Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valitri #73

Merged
merged 32 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
76405df
s3 adaptation
DD-Arras Nov 21, 2024
73fafe2
build: validtri 0.1
DD-Arras Nov 22, 2024
a8df716
build: validtri s3 bucket
DD-Arras Nov 22, 2024
99c775f
Merge branch 'master' into valitri
DD-Arras Nov 22, 2024
a6e44dc
fix: composer.json
DD-Arras Nov 22, 2024
9227f28
fix: db name from env
DD-Arras Nov 26, 2024
5816ee5
fix: typo in doctrine config
DD-Arras Nov 26, 2024
1b7425e
fix: typo in doctrine config
DD-Arras Nov 26, 2024
c252f5b
test: add health checks
DD-Arras Nov 29, 2024
47498d3
fix(debug): correction de quelques problèmes validtri
mborne Nov 29, 2024
431f296
fix(health): namespace
mborne Nov 29, 2024
2a425ee
dev(Validation): fix des liens d'acces au fichier s3/local
cboucheIGN Nov 29, 2024
9ca0c6d
feat: update api-client to 0.4.4 with new covadis di model
cboucheIGN Nov 29, 2024
f2f215b
feat: ajout parametres du PLUGIN dgpr dans la liste des arguments dis…
cboucheIGN Dec 1, 2024
2ae9efc
feat: mise a jour validator-api-client v0.4.5
cboucheIGN Dec 1, 2024
28476eb
fix: clean normedZip from worker
DD-Arras Dec 2, 2024
2b89c1b
fix: remove validation directory
DD-Arras Dec 2, 2024
6c0e8bd
fix: make storage dirs
DD-Arras Dec 2, 2024
7ab2bdb
fix(test): fix some test and skip failing ones (S3, download,...)
mborne Dec 2, 2024
a6993c9
fix(validtri): change upload paths
DD-Arras Dec 2, 2024
8ca00cb
fix(validtri): change routes to refer to dataStorage
DD-Arras Dec 2, 2024
1457dfa
Merge branch 'valitri' of gh_work:IGNF/validator-api into valitri
DD-Arras Dec 2, 2024
3b7c240
chore(docker): fix env params for JDBC
mborne Dec 2, 2024
c9e42d6
fix(composer): specific version for flysystem-async-aws-s3
mborne Dec 2, 2024
139a8a4
chore(docker): remove useless packages...
mborne Dec 2, 2024
fd61344
feat: mise a jour validator-api-client v0.4.6
cboucheIGN Dec 2, 2024
09813ca
chore(docker): rebase on ubuntu:24.04
mborne Dec 2, 2024
34815ce
fix(docker): download validator-cli.jar
mborne Dec 2, 2024
722fbf1
Merge pull request #75 from IGNF/validtri-docker-ubuntu
cboucheIGN Dec 2, 2024
d39b684
feat: mise a jour validator-api-client v0.4.6
cboucheIGN Dec 2, 2024
90bfe98
Merge pull request #74 from IGNF/validator-client-0.4.6
cboucheIGN Dec 2, 2024
cdea6c4
test: mark for skipped
cboucheIGN Dec 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 60 additions & 39 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
#----------------------------------------------------------------------
# Download vendor from composer.json in dedicated layer
#----------------------------------------------------------------------
FROM composer:2.6 as vendor
ARG registry=docker.io
FROM ${registry}/library/composer:latest AS vendor

RUN mkdir -p /opt/validator-api
WORKDIR /opt/validator-api
COPY composer.json .
RUN composer install --no-scripts --prefer-dist --ignore-platform-req=ext-pcntl

#----------------------------------------------------------------------
# Create base layer for dev and production
# Create application container
#----------------------------------------------------------------------
FROM php:8.2-apache as base
FROM ${registry}/library/ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive
ENV LANG fr_FR.UTF-8
ENV LANG=fr_FR.UTF-8
ENV VALIDATOR_PATH=/opt/ign-validator/validator-cli.jar

