Add an example docker-compose file with everything you need for the

server to work + reduce the amount of commands used in builds.
This commit is contained in:
magmaus3 2023-05-16 13:28:42 +02:00
parent 4339719eca
commit 1cdb010d2b
Signed by: magmaus3
GPG key ID: 966755D3F4A9B251
5 changed files with 75 additions and 17 deletions

View file

@ -1,16 +1,15 @@
FROM php:apache FROM php:apache
RUN docker-php-ext-install pdo_mysql RUN docker-php-ext-install pdo_mysql
RUN apt update && apt install -y git RUN apt-get update && apt-get install --no-install-recommends -y git && apt-get clean
RUN git clone --depth 1 --branch master https://github.com/cvolton/gmdprivateserver /gdps RUN git clone --depth 1 --branch master https://github.com/cvolton/gmdprivateserver /gdps && \
chown -R www-data:www-data /gdps/data && \
chmod 774 /gdps/data -R
COPY config/ /gdps/config COPY config/ /gdps/config
RUN apt autoremove -y RUN cp -r /etc/apache2/mods-available /tmp/mods && ls /tmp/mods && \
RUN chown -R www-data:www-data /gdps/data rm -rf /etc/apache2/ && mkdir /etc/apache2 && \
RUN chmod 774 /gdps/data -R mv /tmp/mods /etc/apache2/mods-available
RUN cp -r /etc/apache2/mods-available /tmp/mods
RUN rm -rf /etc/apache2/
COPY apache2 /etc/apache2 COPY apache2 /etc/apache2
RUN mv /tmp/mods /etc/apache2/mods-available
# HACK: Hide all errors, fixes an issue where php's errors are added # HACK: Hide all errors, fixes an issue where php's errors are added
# to responses that can't have additional data, like getGJLevels21.php # to responses that can't have additional data, like getGJLevels21.php

View file

@ -2,13 +2,29 @@
## Usage: ## Usage:
building: After you clone this repository, you can run the server using `docker compose`,
which includes the server, mariadb database and adminer for managment:
```
docker compose up
```
Make sure to change the passwords included in the file:
- `DB_PASSWORD` for server
- `MARIADB_PASSWORD` for db
- `MARIADB_ROOT_PASSWORD` for db
You'll also need to import the database from [the source code repository](https://raw.githubusercontent.com/Cvolton/GMDprivateServer/master/database.sql).
For more details, check [the project wiki](https://github.com/Cvolton/GMDprivateServer/wiki)
---
building the image:
``` ```
docker buildx build . -t <image tag> docker buildx build . -t <image tag>
``` ```
<!---->
running (remove the `-it` params to run in background): <!-- running (remove the `-it` params to run in background): -->
``` <!-- ``` -->
# Note that you might want to add a volume for /gdps/data, so the levels are preserved <!-- # Note that you might want to add a volume for /gdps/data, so the levels are preserved -->
docker run -p 8080:80 -it <the tag you chose earlier> <!-- docker run -p 8080:80 -it <the tag you chose earlier> -->
``` <!-- ``` -->

View file

@ -8,7 +8,7 @@
- [x] Add the server to the image - [x] Add the server to the image
- [] test the image - [x] test the image
- [x] basic functionality - [x] basic functionality
- [x] playing levels (works, `/gdps/data` has to be writeable) - [x] playing levels (works, `/gdps/data` has to be writeable)
- [x] uploading levels - [x] uploading levels

View file

@ -9,7 +9,7 @@ Group ${APACHE_RUN_GROUP}
HostnameLookups Off HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel debug LogLevel info
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common LogFormat "%h %l %u %t \"%r\" %>s %O" common

43
docker-compose.yml Normal file
View file

@ -0,0 +1,43 @@
services:
service-info: {"image":"busybox:1.36.0", "entrypoint": ["echo", "-e", '\n\n ___ __ __ ____ ___ ____ _____ _ _ _ _____ \n|_ _| \\/ | _ \\ / _ \\| _ \\_ _|/ \\ | \\ | |_ _|\n | || |\\/| | |_) | | | | |_) || | / _ \\ | \\| | | | \n | || | | | __/| |_| | _ < | |/ ___ \\| |\\ | | | \n|___|_| |_|_| \\___/|_| \\_\\|_/_/ \\_\\_| \\_| |_| \n\n IMPORTANT: You will need to import the database dump from https://raw.githubusercontent.com/Cvolton/GMDprivateServer/master/database.sql for the server to work!\n\nProject wiki: https://github.com/Cvolton/GMDprivateServer/wiki\n']}
# service-info:
# # Reminder about setting up your database, you can safely remove this
# image: busybox:1.36.0
# entrypoint: ["echo", "-e", "\n\n ___ __ __ ____ ___ ____ _____ _ _ _ _____ \n|_ _| \\/ | _ \\ / _ \\| _ \\_ _|/ \\ | \\ | |_ _|\n | || |\\/| | |_) | | | | |_) || | / _ \\ | \\| | | | \n | || | | | __/| |_| | _ < | |/ ___ \\| |\\ | | | \n|___|_| |_|_| \\___/|_| \\_\\|_/_/ \\_\\_| \\_| |_| \n\n IMPORTANT: You will need to import the database dump from https://raw.githubusercontent.com/Cvolton/GMDprivateServer/master/database.sql for the server to work!\n\n"]
server:
build: '.'
environment:
DB_SERVER_NAME: "db"
DB_PORT: 3306
DB_USERNAME: "gdps"
DB_PASSWORD: "YouShouldChangeThisPasswordAsWell"
DB_DATABASE_NAME: "geometrydash"
volumes:
# Used for storing levels and saves
- ./data:/gdps/data
ports:
- 8080:80
depends_on:
- service-info
- db
db:
image: mariadb
restart: unless-stopped
environment:
MARIADB_ROOT_PASSWORD: "YouShouldChangeThatUwU"
MARIADB_USER: "gdps"
MARIADB_PASSWORD: "YouShouldChangeThisPasswordAsWell"
MARIADB_DATABASE: "geometrydash"
depends_on:
- service-info
adminer:
image: adminer
restart: unless-stopped
ports:
- 9080:8080
depends_on:
- db