diff --git a/Dockerfile b/Dockerfile index 2737b0b..3fbad93 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,27 @@ ARG VERSION_PHP=8.3 ARG VERSION_COMPOSER=lts +ARG VERSION_GIT=2.52.0 FROM composer:${VERSION_COMPOSER} AS comp -FROM php:${VERSION_PHP}-apache +# Get upstream +FROM alpine/git:${VERSION_GIT} AS upstream +ARG APP_GH_ADD_SHA=false +ARG APP_GH_REF=refs/heads/develop +ARG GIT_TREE=${APP_GH_REF##*/} +ARG UPSTREAM_URL="https://github.com/librebooking/librebooking" +WORKDIR /upstream +RUN < config/custom-version.txt +fi +rm -rf .git +EORUN + +FROM php:${VERSION_PHP}-apache # Labels LABEL org.opencontainers.image.title="LibreBooking" LABEL org.opencontainers.image.description="LibreBooking as a container" @@ -13,27 +31,24 @@ LABEL org.opencontainers.image.licenses="GPL-3.0" LABEL org.opencontainers.image.authors="colisee@hotmail.com" # Copy entrypoint scripts -COPY --chmod=755 bin /usr/local/bin/ +COPY --chmod=0755 bin /usr/local/bin/ # Create cron jobs -COPY --chown=www-data:www-data --chmod=0755 lb-jobs-cron /config/ +COPY --chown=www-data:www-data --chmod=0755 \ + lb-jobs-cron /config/ # Copy composer COPY --from=comp /usr/bin/composer /usr/bin/composer +# Copy Librebooking +COPY --from=upstream \ + --chown=www-data:root --chmod=0775 \ + /upstream/ /var/www/html/ + # Update and install required debian packages ENV DEBIAN_FRONTEND=noninteractive -ARG APP_GH_REF -ARG APP_GH_ADD_SHA=false -# hadolint ignore=DL3008 # 'Pin versions in apt get install' -COPY setup.sh /usr/local/bin/setup.sh -RUN <//' -set -xeuo pipefail -LB_TARBALL_URL="https://api.github.com/repos/LibreBooking/librebooking/tarball/${APP_GH_REF}" -curl \ - --fail \ - --silent \ - --location "${LB_TARBALL_URL}" | - tar --extract --gzip --directory=/var/www/html --strip-components=1 -if [ "${APP_GH_ADD_SHA}" = "true" ]; then - LB_SHORT_SHA="" - # TARBALL_FILENAME will be like the result of a `git describe` For - # example: 'LibreBooking-librebooking-v4.1.0-126-g6cc8a4c.tar.gz' where - # 'g6cc8a4c' is the short SHA prefixed with 'g'. So the short SHA is - # '6cc8a4c' - TARBALL_FILENAME=$( - curl \ - --head \ - --fail \ - --silent \ - --show-error \ - --location "${LB_TARBALL_URL}" | - sed -nE 's/.*filename="?([^";]+)"?.*/\1/p' - ) - LB_SHORT_SHA=$(echo "${TARBALL_FILENAME}" | sed -E 's/.*-g([0-9a-f]+)\.tar\.gz/\1/') - if [ -n "${LB_SHORT_SHA}" ]; then - printf '%s\n' "${LB_SHORT_SHA}" >/var/www/html/config/version-suffix.txt - else - echo "ERROR determining the LB_SHORT_SHA value from TARBALL_FILENAME ${TARBALL_FILENAME}" >&2 - exit 1 - fi -fi if [ -f /var/www/html/composer.json ]; then sed \ -i /var/www/html/composer.json \ @@ -96,19 +65,17 @@ if ! [ -d /var/www/html/tpl_c ]; then fi mkdir /var/www/html/Web/uploads/reservation -chown www-data:root \ +chown --recursive www-data:root \ /var/www/html/config \ + /var/www/html/plugins \ /var/www/html/tpl_c \ /var/www/html/Web/uploads/images \ /var/www/html/Web/uploads/reservation \ /usr/local/etc/php/conf.d/librebooking.ini -chmod g+rwx \ +chmod --recursive g+rwx \ /var/www/html/config \ + /var/www/html/plugins \ /var/www/html/tpl_c \ /var/www/html/Web/uploads/images \ /var/www/html/Web/uploads/reservation \ /usr/local/etc/php/conf.d/librebooking.ini -chown --recursive www-data:root \ - /var/www/html/plugins -chmod --recursive g+rwx \ - /var/www/html/plugins