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
|
|
|
|
|
2023-02-19 12:58:51 +00:00
|
|
|
ARG DOCKER_UID=1000
|
|
|
|
ENV DOCKER_UID="${DOCKER_UID}"
|
|
|
|
|
2023-01-19 19:47:15 +00:00
|
|
|
WORKDIR /app
|
|
|
|
|
2023-02-19 12:58:51 +00:00
|
|
|
RUN adduser --disabled-password --uid "${DOCKER_UID}" app \
|
|
|
|
&& chown app:app -R /app
|
|
|
|
|
|
|
|
USER app
|
|
|
|
|
2023-03-03 21:52:04 +00:00
|
|
|
ENV PATH="${PATH}:/app/bin:/app/vendor/bin"
|
2023-01-19 19:47:15 +00:00
|
|
|
|
2023-02-19 12:58:51 +00:00
|
|
|
COPY --chown=app:app composer.* ./
|
2023-01-19 19:47:15 +00:00
|
|
|
|
|
|
|
{% if dockerfile.stages.build %}
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
FROM {{ dockerfile.stages.build.extends }} AS build
|
|
|
|
|
2023-02-19 12:58:51 +00:00
|
|
|
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 %}
|
|
|
|
|
2023-02-20 23:00:22 +00:00
|
|
|
{% if dockerfile.stages.build.extra_files %}
|
|
|
|
COPY --chown=app:app {{ dockerfile.stages.build.extra_files | join(" ") }} ./
|
|
|
|
{% endif %}
|
2023-02-14 10:41:51 +00:00
|
|
|
{% for directory in dockerfile.stages.build.extra_directories %}
|
2023-02-19 12:58:51 +00:00
|
|
|
COPY --chown=app:app {{ directory }} {{ directory }}
|
2023-02-14 10:41:51 +00:00
|
|
|
{% endfor %}
|
2023-01-19 22:40:09 +00:00
|
|
|
|
2023-02-19 12:58:51 +00:00
|
|
|
USER app
|
|
|
|
|
2023-02-14 10:41:08 +00:00
|
|
|
{% for command in dockerfile.stages.build.commands %}
|
|
|
|
RUN {{ command }}
|
2023-01-19 19:47:15 +00:00
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
|
2023-02-19 12:58:51 +00:00
|
|
|
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
|
|
|
|
|
2023-02-19 12:58:51 +00:00
|
|
|
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 %}
|
2023-01-19 22:40:09 +00:00
|
|
|
{{ command }}
|
2023-01-19 19:47:15 +00:00
|
|
|
{%- if not loop.last %} \{% endif %}
|
2023-01-19 22:40:09 +00:00
|
|
|
|
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 %}
|