build-configs/templates/Dockerfile.twig

90 lines
2 KiB
Docker
Raw Normal View History

2023-01-19 19:47:15 +00:00
FROM php:{{ php.version }} AS base
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
RUN which composer && composer -V
ARG DOCKER_UID=1000
ENV DOCKER_UID="${DOCKER_UID}"
2023-01-19 19:47:15 +00:00
WORKDIR /app
RUN adduser --disabled-password --uid "${DOCKER_UID}" app \
&& chown app:app -R /app
USER app
2023-01-19 19:47:15 +00:00
ENV PATH="${PATH}:/app/vendor/bin"
COPY --chown=app:app composer.* ./
2023-01-19 19:47:15 +00:00
{% if dockerfile.stages.build %}
################################################################################
FROM {{ dockerfile.stages.build.extends }} AS build
USER root
2023-01-19 19:47:15 +00:00
{% 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 %}
{% for directory in dockerfile.stages.build.extra_directories %}
COPY --chown=app:app {{ directory }} {{ directory }}
{% endfor %}
USER app
{% for command in dockerfile.stages.build.commands %}
RUN {{ command }}
2023-01-19 19:47:15 +00:00
{% endfor %}
{% endif %}
COPY --chown=app:app tools/docker/images/php/root /
2023-01-21 19:52:58 +00:00
ENTRYPOINT ["/usr/local/bin/docker-entrypoint-php"]
CMD ["php-fpm"]
2023-01-19 19:47:15 +00:00
{% if dockerfile.stages.test %}
################################################################################
FROM {{ dockerfile.stages.test.extends }} AS test
COPY --chown=app:app . .
2023-01-19 19:47:15 +00:00
RUN {% for command in dockerfile.stages.test.commands -%}
{% if not loop.first %} && {% endif %}
{{ command }}
2023-01-19 19:47:15 +00:00
{%- if not loop.last %} \{% endif %}
2023-01-19 19:47:15 +00:00
{% endfor %}
{% endif %}
2023-02-14 20:14:43 +00:00
{% if web.type == "caddy" %}
################################################################################
FROM caddy:2 as web
WORKDIR /app
COPY tools/docker/images/web/root /
{% endif %}
2023-01-19 19:47:15 +00:00
{% if web.type == "nginx" %}
################################################################################
FROM nginx:1 as web
EXPOSE 8080
WORKDIR /app
2023-02-14 20:14:43 +00:00
COPY tools/docker/images/web/root /
2023-01-19 19:47:15 +00:00
{% endif %}