Create base images with variants corresponding to PHP image variants
This commit is contained in:
parent
f394bf42eb
commit
562599b00f
@ -1,24 +1,6 @@
|
||||
ARG BASE_VERSION=latest
|
||||
ARG REGISTRY=docker.io
|
||||
|
||||
FROM $REGISTRY/cojedzie/base:$BASE_VERSION as base
|
||||
|
||||
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/
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
RUN install-php-extensions bcmath intl opcache zip sockets;
|
||||
|
||||
COPY --from=base /var/www /var/www
|
||||
|
||||
ENV APP_ENV=prod
|
||||
ENV DATABASE_URL="sqlite:////var/db/app.db"
|
||||
ENV PATH=$PATH:/var/www/bin
|
||||
|
||||
VOLUME /var/db
|
||||
FROM $REGISTRY/cojedzie/base:${BASE_VERSION}-fpm as base
|
||||
|
||||
CMD ["./bin/docker-init.sh", "php-fpm"]
|
||||
|
@ -1,26 +1,10 @@
|
||||
ARG BASE_VERSION=latest
|
||||
ARG REGISTRY=docker.io
|
||||
|
||||
FROM $REGISTRY/cojedzie/base:$BASE_VERSION as base
|
||||
FROM $REGISTRY/cojedzie/base:${BASE_VERSION} as base
|
||||
|
||||
FROM php:7.4-alpine
|
||||
|
||||
LABEL maintainer="Kacper Donat <kacper@kadet.net>"
|
||||
|
||||
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
RUN install-php-extensions bcmath intl opcache zip sockets;
|
||||
|
||||
COPY --from=base /var/www /var/www
|
||||
|
||||
ENV APP_ENV=prod
|
||||
ENV DATABASE_URL="sqlite:////var/db/app.db"
|
||||
ENV PATH=$PATH:/var/www/bin
|
||||
|
||||
VOLUME /var/db
|
||||
COPY --from=spiralscout/roadrunner:1.9.2 /usr/bin/rr /usr/bin/rr
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["./bin/docker-init.sh", "rr", "serve"]
|
||||
CMD ["./bin/docker-init.sh", "rr", "serve", "-v"]
|
||||
|
@ -24,5 +24,7 @@ ENV APP_ENV=prod
|
||||
|
||||
RUN composer run-script post-install-cmd
|
||||
|
||||
VOLUME /var/db
|
||||
|
||||
# This image is not meant to be run, just to prepare all required files
|
||||
CMD ["/bin/false"]
|
||||
|
27
build/base/cli.Dockerfile
Normal file
27
build/base/cli.Dockerfile
Normal file
@ -0,0 +1,27 @@
|
||||
ARG BASE_VERSION=latest
|
||||
ARG REGISTRY=docker.io
|
||||
|
||||
FROM $REGISTRY/cojedzie/base:$BASE_VERSION as base
|
||||
|
||||
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/
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
RUN install-php-extensions bcmath intl opcache zip sockets;
|
||||
|
||||
COPY composer.json composer.lock ./
|
||||
|
||||
COPY --from=base /var/www /var/www
|
||||
|
||||
ENV APP_ENV=prod
|
||||
ENV DATABASE_URL="sqlite:////var/db/app.db"
|
||||
ENV PATH=$PATH:/var/www/bin
|
||||
|
||||
VOLUME /var/db
|
||||
|
||||
# This image is not meant to be run, just to prepare all required files
|
||||
CMD ["/bin/false"]
|
27
build/base/fpm.Dockerfile
Normal file
27
build/base/fpm.Dockerfile
Normal file
@ -0,0 +1,27 @@
|
||||
ARG BASE_VERSION=latest
|
||||
ARG REGISTRY=docker.io
|
||||
|
||||
FROM $REGISTRY/cojedzie/base:$BASE_VERSION as base
|
||||
|
||||
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/
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
RUN install-php-extensions bcmath intl opcache zip sockets;
|
||||
|
||||
COPY composer.json composer.lock ./
|
||||
|
||||
COPY --from=base /var/www /var/www
|
||||
|
||||
ENV APP_ENV=prod
|
||||
ENV DATABASE_URL="sqlite:////var/db/app.db"
|
||||
ENV PATH=$PATH:/var/www/bin
|
||||
|
||||
VOLUME /var/db
|
||||
|
||||
# This image is not meant to be run, just to prepare all required files
|
||||
CMD ["/bin/false"]
|
@ -135,20 +135,22 @@ fi
|
||||
|
||||
if [ $BUILD_BASE -eq 1 ]; then
|
||||
build --no-register base $ROOT/api/ || exit 1
|
||||
build --no-register --variant fpm base $ROOT/api/ || exit 1
|
||||
build --no-register --variant cli base $ROOT/api/ || exit 1
|
||||
fi
|
||||
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
api)
|
||||
build api $ROOT/api/ --variant rr --default || exit 1
|
||||
build api $ROOT/api/ --variant fpm || exit 1
|
||||
build api $BUILD/api/ --variant rr --default || exit 1
|
||||
build api $BUILD/api/ --variant fpm || exit 1
|
||||
;;
|
||||
standalone)
|
||||
build standalone $ROOT/api/ --variant rr --default || exit 1
|
||||
build standalone $BUILD/standalone/ --variant rr --default || exit 1
|
||||
;;
|
||||
worker)
|
||||
build worker $ROOT/api/ || exit 1
|
||||
build worker $BUILD/worker/ || exit 1
|
||||
;;
|
||||
front)
|
||||
build front $ROOT/front/ || exit 1
|
||||
|
@ -3,13 +3,14 @@ ARG REGISTRY=docker.io
|
||||
|
||||
FROM ${REGISTRY}/cojedzie/api:${BASE_VERSION}-rr
|
||||
|
||||
RUN apk add supervisor && \
|
||||
# escape=`
|
||||
RUN apk add supervisor gettext && \
|
||||
{ \
|
||||
echo '[supervisord]'; \
|
||||
echo 'nodaemon=true'; \
|
||||
echo ; \
|
||||
echo '[program:roadrunner]'; \
|
||||
echo 'command=rr serve'; \
|
||||
echo 'command=rr serve -v'; \
|
||||
echo 'startsecs=0'; \
|
||||
echo 'start=true'; \
|
||||
echo 'autorestart=true'; \
|
||||
@ -19,7 +20,7 @@ RUN apk add supervisor && \
|
||||
echo 'stderr_logfile_maxbytes=0'; \
|
||||
echo ; \
|
||||
echo '[program:messenger-consumer]'; \
|
||||
echo 'command=php /var/www/bin/console messenger:consume main -vv --time-limit=86400 --limit=10'; \
|
||||
echo 'command=php /var/www/bin/console messenger:consume $COJEDZIE_WORKER_OPTS $COJEDZIE_WORKER_QUEUES'; \
|
||||
echo 'startsecs=0'; \
|
||||
echo 'start=true'; \
|
||||
echo 'autorestart=true'; \
|
||||
@ -27,6 +28,11 @@ RUN apk add supervisor && \
|
||||
echo 'stderr_logfile=/dev/stderr'; \
|
||||
echo 'stdout_logfile_maxbytes=0'; \
|
||||
echo 'stderr_logfile_maxbytes=0'; \
|
||||
} | tee /etc/supervisord.conf;
|
||||
} | tee /etc/supervisord.conf.tpl;
|
||||
|
||||
CMD ["./bin/docker-init.sh", "supervisord", "-c", "/etc/supervisord.conf"]
|
||||
COPY ./supervisord-init.sh ./bin/
|
||||
|
||||
ENV COJEDZIE_WORKER_QUEUES=main
|
||||
ENV COJEDZIE_WORKER_OPTS="-vv --time-limit=86400 --limit=10 --memory-limit=128M"
|
||||
|
||||
CMD ["./bin/supervisord-init.sh", "supervisord", "-c", "/etc/supervisord.conf"]
|
||||
|
7
build/standalone/supervisord-init.sh
Executable file
7
build/standalone/supervisord-init.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -f /etc/supervisord.conf.tpl ]; then
|
||||
envsubst < /etc/supervisord.conf.tpl > /etc/supervisord.conf
|
||||
fi
|
||||
|
||||
exec "$@"
|
@ -1,31 +1,15 @@
|
||||
ARG BASE_VERSION=latest
|
||||
ARG REGISTRY=docker.io
|
||||
|
||||
FROM $REGISTRY/cojedzie/base:$BASE_VERSION as base
|
||||
FROM $REGISTRY/cojedzie/base:${BASE_VERSION}-cli
|
||||
|
||||
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/
|
||||
|
||||
WORKDIR /var/www
|
||||
|
||||
RUN install-php-extensions bcmath intl opcache zip sockets;
|
||||
|
||||
COPY --from=base /var/www /var/www
|
||||
|
||||
ENV APP_ENV=prod
|
||||
ENV DATABASE_URL="sqlite:////var/db/app.db"
|
||||
ENV PATH=$PATH:/var/www/bin
|
||||
|
||||
RUN apk add supervisor && \
|
||||
RUN apk add supervisor gettext && \
|
||||
{ \
|
||||
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 'command=php /var/www/bin/console messenger:consume $COJEDZIE_WORKER_OPTS $COJEDZIE_WORKER_QUEUES'; \
|
||||
echo 'startsecs=0'; \
|
||||
echo 'start=true'; \
|
||||
echo 'autorestart=true'; \
|
||||
@ -33,8 +17,11 @@ RUN apk add supervisor && \
|
||||
echo 'stderr_logfile=/dev/stderr'; \
|
||||
echo 'stdout_logfile_maxbytes=0'; \
|
||||
echo 'stderr_logfile_maxbytes=0'; \
|
||||
} | tee /etc/supervisord.conf;
|
||||
} | tee /etc/supervisord.conf.tpl;
|
||||
|
||||
VOLUME /var/db
|
||||
COPY ./supervisord-init.sh ./bin/
|
||||
|
||||
CMD ["supervisord", "-c", "/etc/supervisord.conf"]
|
||||
ENV COJEDZIE_WORKER_QUEUES=main
|
||||
ENV COJEDZIE_WORKER_OPTS="-vv --time-limit=86400 --limit=10 --memory-limit=128M"
|
||||
|
||||
CMD ["./bin/supervisord-init.sh", "supervisord", "-c", "/etc/supervisord.conf"]
|
||||
|
7
build/worker/supervisord-init.sh
Executable file
7
build/worker/supervisord-init.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -f /etc/supervisord.conf.tpl ]; then
|
||||
envsubst < /etc/supervisord.conf.tpl > /etc/supervisord.conf
|
||||
fi
|
||||
|
||||
exec "$@"
|
Loading…
Reference in New Issue
Block a user