Skip to content

Instantly share code, notes, and snippets.

@dkarlovi
Last active March 18, 2020 07:45
Show Gist options
  • Save dkarlovi/81353de1c55ce2056138a0aff7732368 to your computer and use it in GitHub Desktop.
Save dkarlovi/81353de1c55ce2056138a0aff7732368 to your computer and use it in GitHub Desktop.
Symfony + RoadRunner + build-time cache volume Dockerfile
# syntax=docker/dockerfile:experimental
FROM alpine:3.11 AS runtime
WORKDIR /app
RUN addgroup -g 82 -S www-data && \
adduser -u 82 -H -D -S -G www-data www-data && \
apk add --update --no-cache \
php7 \
php7-ctype \
php7-dom \
php7-iconv \
php7-intl \
php7-json \
php7-mbstring \
php7-opcache \
php7-xml \
tini
FROM runtime AS installer
WORKDIR /app
RUN apk add --update --no-cache \
php7-curl \
php7-openssl \
php7-phar \
php7-zip
COPY --from=composer:1.9 /usr/bin/composer /usr/bin/composer
COPY . /app/
RUN --mount=type=cache,target=/composer COMPOSER_HOME=/composer composer install --classmap-authoritative --no-dev --no-interaction --no-scripts --no-suggest --prefer-dist && \
vendor/bin/rr get-binary --location=vendor/bin --no-interaction && \
bin/console cache:warmup
FROM runtime
EXPOSE 80
WORKDIR /app
# these are layered on purpose
COPY --from=installer /app/vendor /app/vendor
COPY --from=installer /app/public /app/public
COPY --from=installer /app/src /app/src
COPY --from=installer /app/templates /app/templates
COPY --from=installer /app/config /app/config
COPY --from=installer /app/.rr.yaml /app/.rr.yaml
COPY --from=installer /app/bin /app/bin
COPY --from=installer /app/var /app/var
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["/app/vendor/bin/rr", "serve", "-v", "-d"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment