clsource

Docker Compose for ProcessWire

Recommended Posts

Here is my setup:

My Dockerfile:

#
# PHP Dependencies
#
FROM composer:1.7 as vendor

COPY web/ /app

RUN composer install \
    --ignore-platform-reqs \
    --no-interaction \
    --no-plugins \
    --no-scripts \
    --prefer-dist

#
# Frontend
#
FROM node:latest as frontend

COPY --from=vendor /app /app

WORKDIR /app/site/templates

RUN npm install --global gulp-cli && \
    npm --prefix /app/site/templates install gulp /app/site/templates && \
    npm --prefix /app/site/templates install /app/site/templates && \
    gulp build

#
# Application
#
FROM php:7.2.7-fpm-alpine

COPY --from=frontend /app /var/www/html

WORKDIR /var/www

RUN apk add --update $PHPIZE_DEPS \
        freetype-dev \
        libjpeg-turbo-dev \
        libpng-dev \
    && docker-php-ext-install iconv pdo pdo_mysql mysqli opcache zip \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install gd \
    && rm -rf /var/cache/apk/* \
    && chown -R www-data:www-data .

# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN { \
		echo 'opcache.memory_consumption=128'; \
		echo 'opcache.interned_strings_buffer=8'; \
		echo 'opcache.max_accelerated_files=4000'; \
		echo 'opcache.revalidate_freq=2'; \
		echo 'opcache.fast_shutdown=1'; \
		echo 'opcache.enable_cli=1'; \
	} > /usr/local/etc/php/conf.d/opcache-recommended.ini \

My dev_docker-compose.yml:

version: '3'
services:
    web:
        image: nginx:alpine
        volumes:
            - ./etc/nginx/default.conf:/etc/nginx/conf.d/default.conf:delegated
            - ./etc/ssl:/etc/ssl:delegated
            - ./web:/var/www/html:delegated
            - ./etc/nginx/default.template.conf:/etc/nginx/conf.d/default.template:delegated
            - ./logs/nginx/:/var/log/nginx:cached
        ports:
            - "8000:80"
            - "3000:443"
        environment:
            - NGINX_HOST=${NGINX_HOST}
        command: /bin/sh -c "envsubst '$$NGINX_HOST' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
        restart: always
        depends_on:
            - php
            - mysqldb
    php:
        build: ./
        image: app:latest
        restart: always
        environment:
          MYSQL_HOST: ${MARIADB_HOST}
          MYSQL_PORT: 3306
          MYSQL_DATABASE: ${MARIADB_DATABASE}
          MYSQL_USER: ${MARIADB_USER}
          MYSQL_PASSWORD: ${MARIADB_PASSWORD}
        volumes:
            - ./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini
            - ./web:/var/www/html:delegated
            - ./assets:/var/www/html/site/assets:delegated
    composer:
        image: "composer"
        volumes:
            - ./web:/app
        command: install --ignore-platform-reqs
    myadmin:
        image: phpmyadmin/phpmyadmin
        container_name: phpmyadmin
        ports:
            - "8080:80"
        environment:
            - PMA_ARBITRARY=1
            - PMA_HOST=${MARIADB_HOST}
        restart: always
        depends_on:
            - mysqldb
    mysqldb:
        image: mariadb:${MARIADB_VERSION}
        container_name: ${MARIADB_HOST}
        restart: always
        env_file:
            - ".env"
        environment:
            - MYSQL_DATABASE=${MARIADB_DATABASE}
            - MYSQL_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD}
            - MYSQL_USER=${MARIADB_USER}
            - MYSQL_PASSWORD=${MARIADB_PASSWORD}
        ports:
            - "8989:3306"
        volumes:
            - ./data/db/mysql:/var/lib/mysql:delegated

my prod_docker-compose.yml

version: '3'
services:
    web:
        image: nginx:alpine
        volumes:
            - ./etc/nginx/default.conf:/etc/nginx/conf.d/default.conf
            - ./etc/ssl:/etc/ssl
            - ./etc/nginx/default.template.conf:/etc/nginx/conf.d/default.template
            - ./logs/nginx/:/var/log/nginx
            - webroot-volume:/var/www/html
        ports:
            - "80:80"
            - "443:443"
        environment:
            - NGINX_HOST=${NGINX_HOST}
        command: /bin/sh -c "envsubst '$$NGINX_HOST' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
        restart: always
        depends_on:
            - php
            - mysqldb
    php:
        image: app:latest
        restart: always
        environment:
          MYSQL_HOST: ${MARIADB_HOST}
          MYSQL_PORT: 3306
          MYSQL_DATABASE: ${MARIADB_DATABASE}
          MYSQL_USER: ${MARIADB_USER}
          MYSQL_PASSWORD: ${MARIADB_PASSWORD}
        volumes:
            - webroot-volume:/var/www/html
            - ./assets:/var/www/html/site/assets
    mysqldb:
        image: mariadb:${MARIADB_VERSION}
        container_name: ${MARIADB_HOST}
        restart: always
        env_file:
            - ".env"
        environment:
            - MYSQL_DATABASE=${MARIADB_DATABASE}
            - MYSQL_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD}
            - MYSQL_USER=${MARIADB_USER}
            - MYSQL_PASSWORD=${MARIADB_PASSWORD}
        volumes:
            - ./data/db/mysql:/var/lib/mysql
volumes:
     webroot-volume:

 

  • Like 1

Share this post


Link to post
Share on other sites

  • Recently Browsing   0 members

    No registered users viewing this page.