Refactor Dockerfiles for better cacheability
This commit is contained in:
parent
af801110aa
commit
d7ec6aee4d
@ -3,8 +3,6 @@ FROM php:7.4-fpm-alpine
|
||||
ENV DATABASE_URL="sqlite:///var/db/app.db"
|
||||
|
||||
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
|
||||
|
||||
# Composer
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
RUN install-php-extensions bcmath intl opcache zip sockets xdebug-^3.0;
|
@ -1,25 +0,0 @@
|
||||
FROM php:7.4-fpm-alpine
|
||||
|
||||
ENV APP_ENV=prod
|
||||
ENV DATABASE_URL="sqlite:////var/db/app.db"
|
||||
ENV PATH=$PATH:/usr/src/app/bin
|
||||
|
||||
RUN apk add --no-cache autoconf openssl-dev g++ make pcre-dev icu-dev zlib-dev libzip-dev git && \
|
||||
docker-php-ext-install bcmath intl opcache zip sockets && \
|
||||
apk del --purge autoconf g++ make;
|
||||
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
COPY . .
|
||||
|
||||
RUN composer install --no-dev --no-scripts --no-plugins --prefer-dist --no-progress --no-interaction && \
|
||||
composer dump-autoload --optimize && \
|
||||
composer check-platform-reqs && \
|
||||
php bin/console cache:warmup
|
||||
|
||||
# Timezone
|
||||
RUN ln -snf /usr/share/zoneinfo/Europe/Warsaw /etc/localtime &&
|
||||
echo "date.timezone = Europe/Warsaw" >> /usr/local/etc/php/conf.d/datetime.ini;
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
CMD ["./bin/docker-init.sh", "php-fpm"]
|
@ -1,25 +0,0 @@
|
||||
FROM php:7.4-alpine
|
||||
|
||||
ENV APP_ENV=prod
|
||||
ENV DATABASE_URL="sqlite:////var/db/app.db"
|
||||
ENV PATH=$PATH:/usr/src/app/bin
|
||||
|
||||
RUN apk add --no-cache autoconf openssl-dev g++ make pcre-dev icu-dev zlib-dev libzip-dev git && \
|
||||
docker-php-ext-install bcmath intl opcache zip sockets && \
|
||||
apk del --purge autoconf g++ make
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
COPY . .
|
||||
|
||||
RUN composer install --no-dev --no-scripts --no-plugins --prefer-dist --no-progress --no-interaction
|
||||
RUN ./vendor/bin/rr get-binary --location /usr/local/bin
|
||||
|
||||
RUN composer dump-autoload --optimize && \
|
||||
composer check-platform-reqs && \
|
||||
php bin/console cache:warmup
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["./bin/docker-init.sh", "rr", "serve"]
|
@ -13,12 +13,12 @@ services:
|
||||
api:
|
||||
build:
|
||||
context: ./api
|
||||
dockerfile: dev.Dockerfile
|
||||
dockerfile: Dockerfile
|
||||
env_file:
|
||||
- ./docker/php/.env
|
||||
- ./docker/api/.env
|
||||
volumes:
|
||||
- ./api:/var/www:cached
|
||||
- ./docker/php/log.conf:/usr/local/etc/php-fpm.d/zz-log.conf
|
||||
- ./docker/api/log.conf:/usr/local/etc/php-fpm.d/zz-log.conf
|
||||
|
||||
frontend:
|
||||
image: node:15.2.1
|
||||
|
29
docker/api/fpm.Dockerfile
Normal file
29
docker/api/fpm.Dockerfile
Normal file
@ -0,0 +1,29 @@
|
||||
FROM php:7.4-fpm-alpine
|
||||
|
||||
LABEL maintainer="Kacper Donat <kacper@kadet.net>"
|
||||
|
||||
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
RUN install-php-extensions bcmath intl opcache zip sockets;
|
||||
|
||||
COPY composer.json composer.lock ./
|
||||
|
||||
RUN apk add git && \
|
||||
composer install --no-dev --no-scripts --no-plugins --prefer-dist --no-progress --no-interaction && \
|
||||
composer dump-autoload --optimize && \
|
||||
composer check-platform-reqs && \
|
||||
composer clear-cache && \
|
||||
apk del --purge git
|
||||
|
||||
COPY . .
|
||||
|
||||
ENV APP_ENV=prod
|
||||
ENV DATABASE_URL="sqlite:////var/db/app.db"
|
||||
ENV PATH=$PATH:/var/www/bin
|
||||
|
||||
RUN composer run-script post-install-cmd
|
||||
|
||||
CMD ["./bin/docker-init.sh", "php-fpm"]
|
37
docker/api/rr.Dockerfile
Normal file
37
docker/api/rr.Dockerfile
Normal file
@ -0,0 +1,37 @@
|
||||
FROM php:7.4-alpinpe
|
||||
|
||||
LABEL maintainer="Kacper Donat <kacper@kadet.net>"
|
||||
|
||||
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
RUN install-php-extensions bcmath intl opcache zip sockets;
|
||||
|
||||
COPY composer.json composer.lock ./
|
||||
|
||||
RUN apk add git && \
|
||||
composer install --no-dev --no-scripts --no-plugins --prefer-dist --no-progress --no-interaction && \
|
||||
composer dump-autoload --optimize && \
|
||||
composer check-platform-reqs && \
|
||||
composer clear-cache && \
|
||||
apk del --purge git
|
||||
|
||||
# this touch is needed because get-binary calls the autoloader
|
||||
RUN mkdir -p ./src/Functions && \
|
||||
touch src/Functions/index.php && \
|
||||
./vendor/bin/rr get-binary --location /usr/local/bin
|
||||
|
||||
COPY . .
|
||||
|
||||
ENV APP_ENV=prod
|
||||
ENV DATABASE_URL="sqlite:////var/db/app.db"
|
||||
ENV PATH=$PATH:/var/www/bin
|
||||
|
||||
RUN composer run-script post-install-cmd
|
||||
RUN mkdir /var/db
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["./bin/docker-init.sh", "rr", "serve"]
|
45
docker/worker/Dockerfile
Normal file
45
docker/worker/Dockerfile
Normal file
@ -0,0 +1,45 @@
|
||||
FROM php:7.4-cli-alpine
|
||||
|
||||
LABEL maintainer="Kacper Donat <kacper@kadet.net>"
|
||||
|
||||
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
RUN apk add supervisor && \
|
||||
{ \
|
||||
echo '[supervisord]'; \
|
||||
echo 'nodaemon=true'; \
|
||||
echo ; \
|
||||
echo '[program:messenger-consumer]'; \
|
||||
echo 'command=php /var/www/bin/console messenger:consume main -vv --time-limit=86400 --limit=10'; \
|
||||
echo 'startsecs=0'; \
|
||||
echo 'start=true'; \
|
||||
echo 'autorestart=true'; \
|
||||
echo 'stdout_logfile=/dev/stdout'; \
|
||||
echo 'stderr_logfile=/dev/stderr'; \
|
||||
echo 'stdout_logfile_maxbytes=0'; \
|
||||
echo 'stderr_logfile_maxbytes=0'; \
|
||||
} | tee /etc/supervisord.conf;
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
RUN install-php-extensions bcmath intl opcache zip sockets;
|
||||
|
||||
COPY composer.json composer.lock ./
|
||||
|
||||
RUN apk add git && \
|
||||
composer install --no-dev --no-scripts --no-plugins --prefer-dist --no-progress --no-interaction && \
|
||||
composer dump-autoload --optimize && \
|
||||
composer check-platform-reqs && \
|
||||
composer clear-cache && \
|
||||
apk del --purge git
|
||||
|
||||
COPY . .
|
||||
|
||||
ENV APP_ENV=prod
|
||||
ENV DATABASE_URL="sqlite:////var/db/app.db"
|
||||
ENV PATH=$PATH:/var/www/bin
|
||||
|
||||
RUN composer run-script post-install-cmd
|
||||
|
||||
CMD ["supervisord", "-c", "/etc/supervisord.conf"]
|
2
docker/worker/supervisord.conf
Normal file
2
docker/worker/supervisord.conf
Normal file
@ -0,0 +1,2 @@
|
||||
[supervisord]
|
||||
nodaemon=true
|
@ -23,6 +23,8 @@ RUN yarn install --production
|
||||
|
||||
FROM node:15.2.1-slim
|
||||
|
||||
LABEL maintainer="Kacper Donat <kacper@kadet.net>"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=build /app/build/ build
|
||||
|
Loading…
Reference in New Issue
Block a user