Skip to content

Commit 4c57e30

Browse files
authored
Merge pull request #73 from IGNF/valitri
Valitri
2 parents 9c4318c + cdea6c4 commit 4c57e30

34 files changed

+6074
-546
lines changed

.docker/Dockerfile

Lines changed: 60 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
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

67
RUN mkdir -p /opt/validator-api
78
WORKDIR /opt/validator-api
89
COPY composer.json .
910
RUN 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

1617
ENV DEBIAN_FRONTEND=noninteractive
17-
ENV LANG fr_FR.UTF-8
18+
ENV LANG=fr_FR.UTF-8
1819
ENV 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
#----------------------------------------------------------------------
3334
RUN 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

62101
RUN a2enmod rewrite remoteip
63102

103+
64104
#----------------------------------------------------------------------
65105
# Setup validator-cli.jar dependencies (java & ogr2ogr)
66106
#----------------------------------------------------------------------
67107
RUN 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

102142
USER www-data
103143

144+
ENV APP_ENV=prod
145+
104146
EXPOSE 8000
105147
CMD ["/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

.docker/apache2-foreground

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Adapted from docker/php removing folders creation at runtime (requires root)
5+
# src : https://github.com/docker-library/php/blob/master/8.3/bullseye/apache/apache2-foreground
6+
7+
: "${APACHE_CONFDIR:=/etc/apache2}"
8+
: "${APACHE_ENVVARS:=$APACHE_CONFDIR/envvars}"
9+
if test -f "$APACHE_ENVVARS"; then
10+
. "$APACHE_ENVVARS"
11+
fi
12+
13+
# Apache gets grumpy about PID files pre-existing
14+
: "${APACHE_RUN_DIR:=/var/run/apache2}"
15+
: "${APACHE_PID_FILE:=$APACHE_RUN_DIR/apache2.pid}"
16+
rm -f "$APACHE_PID_FILE"
17+
18+
# Start apache forwarding SIGINT and SIGTERM to SIGWINCH
19+
APACHE2_PID=""
20+
function stop_apache()
21+
{
22+
if [ ! -z "$APACHE2_PID" ];
23+
then
24+
kill -s WINCH $APACHE2_PID
25+
fi
26+
}
27+
28+
trap stop_apache SIGINT SIGTERM SIGWINCH
29+
30+
apache2 -DFOREGROUND "$@" &
31+
APACHE2_PID=$!
32+
wait $APACHE2_PID

.docker/application.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ backend(){
3838

3939
test(){
4040
export APP_ENV=test
41-
export DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@database:5432/validator_api_test?serverVersion=13&charset=utf8"
41+
export DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@database:5432/validator_api_test?serverVersion=15&charset=utf8"
4242
bin/console --env=test doctrine:database:create --if-not-exists
4343
bin/console --env=test doctrine:schema:update --complete --force
4444
XDEBUG_MODE=coverage vendor/bin/phpunit

.docker/php.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
; config/php.ini
22
date.timezone = Europe/Paris
33

4+
# hide php version
5+
expose_php = off
6+
47
opcache.enable = 1
58
opcache.enable_cli = 1
69
opcache.memory_consumption = 128

.env

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,20 @@ CORS_ALLOW_ORIGIN=*
4444
#
4545
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
4646
# DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/validator-api?serverVersion=5.7"
47-
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/validator_api?serverVersion=13&charset=utf8
47+
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/validator_api?serverVersion=15&charset=utf8
4848
###< doctrine/doctrine-bundle ###
49+
50+
###> league/flysystem
51+
S3_ENDPOINT=https://s3.sbg.io.cloud.ovh.net
52+
S3_ACCESS_KEY=
53+
S3_SECRET_KEY=
54+
S3_BUCKET=dev-ign-mut-validtri
55+
S3_REGION=sbg
56+
57+
### validator-worker/validator-cli postgis
58+
# DB_URL=jdbc:postgresql://${PGHOST}:${PGPORT}/${PGDATABASE}?ssl=true&sslmode=require&sslfactory=org.postgresql.ssl.NonValidatingFactory
59+
DB_URL=jdbc:postgresql://localhost:5432/validator_api
60+
DB_USER=${POSTGRES_USER}
61+
DB_PASSWORD=${POSTGRES_PASSWORD}
62+
# must stay empty
63+
DB_SCHEMA=

.github/workflows/php-ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ jobs:
1414

1515
strategy:
1616
matrix:
17-
php-version: [7.4,8.1]
17+
php-version: [8.3]
1818

1919
runs-on: ubuntu-latest
2020

2121
# see https://docs.github.com/en/actions/using-containerized-services/creating-postgresql-service-containers
2222
services:
2323
postgres:
24-
image: postgres:14
24+
image: postgres:15
2525
env:
2626
POSTGRES_PASSWORD: postgres
2727
options: >-
@@ -65,7 +65,7 @@ jobs:
6565
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/validator_api?serverVersion=14&charset=utf8
6666

6767
- name: Upload coverage results to coveralls.io
68-
if: github.ref == 'refs/heads/master' && matrix.php-version == '8.1'
68+
if: github.ref == 'refs/heads/master' && matrix.php-version == '8.3'
6969
run: |
7070
vendor/bin/php-coveralls --coverage_clover=var/data/output/coverage.xml --json_path=var/data/output/coveralls.json -v
7171
env:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ sonar-scanner
3131
node_modules
3232

3333
/output/
34+
# vscode
35+
*.bkp
3436

3537
###> friendsofphp/php-cs-fixer ###
3638
/.php-cs-fixer.php

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232
"symfony/validator": "5.4.*",
3333
"symfony/yaml": "5.4.*",
3434
"symfony/mime": "5.4.*",
35-
"symfony/runtime": "5.4.*"
35+
"symfony/runtime": "5.4.*",
36+
"league/flysystem-bundle": "^3.3",
37+
"league/flysystem-async-aws-s3": "^3.29",
38+
"league/flysystem-aws-s3-v3": "^3.29"
3639
},
3740
"require-dev": {
3841
"doctrine/doctrine-fixtures-bundle": "^3.4",

config/bundles.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
Liip\TestFixturesBundle\LiipTestFixturesBundle::class => ['dev' => true, 'test' => true],
1414
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
1515
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
16+
League\FlysystemBundle\FlysystemBundle::class => ['all' => true],
1617
];

config/packages/doctrine.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
doctrine:
22
dbal:
33
url: '%env(resolve:DATABASE_URL)%'
4-
54
# IMPORTANT: You MUST configure your server version,
65
# either here or in the DATABASE_URL env var (see .env file)
76
#server_version: '5.7'

0 commit comments

Comments
 (0)