From b239d6aa185924118065e8b89bdb846b37e86dd9 Mon Sep 17 00:00:00 2001 From: BirkhoffLee Date: Sat, 4 Aug 2018 12:48:44 +0800 Subject: [PATCH] Improve Dockerfile Add restart policy. Use Traefik --- .gitignore | 1 - .docker-compose.yml => docker-compose.yml | 41 +++++++++------- services/php/Dockerfile | 57 +++++++++++------------ 3 files changed, 51 insertions(+), 48 deletions(-) delete mode 100644 .gitignore rename .docker-compose.yml => docker-compose.yml (56%) diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 1120be9..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -docker-compose.yml diff --git a/.docker-compose.yml b/docker-compose.yml similarity index 56% rename from .docker-compose.yml rename to docker-compose.yml index 5fec916..fbed868 100644 --- a/.docker-compose.yml +++ b/docker-compose.yml @@ -1,53 +1,60 @@ -version: "3" +version: "3.1" + services: + db: + image: mariadb + restart: unless-stopped environment: - "MYSQL_DATABASE=pterodactyl" - "MYSQL_PASSWORD=pterodactyl" - "MYSQL_RANDOM_ROOT_PASSWORD=yes" - "MYSQL_USER=pterodactyl" - image: mariadb:latest networks: + - traefik - default volumes: - - db:/var/lib/mysql + - ./db:/var/lib/mysql + http: build: context: services/http dockerfile: Dockerfile + restart: unless-stopped depends_on: - "php" - ports: - - "80:80" + expose: + - 80 networks: + - traefik - default volumes: - - env:/var/www/html/env - - panel:/var/www/html/pterodactyl - - storage:/var/www/html/pterodactyl/storage + - ./env:/var/www/html/env + - ./panel:/var/www/html/pterodactyl + - ./storage:/var/www/html/pterodactyl/storage + php: build: context: services/php dockerfile: Dockerfile + restart: unless-stopped depends_on: - "db" networks: - default volumes: - - env:/var/www/html/env - - panel:/var/www/html/pterodactyl - - storage:/var/www/html/pterodactyl/storage + - ./env:/var/www/html/env + - ./panel:/var/www/html/pterodactyl + - ./storage:/var/www/html/pterodactyl/storage + redis: image: redis:alpine + restart: unless-stopped networks: - default networks: default: driver: bridge - -volumes: - db: - env: - panel: - storage: + traefik: + external: true diff --git a/services/php/Dockerfile b/services/php/Dockerfile index 2e93acd..128d859 100644 --- a/services/php/Dockerfile +++ b/services/php/Dockerfile @@ -1,52 +1,49 @@ FROM php:7.2-fpm-alpine -ENV PANEL_VERSION=v0.7.7 +ENV PANEL_VERSION=v0.7.9 # Set up all the dependencies for the PHP container. -RUN apk add --no-cache curl git supervisor tar unzip -RUN docker-php-ext-install bcmath -# https://github.com/docker-library/php/issues/483 -# RUN docker-php-ext-install curl -# https://stackoverflow.com/questions/39657058/installing-gd-in-docker#39658592 -RUN apk add --no-cache libpng-dev -RUN docker-php-ext-install gd -RUN docker-php-ext-install mbstring -RUN docker-php-ext-install pdo -RUN docker-php-ext-install pdo_mysql -RUN docker-php-ext-install tokenizer -# https://lists.alpinelinux.org/alpine-aports/2526.html -RUN apk add --no-cache libxml2-dev -RUN docker-php-ext-install xml -RUN docker-php-ext-install zip -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer +RUN apk add --no-cache curl git supervisor tar unzip; \ + docker-php-ext-install bcmath; \ + apk add --no-cache libpng-dev; \ + docker-php-ext-install gd; \ + docker-php-ext-install mbstring; \ + docker-php-ext-install pdo; \ + docker-php-ext-install pdo_mysql; \ + docker-php-ext-install tokenizer; \ + apk add --no-cache libxml2-dev; \ + docker-php-ext-install xml; \ + docker-php-ext-install zip; \ + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer # Set up the server working directories. -RUN adduser -g '' -D -u 9999 pterodactyl -RUN mkdir -p /var/www/html/env -RUN mkdir -p /var/www/html/pterodactyl +RUN adduser -g '' -D -u 9999 pterodactyl; \ + mkdir -p /var/www/html/env; \ + mkdir -p /var/www/html/pterodactyl + WORKDIR /var/www/html/pterodactyl RUN chown -R pterodactyl:pterodactyl /var/www/html/pterodactyl /var/www/html/env # Deploy panel files. USER pterodactyl:pterodactyl -RUN curl -Lo panel.tar.gz https://github.com/Pterodactyl/Panel/releases/download/${PANEL_VERSION}/panel.tar.gz -RUN tar --strip-components=1 -xzvf panel.tar.gz -# Since Docker's configuration mounting feature sucks, we're going to use a cheap -# workaround involving symbolic links. -RUN cp .env.example /var/www/html/env/.env -RUN ln -s /var/www/html/env/.env /var/www/html/pterodactyl/.env -RUN composer install --no-dev -RUN chmod -R 755 storage/* bootstrap/cache +RUN curl -Lo panel.tar.gz https://github.com/Pterodactyl/Panel/releases/download/${PANEL_VERSION}/panel.tar.gz; \ + tar --strip-components=1 -xzvf panel.tar.gz; \ + cp .env.example /var/www/html/env/.env; \ + ln -s /var/www/html/env/.env /var/www/html/pterodactyl/.env; \ + composer install --no-dev; \ + chmod -R 755 storage/* bootstrap/cache # Copy the remaining configuration files. USER root:root RUN mkdir -p /var/log/pterodactyl + COPY install.sh /usr/local/bin/install -RUN chmod +x /usr/local/bin/install COPY upgrade.sh /usr/local/bin/upgrade -RUN chmod +x /usr/local/bin/upgrade COPY schedule /var/spoon/cron/crontabs/schedule COPY supervisord.conf /etc/supervisor/supervisord.conf COPY www.conf /usr/local/etc/php-fpm.d/www.conf +RUN chmod +x /usr/local/bin/install; \ + chmod +x /usr/local/bin/upgrade + ENTRYPOINT ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf"]