Skip to content

Commit 43fb8e7

Browse files
author
Jon Bendtsen
committed
undo changes to v15
1 parent eaeec86 commit 43fb8e7

3 files changed

Lines changed: 607 additions & 89 deletions

File tree

images/15.0.3-php7.4/Dockerfile

Lines changed: 59 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,31 @@
11
ARG ARCH=
22

3-
# ============================================================
4-
# BUILDER STAGE — compile PHP extensions & fetch Dolibarr
5-
# ============================================================
6-
FROM ${ARCH}php:8.2-apache-bookworm AS builder
3+
# Use a PHP image
4+
# Example: PHP_BASE_IMAGE=x.y-apache-buster
5+
# Example: PHP_BASE_IMAGE=x.y-apache-bullseye
6+
# Note: Version of the PHP image must be a compatible version according to https://wiki.dolibarr.org/index.php?title=Versions
7+
FROM ${ARCH}php:7.4-apache-bullseye
78

8-
RUN apt-get update -y \
9-
&& apt-get dist-upgrade -y \
10-
&& apt-get install -y --no-install-recommends \
11-
libc-client-dev \
12-
libfreetype6-dev \
13-
libjpeg62-turbo-dev \
14-
libkrb5-dev \
15-
libldap2-dev \
16-
libldap-common \
17-
libpng-dev \
18-
libpq-dev \
19-
libxml2-dev \
20-
libzip-dev \
21-
libtidy-dev \
22-
curl \
23-
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
24-
&& docker-php-ext-install -j$(nproc) calendar intl mysqli pdo_mysql gd soap zip opcache tidy \
25-
&& docker-php-ext-configure pgsql -with-pgsql \
26-
&& docker-php-ext-install pdo_pgsql pgsql \
27-
&& docker-php-ext-configure ldap --with-libdir=lib/$(gcc -dumpmachine)/ \
28-
&& docker-php-ext-install -j$(nproc) ldap \
29-
&& docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
30-
&& docker-php-ext-install imap \
31-
&& rm -rf /var/lib/apt/lists/*
32-
33-
# Download Dolibarr
34-
ENV DOLI_VERSION=develop
35-
36-
RUN curl -fLSs https://github.com/Dolibarr/dolibarr/archive/${DOLI_VERSION}.tar.gz | \
37-
tar -C /tmp -xz && \
38-
cp -r /tmp/dolibarr-${DOLI_VERSION}/htdocs/. /var/www/html/ && \
39-
ln -s /var/www/html /var/www/htdocs && \
40-
cp -r /tmp/dolibarr-${DOLI_VERSION}/scripts /var/www/ && \
41-
rm -rf /tmp/dolibarr-${DOLI_VERSION} && \
42-
mkdir -p /var/www/documents && \
43-
mkdir -p /var/www/html/custom && \
44-
chown -R www-data:www-data /var/www
45-
46-
# ============================================================
47-
# RUNTIME STAGE — only what's needed to run Dolibarr
48-
# ============================================================
49-
FROM ${ARCH}php:8.2-apache-bookworm
50-
51-
# Credit/Initial maintainer: Garcia MICHEL
9+
# Credit/Initial maintainer: Garcia MICHEL <garcia@soamichel.fr>
5210
# Modified according to the GPL license by developers of the Dolibarr community:
5311
# 2024 Alois Micard
5412
# 2024 Laurent Destailleur
5513
# 2025 Renato de Castro Ferreira
56-
5714
LABEL maintainer="The Dolibarr foundation <contact@dolibarr.org>"
5815

59-
# ---- All original environment variables preserved ----
60-
ENV DOLI_VERSION=develop
61-
ENV DOLI_VERSION_FOR_INIT_DEMO=23.0
16+
ENV DOLI_VERSION=15.0.3
17+
ENV DOLI_VERSION_FOR_INIT_DEMO=15.0
6218
ENV DOLI_INSTALL_AUTO=1
6319
ENV DOLI_PROD=1
20+
6421
ENV DOLI_DB_TYPE=mysqli
6522
ENV DOLI_DB_HOST=mysql
6623
ENV DOLI_DB_HOST_PORT=3306
6724
ENV DOLI_DB_NAME=dolidb
6825
ENV DOLI_DB_SSL=false
69-
ENV DOLI_URL_ROOT=''
26+
27+
ENV DOLI_URL_ROOT='http://localhost'
28+
7029
ENV DOLI_AUTH=dolibarr
7130
ENV DOLI_LDAP_HOST=127.0.0.1
7231
ENV DOLI_LDAP_PORT=389
@@ -78,67 +37,78 @@ ENV DOLI_LDAP_FILTER=''
7837
ENV DOLI_LDAP_BIND_DN=''
7938
ENV DOLI_LDAP_BIND_PASS=''
8039
ENV DOLI_LDAP_DEBUG=false
40+
8141
ENV DOLI_CRON=0
42+
8243
ENV WWW_USER_ID=33
8344
ENV WWW_GROUP_ID=33
45+
8446
ENV PHP_INI_DATE_TIMEZONE='UTC'
8547
ENV PHP_INI_MEMORY_LIMIT=256M
8648
ENV PHP_INI_UPLOAD_MAX_FILESIZE=20M
8749
ENV PHP_INI_POST_MAX_SIZE=22M
8850
ENV PHP_INI_ALLOW_URL_FOPEN=0
8951

90-
# ---- Install ONLY runtime shared libraries (no -dev, no compilers) ----
9152
RUN apt-get update -y \
9253
&& apt-get dist-upgrade -y \
9354
&& apt-get install -y --no-install-recommends \
94-
libc-client2007e \
95-
libfreetype6 \
96-
libjpeg62-turbo \
97-
libkrb5-3 \
98-
libldap-2.5-0 \
55+
libc-client-dev \
56+
libfreetype6-dev \
57+
libjpeg62-turbo-dev \
58+
libkrb5-dev \
59+
libldap2-dev \
9960
libldap-common \
100-
libpng16-16 \
101-
libpq5 \
102-
libxml2 \
103-
libzip4 \
104-
libtidy5deb1 \
61+
libpng-dev \
62+
libpq-dev \
63+
libxml2-dev \
64+
libzip-dev \
65+
libtidy-dev \
10566
default-mysql-client \
10667
postgresql-client \
68+
vim-tiny \
10769
cron \
108-
&& apt-get remove -y --purge build-essential g++ gcc make binutils cpp \
109-
&& apt-get remove -y --purge dpkg-dev libc6-dev libc-dev-bin libstdc++-12-dev libgcc-12-dev linux-libc-dev \
110-
# 2. Remove Unnecessary Utilities (Safe to remove)
111-
&& apt-get remove -y --purge re2c autoconf m4 xz-utils \
112-
&& apt-get autoremove -y \
70+
&& apt-get autoremove -y
71+
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
72+
&& docker-php-ext-install -j$(nproc) calendar intl mysqli pdo_mysql gd soap zip opcache tidy \
73+
&& docker-php-ext-configure pgsql -with-pgsql \
74+
&& docker-php-ext-install pdo_pgsql pgsql \
75+
&& docker-php-ext-configure ldap --with-libdir=lib/$(gcc -dumpmachine)/ \
76+
&& docker-php-ext-install -j$(nproc) ldap \
77+
&& docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
78+
&& docker-php-ext-install imap \
79+
&& mv ${PHP_INI_DIR}/php.ini-production ${PHP_INI_DIR}/php.ini \
80+
&& sed -i 's/expose_php = On/expose_php = Off/g' ${PHP_INI_DIR}/php.ini \
11381
&& rm -rf /var/lib/apt/lists/*
11482

115-
# ---- Copy compiled PHP extensions + configs from builder ----
116-
COPY --from=builder /usr/local/lib/php/extensions/ /usr/local/lib/php/extensions/
117-
COPY --from=builder /usr/local/etc/php/conf.d/ /usr/local/etc/php/conf.d/
118-
119-
# ---- Production php.ini + hardening (same as upstream) ----
120-
RUN mv ${PHP_INI_DIR}/php.ini-production ${PHP_INI_DIR}/php.ini \
121-
&& sed -i 's/expose_php = On/expose_php = Off/g' ${PHP_INI_DIR}/php.ini
122-
123-
# ---- Apache hardening (same as upstream) ----
83+
# Disable useless Apache modules to provide safe defaults
12484
RUN a2disconf serve-cgi-bin \
12585
&& a2dismod status \
12686
&& a2dismod -f alias \
12787
&& a2dismod -f autoindex \
128-
&& a2enmod rewrite \
12988
&& sed -i \
130-
-e 's/^\(ServerSignature On\)$/#\1/g' \
131-
-e 's/^#\(ServerSignature Off\)$/\1/g' \
132-
-e 's/^\(ServerTokens\) OS$/\1 Prod/g' \
133-
/etc/apache2/conf-available/security.conf
89+
-e 's/^\(ServerSignature On\)$/#\1/g' \
90+
-e 's/^#\(ServerSignature Off\)$/\1/g' \
91+
-e 's/^\(ServerTokens\) OS$/\1 Prod/g' \
92+
/etc/apache2/conf-available/security.conf
13493

135-
# ---- Copy Dolibarr application from builder ----
136-
COPY --from=builder --chown=www-data:www-data /var/www/html /var/www/html
137-
COPY --from=builder --chown=www-data:www-data /var/www/scripts /var/www/scripts
138-
COPY --from=builder --chown=www-data:www-data /var/www/documents /var/www/documents
139-
RUN ln -s /var/www/html /var/www/htdocs
94+
# Get Dolibarr
95+
RUN curl -fLSs https://github.com/Dolibarr/dolibarr/archive/${DOLI_VERSION}.tar.gz |\
96+
tar -C /tmp -xz && \
97+
cp -r /tmp/dolibarr-${DOLI_VERSION}/htdocs/* /var/www/html/ && \
98+
ln -s /var/www/html /var/www/htdocs && \
99+
cp -r /tmp/dolibarr-${DOLI_VERSION}/scripts /var/www/ && \
100+
rm -rf /tmp/* && \
101+
mkdir -p /var/www/documents && \
102+
mkdir -p /var/www/html/custom && \
103+
chown -R www-data:www-data /var/www && \
104+
chmod -R u-w /var/www/html
140105

141106
EXPOSE 80
142-
143107
VOLUME /var/www/documents
144108
VOLUME /var/www/html/custom
109+
110+
COPY docker-init.php /var/www/scripts/
111+
COPY docker-run.sh /usr/local/bin/
112+
ENTRYPOINT ["docker-run.sh"]
113+
114+
CMD ["apache2-foreground"]
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env php
2+
<?php
3+
# This script is called by the docker-run.sh script to enabled modules during Dolibarr first installation.
4+
# It is embedded into the Docker image of dolibarr/dolibarr.
5+
6+
require_once '../htdocs/master.inc.php';
7+
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
8+
9+
printf("Activating module User... ");
10+
activateModule('modUser');
11+
printf("OK\n");
12+
13+
if (!empty(getenv('DOLI_COMPANY_COUNTRYCODE'))) {
14+
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
15+
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
16+
$countryCode = getenv('DOLI_COMPANY_COUNTRYCODE');
17+
$country = new Ccountry($db);
18+
$res = $country->fetch(0,$countryCode);
19+
if ($res > 0 ) {
20+
$s = $country->id.':'.$country->code.':'.$country->label;
21+
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity);
22+
printf('Configuring for country : '.$s."\n");
23+
activateModulesRequiredByCountry($country->code);
24+
} else {
25+
printf('Unable to find country '.$countryCode."\n");
26+
}
27+
}
28+
29+
if (!empty(getenv('DOLI_COMPANY_NAME'))) {
30+
$compname = getenv('DOLI_COMPANY_NAME');
31+
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", $compname, 'chaine', 0, '', $conf->entity);
32+
}
33+
34+
if (!empty(getenv('DOLI_ENABLE_MODULES'))) {
35+
$mods = explode(',', getenv('DOLI_ENABLE_MODULES'));
36+
foreach ($mods as $mod) {
37+
printf("Activating module ".$mod." ...");
38+
try {
39+
$res = activateModule('mod' . $mod);
40+
if ($res < 0) {
41+
print(" FAILED. Unable to load module. Be sure to check the case\n");
42+
} else {
43+
printf(" OK\n");
44+
}
45+
} catch (Throwable $t) {
46+
print(" FAILED. Unable to load module. Be sure to check the case\n");
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)