Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Feature/dockerize #1275

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# This Dockerfile contains different images

ARG PHP_VERSION=8.0
ARG CADDY_VERSION=2

# Build PHP FPM

ARG APP_ENV=dev

FROM php:${PHP_VERSION}-fpm-alpine AS symfony_php

WORKDIR /srv/symfony
VOLUME /var/run/php
VOLUME /srv/symfony/var

# Install required PHP extensions
RUN set -eux; \
apk add --no-cache \
$PHPIZE_DEPS \
icu-dev \
; \
docker-php-ext-install intl

COPY docker/php/php-fpm.d/zz-docker.conf /usr/local/etc/php-fpm.d/zz-docker.conf

# Install composer
COPY --from=composer:2.0 /usr/bin/composer /usr/bin/composer

ENV COMPOSER_ALLOW_SUPERUSER=1
ENV PATH="${PATH}:/root/.composer/vendor/bin"

# copy only specifically what we need
COPY composer.json composer.lock symfony.lock ./
COPY assets assets/
COPY bin bin/
COPY config config/
COPY data data/
COPY migrations migrations/
COPY public public/
COPY src src/
COPY templates templates/
COPY tests tests/
COPY translations translations/
COPY .env .env.test webpack.config.js yarn.lock ./

RUN set -eux; \
composer install --prefer-dist --no-progress; \
composer clear-cache


RUN set -eux; \
mkdir -p var/cache var/log; \
composer dump-autoload --classmap-authoritative ; \
composer run-script post-install-cmd; \
chmod +x bin/console; sync


# Build Caddy image
FROM caddy:${CADDY_VERSION}-builder-alpine AS symfony_caddy_builder

RUN xcaddy build

FROM caddy:${CADDY_VERSION} AS symfony_caddy
WORKDIR /srv/symfony

COPY --from=symfony_caddy_builder /usr/bin/caddy /usr/bin/caddy
COPY --from=symfony_php /srv/symfony/public public/
COPY docker/caddy/Caddyfile /etc/caddy/Caddyfile

35 changes: 35 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: "3.4"

services:
php:
build:
context: ./
target: symfony_php
depends_on:
- db
restart: unless-stopped
volumes:
- php_socket:/var/run/php

caddy:
build:
context: ./
target: symfony_caddy
depends_on:
- php
environment:
SERVER_NAME: ${SERVER_NAME:-localhost}
restart: unless-stopped
volumes:
- php_socket:/var/run/php
- caddy_data:/data
- caddy_config:/config
ports:
- "80:80"
- "443:443"

volumes:
php_socket:
caddy_data:
caddy_config:

16 changes: 16 additions & 0 deletions docker/caddy/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
# Debug
{$DEBUG}
}

{$SERVER_NAME}

log

handle {
root * /srv/symfony/public

php_fastcgi unix//var/run/php/php-fpm.sock
encode zstd gzip
file_server
}
6 changes: 6 additions & 0 deletions docker/php/php-fpm.d/zz-docker.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[global]
daemonize = no

[www]
listen = /var/run/php/php-fpm.sock
listen.mode = 0666