From 1cdb010d2bf3d040094b83691331fe1b2f9f973c Mon Sep 17 00:00:00 2001 From: magmaus3 Date: Tue, 16 May 2023 13:28:42 +0200 Subject: [PATCH] Add an example docker-compose file with everything you need for the server to work + reduce the amount of commands used in builds. --- Dockerfile | 15 +++++++-------- README.md | 30 +++++++++++++++++++++++------- TODO.md | 2 +- apache2/apache2.conf | 2 +- docker-compose.yml | 43 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+), 17 deletions(-) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index 24128bc..53ce2b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,15 @@ FROM php:apache RUN docker-php-ext-install pdo_mysql -RUN apt update && apt install -y git -RUN git clone --depth 1 --branch master https://github.com/cvolton/gmdprivateserver /gdps +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 && \ + chown -R www-data:www-data /gdps/data && \ + chmod 774 /gdps/data -R COPY config/ /gdps/config -RUN apt autoremove -y -RUN chown -R www-data:www-data /gdps/data -RUN chmod 774 /gdps/data -R -RUN cp -r /etc/apache2/mods-available /tmp/mods -RUN rm -rf /etc/apache2/ +RUN cp -r /etc/apache2/mods-available /tmp/mods && ls /tmp/mods && \ + rm -rf /etc/apache2/ && mkdir /etc/apache2 && \ + mv /tmp/mods /etc/apache2/mods-available 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 # to responses that can't have additional data, like getGJLevels21.php diff --git a/README.md b/README.md index 15e9391..c3fe734 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,29 @@ ## 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 ``` - -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 -docker run -p 8080:80 -it -``` + + + + + + diff --git a/TODO.md b/TODO.md index a8db53d..6dfd83b 100644 --- a/TODO.md +++ b/TODO.md @@ -8,7 +8,7 @@ - [x] Add the server to the image -- [] test the image +- [x] test the image - [x] basic functionality - [x] playing levels (works, `/gdps/data` has to be writeable) - [x] uploading levels diff --git a/apache2/apache2.conf b/apache2/apache2.conf index a326a11..52759af 100644 --- a/apache2/apache2.conf +++ b/apache2/apache2.conf @@ -9,7 +9,7 @@ Group ${APACHE_RUN_GROUP} HostnameLookups Off 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 "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %O" common diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..23a0c4e --- /dev/null +++ b/docker-compose.yml @@ -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