11# ----------------------------------------------------------------------
22# Download vendor from composer.json in dedicated layer
33# ----------------------------------------------------------------------
4- FROM composer:2.6 as vendor
4+ ARG registry=docker.io
5+ FROM ${registry}/library/composer:latest AS vendor
56
67RUN mkdir -p /opt/validator-api
78WORKDIR /opt/validator-api
89COPY composer.json .
910RUN composer install --no-scripts --prefer-dist --ignore-platform-req=ext-pcntl
1011
1112# ----------------------------------------------------------------------
12- # Create base layer for dev and production
13+ # Create application container
1314# ----------------------------------------------------------------------
14- FROM php:8.2-apache as base
15+ FROM ${registry}/library/ubuntu:24.04
1516
1617ENV DEBIAN_FRONTEND=noninteractive
17- ENV LANG fr_FR.UTF-8
18+ ENV LANG= fr_FR.UTF-8
1819ENV VALIDATOR_PATH=/opt/ign-validator/validator-cli.jar
1920
2021# ----------------------------------------------------------------------
2122# Configure locale to fr_FR.UTF-8
2223# see also https://stackoverflow.com/a/41797247
2324# ----------------------------------------------------------------------
24- RUN apt-get update && apt-get install -y locales \
25+ RUN apt-get update && apt-get install --no-install-recommends - y locales \
2526 && sed -i -e 's/# en_US.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/' /etc/locale.gen \
2627 && dpkg-reconfigure locales \
2728 && update-locale LANG=fr_FR.UTF-8 \
@@ -31,26 +32,64 @@ RUN apt-get update && apt-get install -y locales \
3132# Install common tools
3233# ----------------------------------------------------------------------
3334RUN apt-get update \
34- && apt-get install -y \
35- unzip \
36- make \
35+ && apt-get install --no-install-recommends -y \
36+ unzip zip \
3737 curl wget \
38- zip \
38+ file \
39+ postgresql-client \
40+ && rm -rf /var/lib/apt/lists/*
41+
42+
43+ # ------------------------------------------------------------------------
44+ # Configure https://packages.sury.org/php/ to get latests PHP versions
45+ # ------------------------------------------------------------------------
46+ RUN apt-get update \
47+ && apt-get install --no-install-recommends -y gnupg2 software-properties-common \
48+ && add-apt-repository -y ppa:ondrej/php \
49+ && apt-get remove -y software-properties-common \
3950 && rm -rf /var/lib/apt/lists/*
4051
4152# ----------------------------------------------------------------------
42- # Configure PHP
53+ # Install Apache, PHP and its extensions
54+ # TODO : php8.3-pcntl ?
4355# ----------------------------------------------------------------------
44- COPY .docker/php.ini /usr/local/etc/php/conf.d/app.ini
56+ RUN apt-get update \
57+ && apt-get install --no-install-recommends -y \
58+ apache2 php8.3 libapache2-mod-php8.3 \
59+ php8.3-opcache php8.3-xml \
60+ php8.3-pdo php8.3-pgsql php8.3-zip \
61+ && rm -rf /var/lib/apt/lists/*
62+
63+ # ------------------------------------------------------------------------
64+ # Add helper script to start apache
65+ # (see https://github.com/docker-library/php)
66+ # ------------------------------------------------------------------------
67+ COPY .docker/apache2-foreground /usr/local/bin/apache2-foreground
68+ RUN chmod +x /usr/local/bin/apache2-foreground
69+
70+ # ------------------------------------------------------------------------
71+ # Create apache2 repository
72+ # (see https://github.com/docker-library/php)
73+ # ------------------------------------------------------------------------
74+ RUN mkdir -p /var/run/apache2 && chown -R www-data:www-data /var/run/apache2 \
75+ && mkdir -p /var/lock/apache2 && chown -R www-data:www-data /var/lock/apache2 \
76+ && mkdir -p /var/log/apache2 && chown -R www-data:www-data /var/log/apache2
77+
78+ # ------------------------------------------------------------------------
79+ # Redirects logs to stdout / stderr
80+ # (see https://github.com/docker-library/php)
81+ # ------------------------------------------------------------------------
82+ RUN ln -sfT /dev/stderr "/var/log/apache2/error.log" \
83+ && ln -sfT /dev/stdout "/var/log/apache2/access.log" \
84+ && ln -sfT /dev/stdout "/var/log/apache2/other_vhosts_access.log" \
85+ && chown www-data:www-data /var/log/apache2/*.log
86+
4587
4688# ----------------------------------------------------------------------
47- # Install PHP extensions
89+ # Configure PHP
4890# ----------------------------------------------------------------------
49- RUN apt-get update -qq \
50- && apt-get install -y postgresql-client libpq-dev libzip-dev \
51- && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
52- && docker-php-ext-install opcache pdo pdo_pgsql pgsql zip pcntl \
53- && rm -rf /var/lib/apt/lists/*
91+ COPY .docker/php.ini /etc/php/8.3/apache2/php.ini
92+ # TODO .docker/php.ini /etc/php/8.3/cli/php.ini
5493
5594# ----------------------------------------------------------------------
5695# Configure apache
@@ -61,13 +100,14 @@ COPY .docker/apache-vhost.conf /etc/apache2/sites-available/000-default.conf
61100
62101RUN a2enmod rewrite remoteip
63102
103+
64104# ----------------------------------------------------------------------
65105# Setup validator-cli.jar dependencies (java & ogr2ogr)
66106# ----------------------------------------------------------------------
67107RUN apt-get update -qq \
68108 # see https://github.com/debuerreotype/docker-debian-artifacts/issues/24
69109 && mkdir -p /usr/share/man/man1 \
70- && apt-get install -y openjdk-17-jdk-headless gdal-bin \
110+ && apt-get install --no-install-recommends - y openjdk-17-jdk-headless gdal-bin \
71111 && java -version \
72112 && ogrinfo --version \
73113 && rm -rf /var/lib/apt/lists/*
@@ -101,27 +141,8 @@ VOLUME /opt/validator-api/var/data
101141
102142USER www-data
103143
144+ ENV APP_ENV=prod
145+
104146EXPOSE 8000
105147CMD ["/opt/validator-api/.docker/application.sh" ]
106148
107- # ----------------------------------------------------------------------
108- # DEV image with xdebug
109- # ----------------------------------------------------------------------
110- FROM base as dev
111-
112- ENV APP_ENV=dev
113-
114- USER root
115- # install xdebug extension for php
116- RUN pear config-set http_proxy ${http_proxy} \
117- && pear config-set php_ini $PHP_INI_DIR/php.ini \
118- && pecl install xdebug \
119- && docker-php-ext-enable xdebug
120- USER www-data
121-
122- # ----------------------------------------------------------------------
123- # Production image without xdebug
124- # ----------------------------------------------------------------------
125- FROM base as prod
126-
127- ENV APP_ENV=prod
0 commit comments