Skip to content

Commit 57155e3

Browse files
coliseeRobin Alexander
andauthored
Prepare version 3.3.3 (#196)
* Split image build setup between root and www-data actions * Fix selinux issues brought with Dockerfile RUN --mount statement --------- Co-authored-by: Robin Alexander <colisee@hotmail>
1 parent 918dcab commit 57155e3

3 files changed

Lines changed: 62 additions & 43 deletions

File tree

Dockerfile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ EORUN
2323

2424
# Build supercronic
2525
FROM golang:trixie AS supercronic
26-
ADD https://github.com/aptible/supercronic.git#v0.2.44 src
26+
ADD https://github.com/aptible/supercronic.git#v0.2.44 /go/src/
2727
WORKDIR /go/src
2828
RUN <<EORUN
2929
set -eux
@@ -40,10 +40,10 @@ LABEL org.opencontainers.image.source="https://github.com/librebooking/docker"
4040
LABEL org.opencontainers.image.licenses="GPL-3.0"
4141
LABEL org.opencontainers.image.authors="colisee@hotmail.com"
4242

43-
# Copy entrypoint scripts
43+
# Copy bin scripts
4444
COPY --chmod=0755 bin /usr/local/bin/
4545

46-
# Create cron jobs
46+
# Copy cron jobs
4747
COPY --chown=www-data:www-data --chmod=0755 \
4848
lb-jobs-cron /config/
4949

@@ -59,16 +59,16 @@ COPY --from=upstream \
5959
--chown=www-data:root --chmod=0775 \
6060
/upstream/ /var/www/html/
6161

62-
# Update and install required debian packages
62+
# Customize the system environment
6363
ENV DEBIAN_FRONTEND=noninteractive
64-
RUN --mount=type=bind,source=setup.sh,target=/tmp/setup.sh <<EORUN
65-
bash /tmp/setup.sh
66-
EORUN
64+
RUN bash /usr/local/bin/build_sys.sh
6765

68-
# Environment
69-
USER www-data
70-
WORKDIR /
66+
# Customize the image environment
67+
USER www-data:root
7168
VOLUME /config
7269
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
7370
CMD ["apache2-foreground"]
7471
EXPOSE 8080
72+
73+
# Customize the application environment
74+
RUN bash /usr/local/bin/build_app.sh

bin/build_app.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
# vim: set expandtab ts=2 sw=2 ai :
3+
4+
set -e
5+
set -u
6+
set -o pipefail
7+
trap 'echo "Exit status $? at line $LINENO from: $BASH_COMMAND"' ERR
8+
9+
PS4='+ ${BASH_SOURCE:-}:${FUNCNAME[0]:-}:L${LINENO:-}: '
10+
set -x
11+
12+
if [ -f /var/www/html/composer.json ]; then
13+
sed \
14+
-i /var/www/html/composer.json \
15+
-e "s:\(.*\)nickdnk/graph-sdk\(.*\)7.0\(.*\):\1joelbutcher/facebook-graph-sdk\26.1\3:"
16+
composer install
17+
fi
18+
19+
sed \
20+
-i /var/www/html/database_schema/create-user.sql \
21+
-e "s:^DROP USER ':DROP USER IF EXISTS ':g" \
22+
-e "s:booked_user:schedule_user:g" \
23+
-e "s:localhost:%:g"
24+
25+
if ! [ -d /var/www/html/tpl_c ]; then
26+
mkdir --mode 0775 /var/www/html/tpl_c
27+
fi
28+
29+
mkdir --mode 0775 /var/www/html/Web/uploads/reservation

setup.sh renamed to bin/build_sys.sh

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ trap 'echo "Exit status $? at line $LINENO from: $BASH_COMMAND"' ERR
99
PS4='+ ${BASH_SOURCE:-}:${FUNCNAME[0]:-}:L${LINENO:-}: '
1010
set -x
1111

12+
# Install dependencies
1213
apt-get update
1314
apt-get upgrade --yes
1415
apt-get install --yes --no-install-recommends \
@@ -18,61 +19,50 @@ apt-get install --yes --no-install-recommends \
1819
libfreetype6-dev \
1920
unzip
2021
apt-get clean
21-
rm -rf /var/lib/apt/lists/*
2222

23-
# Customize the http & php environment
24-
cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
23+
# Customize Apache
2524
cat >/etc/apache2/conf-available/remoteip.conf <<EOF
2625
RemoteIPHeader X-Real-IP
2726
RemoteIPInternalProxy 10.0.0.0/8
2827
RemoteIPInternalProxy 172.16.0.0/12
2928
RemoteIPInternalProxy 192.168.0.0/16
3029
EOF
30+
31+
sed \
32+
-i /etc/apache2/ports.conf \
33+
-e 's/Listen 80/Listen 8080/' \
34+
-e 's/Listen 443/Listen 8443/'
35+
sed \
36+
-i /etc/apache2/sites-available/000-default.conf \
37+
-e 's/<VirtualHost \*:80>/<VirtualHost \*:8080>/'
38+
3139
a2enconf remoteip
3240
a2enmod rewrite
3341
a2enmod headers
3442
a2enmod remoteip
43+
44+
# Customize php
45+
cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
46+
touch /usr/local/etc/php/conf.d/librebooking.ini
47+
3548
docker-php-ext-configure gd --with-jpeg --with-freetype
3649
docker-php-ext-install mysqli gd ldap
3750
pecl install timezonedb
3851
docker-php-ext-enable timezonedb
39-
mkdir --parent /var/log/librebooking
40-
chown --recursive www-data:root /var/log/librebooking
41-
chmod --recursive g+rwx /var/log/librebooking
42-
touch /usr/local/etc/php/conf.d/librebooking.ini
43-
sed \
44-
-i /etc/apache2/ports.conf \
45-
-e 's/Listen 80/Listen 8080/' \
46-
-e 's/Listen 443/Listen 8443/'
47-
sed \
48-
-i /etc/apache2/sites-available/000-default.conf \
49-
-e 's/<VirtualHost \*:80>/<VirtualHost \*:8080>/'
5052

51-
if [ -f /var/www/html/composer.json ]; then
52-
sed \
53-
-i /var/www/html/composer.json \
54-
-e "s:\(.*\)nickdnk/graph-sdk\(.*\)7.0\(.*\):\1joelbutcher/facebook-graph-sdk\26.1\3:"
55-
composer install
56-
fi
57-
sed \
58-
-i /var/www/html/database_schema/create-user.sql \
59-
-e "s:^DROP USER ':DROP USER IF EXISTS ':g" \
60-
-e "s:booked_user:schedule_user:g" \
61-
-e "s:localhost:%:g"
62-
if ! [ -d /var/www/html/tpl_c ]; then
63-
mkdir /var/www/html/tpl_c
64-
fi
65-
mkdir /var/www/html/Web/uploads/reservation
53+
# Customize log
54+
mkdir --parent /var/log/librebooking
55+
chown www-data:root /var/log/librebooking
56+
chmod g+rwx /var/log/librebooking
6657

58+
# Customize permissions
6759
chown www-data:root \
6860
/var/www \
6961
/usr/local/etc/php/conf.d/librebooking.ini
7062
chmod g+rwx \
7163
/var/www \
7264
/usr/local/etc/php/conf.d/librebooking.ini
7365
chown --recursive www-data:root \
74-
/etc/apache2/sites-available \
75-
/var/www/html/tpl_c
66+
/etc/apache2/sites-available
7667
chmod --recursive g+rwx \
77-
/etc/apache2/sites-available \
78-
/var/www/html/tpl_c
68+
/etc/apache2/sites-available

0 commit comments

Comments
 (0)