Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 10 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ EORUN

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

# Copy entrypoint scripts
# Copy bin scripts
COPY --chmod=0755 bin /usr/local/bin/

# Create cron jobs
# Copy cron jobs
COPY --chown=www-data:www-data --chmod=0755 \
lb-jobs-cron /config/

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

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

# Environment
USER www-data
WORKDIR /
# Customize the image environment
USER www-data:root
VOLUME /config
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["apache2-foreground"]
EXPOSE 8080

# Customize the application environment
RUN bash /usr/local/bin/build_app.sh
29 changes: 29 additions & 0 deletions bin/build_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
# vim: set expandtab ts=2 sw=2 ai :

set -e
set -u
set -o pipefail
trap 'echo "Exit status $? at line $LINENO from: $BASH_COMMAND"' ERR

PS4='+ ${BASH_SOURCE:-}:${FUNCNAME[0]:-}:L${LINENO:-}: '
set -x

if [ -f /var/www/html/composer.json ]; then
sed \
-i /var/www/html/composer.json \
-e "s:\(.*\)nickdnk/graph-sdk\(.*\)7.0\(.*\):\1joelbutcher/facebook-graph-sdk\26.1\3:"
composer install
fi

sed \
-i /var/www/html/database_schema/create-user.sql \
-e "s:^DROP USER ':DROP USER IF EXISTS ':g" \
-e "s:booked_user:schedule_user:g" \
-e "s:localhost:%:g"

if ! [ -d /var/www/html/tpl_c ]; then
mkdir --mode 0775 /var/www/html/tpl_c
fi

mkdir --mode 0775 /var/www/html/Web/uploads/reservation
56 changes: 23 additions & 33 deletions setup.sh → bin/build_sys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ trap 'echo "Exit status $? at line $LINENO from: $BASH_COMMAND"' ERR
PS4='+ ${BASH_SOURCE:-}:${FUNCNAME[0]:-}:L${LINENO:-}: '
set -x

# Install dependencies
apt-get update
apt-get upgrade --yes
apt-get install --yes --no-install-recommends \
Expand All @@ -18,61 +19,50 @@ apt-get install --yes --no-install-recommends \
libfreetype6-dev \
unzip
apt-get clean
rm -rf /var/lib/apt/lists/*

# Customize the http & php environment
cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
# Customize Apache
cat >/etc/apache2/conf-available/remoteip.conf <<EOF
RemoteIPHeader X-Real-IP
RemoteIPInternalProxy 10.0.0.0/8
RemoteIPInternalProxy 172.16.0.0/12
RemoteIPInternalProxy 192.168.0.0/16
EOF

sed \
-i /etc/apache2/ports.conf \
-e 's/Listen 80/Listen 8080/' \
-e 's/Listen 443/Listen 8443/'
sed \
-i /etc/apache2/sites-available/000-default.conf \
-e 's/<VirtualHost \*:80>/<VirtualHost \*:8080>/'

a2enconf remoteip
a2enmod rewrite
a2enmod headers
a2enmod remoteip

# Customize php
cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
touch /usr/local/etc/php/conf.d/librebooking.ini

docker-php-ext-configure gd --with-jpeg --with-freetype
docker-php-ext-install mysqli gd ldap
pecl install timezonedb
docker-php-ext-enable timezonedb
mkdir --parent /var/log/librebooking
chown --recursive www-data:root /var/log/librebooking
chmod --recursive g+rwx /var/log/librebooking
touch /usr/local/etc/php/conf.d/librebooking.ini
sed \
-i /etc/apache2/ports.conf \
-e 's/Listen 80/Listen 8080/' \
-e 's/Listen 443/Listen 8443/'
sed \
-i /etc/apache2/sites-available/000-default.conf \
-e 's/<VirtualHost \*:80>/<VirtualHost \*:8080>/'

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

# Customize permissions
chown www-data:root \
/var/www \
/usr/local/etc/php/conf.d/librebooking.ini
chmod g+rwx \
/var/www \
/usr/local/etc/php/conf.d/librebooking.ini
chown --recursive www-data:root \
/etc/apache2/sites-available \
/var/www/html/tpl_c
/etc/apache2/sites-available
chmod --recursive g+rwx \
/etc/apache2/sites-available \
/var/www/html/tpl_c
/etc/apache2/sites-available