build-configs/templates/Dockerfile.twig
Oliver Davies 1e800c0a56 refactor: run each command in a separate layer
This makes it easier to debug from which command an error might be
coming from.
2023-02-14 10:41:08 +00:00

68 lines
1.6 KiB
Twig

FROM php:{{ php.version }} AS base
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
RUN which composer && composer -V
WORKDIR /app
ENV PATH="${PATH}:/app/vendor/bin"
COPY composer.* ./
{% if dockerfile.stages.build %}
################################################################################
FROM {{ dockerfile.stages.build.extends }} AS build
{% if dockerfile.stages.build.packages %}
RUN apt-get update -yqq \
&& apt-get install -yqq --no-install-recommends \
{{ dockerfile.stages.build.packages | join(' ') }}
{% endif %}
{% if dockerfile.stages.build.extensions.install %}
RUN docker-php-ext-install {{ dockerfile.stages.build.extensions.install | join(' ') }}
{% endif %}
RUN {% for command in dockerfile.stages.build.commands %}
{% if not loop.first %} && {% endif %}
{{ command }}
{%- if not loop.last %} \{% endif %}
{% for command in dockerfile.stages.build.commands %}
RUN {{ command }}
{% endfor %}
{% endif %}
COPY tools/docker/images/php/root /
ENTRYPOINT ["/usr/local/bin/docker-entrypoint-php"]
CMD ["php-fpm"]
{% if dockerfile.stages.test %}
################################################################################
FROM {{ dockerfile.stages.test.extends }} AS test
COPY . .
RUN {% for command in dockerfile.stages.test.commands -%}
{% if not loop.first %} && {% endif %}
{{ command }}
{%- if not loop.last %} \{% endif %}
{% endfor %}
{% endif %}
{% if web.type == "nginx" %}
################################################################################
FROM nginx:1 as web
EXPOSE 8080
WORKDIR /app
COPY tools/docker/images/nginx/root /
{% endif %}