-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
executable file
·145 lines (122 loc) · 6.07 KB
/
Dockerfile
File metadata and controls
executable file
·145 lines (122 loc) · 6.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#----------------------------------------------------------------------
# Download vendor from composer.json in dedicated layer
#----------------------------------------------------------------------
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 application container
#----------------------------------------------------------------------
FROM ${registry}/library/ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive
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 --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 \
&& rm -rf /var/lib/apt/lists/*
#----------------------------------------------------------------------
# Install common tools
#----------------------------------------------------------------------
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
unzip zip \
curl wget \
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/*
#----------------------------------------------------------------------
# Install Apache, PHP and its extensions
#----------------------------------------------------------------------
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
apache2 php8.4 libapache2-mod-php8.4 \
php8.4-opcache php8.4-xml \
php8.4-pdo php8.4-pgsql php8.4-zip \
php8.4-curl \
&& 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
#----------------------------------------------------------------------
# Configure PHP
#----------------------------------------------------------------------
COPY .docker/php.ini /etc/php/8.4/apache2/conf.d/99-app.ini
COPY .docker/php.ini /etc/php/8.4/cli/conf.d/99-app.ini
#----------------------------------------------------------------------
# Configure apache
#----------------------------------------------------------------------
COPY .docker/apache-ports.conf /etc/apache2/ports.conf
COPY .docker/apache-security.conf /etc/apache2/conf-enabled/security.conf
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 --no-install-recommends -y openjdk-17-jdk-headless gdal-bin \
&& java -version \
&& ogrinfo --version \
&& rm -rf /var/lib/apt/lists/*
#----------------------------------------------------------------------
# Setup /opt/ign-validator/validator-cli.jar
#----------------------------------------------------------------------
ARG validator_version=4.4.18
RUN mkdir -p /opt/ign-validator \
&& wget --quiet -O ${VALIDATOR_PATH} https://github.com/IGNF/validator/releases/download/v${validator_version}/validator-cli.jar \
&& echo "validator-cli.jar version : $(java -jar /opt/ign-validator/validator-cli.jar version)"
#----------------------------------------------------------------------
# Install validator-api
#----------------------------------------------------------------------
COPY . /opt/validator-api
WORKDIR /opt/validator-api
COPY --from=vendor /opt/validator-api/vendor vendor
#----------------------------------------------------------------------
# Prepare data storage
# (Note that /opt/validator-api/var/data is shared between containers)
#----------------------------------------------------------------------
RUN mkdir -p /opt/validator-api/var/data/validations \
&& chown -R www-data:www-data /opt/validator-api/var
# ensure ogr2ogr can write in $HOME/.gdal ...
ENV HOME=/opt/validator-api/var
VOLUME /opt/validator-api/var/data
USER www-data
ENV APP_ENV=prod
EXPOSE 8000
CMD ["/opt/validator-api/.docker/application.sh"]