#----------------------------------------------------------------------
# Configure locale to fr_FR.UTF-8
# see also https://stackoverflow.com/a/41797247
#----------------------------------------------------------------------
RUN apt-get update && apt-get install -y locales \
RUN apt-get update && apt-get install --no-install-recommends -y locales \
&& sed -i -e 's/# en_US.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/' /etc/locale.gen \
&& dpkg-reconfigure locales \
&& update-locale LANG=fr_FR.UTF-8 \
Expand All @@ -31,26 +32,64 @@ RUN apt-get update && apt-get install -y locales \
# Install common tools
#----------------------------------------------------------------------
RUN apt-get update \
&& apt-get install -y \
unzip \
make \
&& apt-get install --no-install-recommends -y \
unzip zip \
curl wget \
zip \
file \
postgresql-client \
&& rm -rf /var/lib/apt/lists/*


#------------------------------------------------------------------------
# Configure https://packages.sury.org/php/ to get latests PHP versions
#------------------------------------------------------------------------
RUN apt-get update \
&& apt-get install --no-install-recommends -y gnupg2 software-properties-common \
&& add-apt-repository -y ppa:ondrej/php \
&& apt-get remove -y software-properties-common \
&& rm -rf /var/lib/apt/lists/*

#----------------------------------------------------------------------
# Configure PHP
# Install Apache, PHP and its extensions
# TODO : php8.3-pcntl ?
#----------------------------------------------------------------------
COPY .docker/php.ini /usr/local/etc/php/conf.d/app.ini
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
apache2 php8.3 libapache2-mod-php8.3 \
php8.3-opcache php8.3-xml \
php8.3-pdo php8.3-pgsql php8.3-zip \
&& rm -rf /var/lib/apt/lists/*

#------------------------------------------------------------------------
# Add helper script to start apache
# (see https://github.com/docker-library/php)
#------------------------------------------------------------------------
COPY .docker/apache2-foreground /usr/local/bin/apache2-foreground
RUN chmod +x /usr/local/bin/apache2-foreground

#------------------------------------------------------------------------
# Create apache2 repository
# (see https://github.com/docker-library/php)
#------------------------------------------------------------------------
RUN mkdir -p /var/run/apache2 && chown -R www-data:www-data /var/run/apache2 \
&& mkdir -p /var/lock/apache2 && chown -R www-data:www-data /var/lock/apache2 \
&& mkdir -p /var/log/apache2 && chown -R www-data:www-data /var/log/apache2

#------------------------------------------------------------------------
# Redirects logs to stdout / stderr
# (see https://github.com/docker-library/php)
#------------------------------------------------------------------------
RUN ln -sfT /dev/stderr "/var/log/apache2/error.log" \
&& ln -sfT /dev/stdout "/var/log/apache2/access.log" \
&& ln -sfT /dev/stdout "/var/log/apache2/other_vhosts_access.log" \
&& chown www-data:www-data /var/log/apache2/*.log


#----------------------------------------------------------------------
# Install PHP extensions
# Configure PHP
#----------------------------------------------------------------------
RUN apt-get update -qq \
&& apt-get install -y postgresql-client libpq-dev libzip-dev \
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
&& docker-php-ext-install opcache pdo pdo_pgsql pgsql zip pcntl \
&& rm -rf /var/lib/apt/lists/*
COPY .docker/php.ini /etc/php/8.3/apache2/php.ini
# TODO .docker/php.ini /etc/php/8.3/cli/php.ini

#----------------------------------------------------------------------
# Configure apache
Expand All @@ -61,13 +100,14 @@ COPY .docker/apache-vhost.conf /etc/apache2/sites-available/000-default.conf

RUN a2enmod rewrite remoteip


#----------------------------------------------------------------------
# Setup validator-cli.jar dependencies (java & ogr2ogr)
#----------------------------------------------------------------------
RUN apt-get update -qq \
# see https://github.com/debuerreotype/docker-debian-artifacts/issues/24
&& mkdir -p /usr/share/man/man1 \
&& apt-get install -y openjdk-17-jdk-headless gdal-bin \
&& apt-get install --no-install-recommends -y openjdk-17-jdk-headless gdal-bin \
&& java -version \
&& ogrinfo --version \
&& rm -rf /var/lib/apt/lists/*
Expand Down Expand Up @@ -101,27 +141,8 @@ VOLUME /opt/validator-api/var/data

USER www-data

ENV APP_ENV=prod

EXPOSE 8000
CMD ["/opt/validator-api/.docker/application.sh"]

#----------------------------------------------------------------------
# DEV image with xdebug
#----------------------------------------------------------------------
FROM base as dev

ENV APP_ENV=dev

USER root
# install xdebug extension for php
RUN pear config-set http_proxy ${http_proxy} \
&& pear config-set php_ini $PHP_INI_DIR/php.ini \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug
USER www-data

#----------------------------------------------------------------------
# Production image without xdebug
#----------------------------------------------------------------------
FROM base as prod

ENV APP_ENV=prod
32 changes: 32 additions & 0 deletions .docker/apache2-foreground
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -e

# Adapted from docker/php removing folders creation at runtime (requires root)
# src : https://github.com/docker-library/php/blob/master/8.3/bullseye/apache/apache2-foreground

: "${APACHE_CONFDIR:=/etc/apache2}"
: "${APACHE_ENVVARS:=$APACHE_CONFDIR/envvars}"
if test -f "$APACHE_ENVVARS"; then
. "$APACHE_ENVVARS"
fi

# Apache gets grumpy about PID files pre-existing
: "${APACHE_RUN_DIR:=/var/run/apache2}"
: "${APACHE_PID_FILE:=$APACHE_RUN_DIR/apache2.pid}"
rm -f "$APACHE_PID_FILE"

# Start apache forwarding SIGINT and SIGTERM to SIGWINCH
APACHE2_PID=""
function stop_apache()
{
if [ ! -z "$APACHE2_PID" ];
then
kill -s WINCH $APACHE2_PID
fi
}

trap stop_apache SIGINT SIGTERM SIGWINCH

apache2 -DFOREGROUND "$@" &
APACHE2_PID=$!
wait $APACHE2_PID
2 changes: 1 addition & 1 deletion .docker/application.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ backend(){

test(){
export APP_ENV=test
export DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@database:5432/validator_api_test?serverVersion=13&charset=utf8"
export DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@database:5432/validator_api_test?serverVersion=15&charset=utf8"
bin/console --env=test doctrine:database:create --if-not-exists
bin/console --env=test doctrine:schema:update --complete --force
XDEBUG_MODE=coverage vendor/bin/phpunit
Expand Down
3 changes: 3 additions & 0 deletions .docker/php.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
; config/php.ini
date.timezone = Europe/Paris

# hide php version
expose_php = off

opcache.enable = 1
opcache.enable_cli = 1
opcache.memory_consumption = 128
Expand Down
17 changes: 16 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,20 @@ CORS_ALLOW_ORIGIN=*
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://db_user:[email protected]:3306/validator-api?serverVersion=5.7"
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/validator_api?serverVersion=13&charset=utf8
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/validator_api?serverVersion=15&charset=utf8
###< doctrine/doctrine-bundle ###

###> league/flysystem
S3_ENDPOINT=https://s3.sbg.io.cloud.ovh.net
S3_ACCESS_KEY=
S3_SECRET_KEY=
S3_BUCKET=dev-ign-mut-validtri
S3_REGION=sbg

### validator-worker/validator-cli postgis
# DB_URL=jdbc:postgresql://${PGHOST}:${PGPORT}/${PGDATABASE}?ssl=true&sslmode=require&sslfactory=org.postgresql.ssl.NonValidatingFactory
DB_URL=jdbc:postgresql://localhost:5432/validator_api
DB_USER=${POSTGRES_USER}
DB_PASSWORD=${POSTGRES_PASSWORD}
# must stay empty
DB_SCHEMA=
6 changes: 3 additions & 3 deletions .github/workflows/php-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:

strategy:
matrix:
php-version: [7.4,8.1]
php-version: [8.3]

runs-on: ubuntu-latest

# see https://docs.github.com/en/actions/using-containerized-services/creating-postgresql-service-containers
services:
postgres:
image: postgres:14
image: postgres:15
env:
POSTGRES_PASSWORD: postgres
options: >-
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/validator_api?serverVersion=14&charset=utf8

- name: Upload coverage results to coveralls.io
if: github.ref == 'refs/heads/master' && matrix.php-version == '8.1'
if: github.ref == 'refs/heads/master' && matrix.php-version == '8.3'
run: |
vendor/bin/php-coveralls --coverage_clover=var/data/output/coverage.xml --json_path=var/data/output/coveralls.json -v
env:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ sonar-scanner
node_modules

/output/
# vscode
*.bkp

###> friendsofphp/php-cs-fixer ###
/.php-cs-fixer.php
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
"symfony/validator": "5.4.*",
"symfony/yaml": "5.4.*",
"symfony/mime": "5.4.*",
"symfony/runtime": "5.4.*"
"symfony/runtime": "5.4.*",
"league/flysystem-bundle": "^3.3",
"league/flysystem-async-aws-s3": "^3.29",
"league/flysystem-aws-s3-v3": "^3.29"
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.4",
Expand Down
1 change: 1 addition & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
Liip\TestFixturesBundle\LiipTestFixturesBundle::class => ['dev' => true, 'test' => true],
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
League\FlysystemBundle\FlysystemBundle::class => ['all' => true],
];
1 change: 0 additions & 1 deletion config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'

# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '5.7'
Expand Down
24 changes: 24 additions & 0 deletions config/packages/flysystem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Author : Mborne

services:
s3_client:
class: 'AsyncAws\S3\S3Client'
arguments:
- endpoint: '%env(S3_ENDPOINT)%'
accessKeyId: '%env(S3_ACCESS_KEY)%'
accessKeySecret: '%env(S3_SECRET_KEY)%'
region: '%env(S3_REGION)%'
# required for minio (avoids access to {bucket}.minio-s3.dev.localhost)
pathStyleEndpoint: true

flysystem:
storages:
default.storage:
adapter: 'local'
options:
directory: '%kernel.project_dir%/var/data'
data.storage:
adapter: 'asyncaws'
options:
client: 's3_client'
bucket: '%env(S3_BUCKET)%'
62 changes: 62 additions & 0 deletions config/packages/monolog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
monolog:
channels:
- deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists

when@dev:
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: ["!event"]
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine", "!console"]

when@test:
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_http_codes: [404, 405]
channels: ["!event"]
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug

when@prod:
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_http_codes: [404, 405]
buffer_size: 50 # How many messages should be saved? Prevent memory leaks
nested:
type: stream
path: php://stderr
level: debug
formatter: monolog.formatter.json
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine"]
deprecation:
type: stream
channels: [deprecation]
path: php://stderr
formatter: monolog.formatter.json
15 changes: 15 additions & 0 deletions config/packages/web_profiler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
when@dev:
web_profiler:
toolbar: true
intercept_redirects: false

framework:
profiler: { only_exceptions: false }

when@test:
web_profiler:
toolbar: false
intercept_redirects: false

framework:
profiler: { collect: false }
Loading
Loading