From 2f7e3fd3f1361cfb4ed92b39d4960212cb8ea060 Mon Sep 17 00:00:00 2001 From: grasdk Date: Tue, 23 Apr 2024 00:37:18 +0200 Subject: [PATCH 1/5] Bumped version number --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3722bab..966ddb3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Using PHP-Apache image FROM php:8.1-apache -ARG galetteversion="1.0.0" +ARG galetteversion="1.0.1" ARG phpversion="8.1" # Maintained by GrasDK for Galette community From 9ff97c296a1a37ec2cdaa94192fc386539de873c Mon Sep 17 00:00:00 2001 From: grasdk Date: Tue, 23 Apr 2024 11:46:59 +0200 Subject: [PATCH 2/5] added instructions for linting and fixed Dockerfile linting messages --- .config/hadolint.yml | 2 + CONTRIBUTING.md | 22 +++++++-- Dockerfile | 113 ++++++++++++++++++++++--------------------- 3 files changed, 78 insertions(+), 59 deletions(-) create mode 100644 .config/hadolint.yml diff --git a/.config/hadolint.yml b/.config/hadolint.yml new file mode 100644 index 0000000..202bf50 --- /dev/null +++ b/.config/hadolint.yml @@ -0,0 +1,2 @@ +ignored: + - SC3028 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 05e6e65..fe811a2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,22 @@ # Galette Docker project +Building and maintaining this project is solely about the containerization of the finished Galette packages. If you want to contribute to Galette itself, take a look [here](https://galette.eu/site/contribute/). + +## Prerequisites +- `docker` is installed in your development environment. +- `dockerd` the docker deamon is installed (and [started](https://docs.docker.com/config/daemon/start/)) +- `buildx` is installed in your development environment. + +Although it's possible to build packages without `dockerd` running, using [`buildah`](https://buildah.io/), the focus here is on [`buildx`](https://docs.docker.com/reference/cli/docker/buildx/). You're welcome to contribute with instructions for `buildah`. + +## Linting +1. Start the docker daemon if it's not already started: `sudo dockerd` +2. Run hadolint (containerized): `docker run --rm -i -v ./.config/hadolint.yml:/.config/hadolint.yaml hadolint/hadolint < Dockerfile` +3. Fix errors and warnings or add them to ignore list of the [hadolint configuration file](./.config/hadolint.yml) if there is a good reason for that. Read more [here](https://github.com/hadolint/hadolint). ## Building the docker image locally -[comment]: <> (From https://www.techrepublic.com/article/how-to-build-a-docker-image-and-upload-it-to-docker-hub/) -* Start the docker daemon if it's not already started: `sudo dockerd` -* Run the build command: `docker buildx build -t galette-local .` +1. Start the docker daemon if it's not already started: `sudo dockerd` +2. Run the build command: `docker buildx build -t galette-local .` + * replace `galette-local` with any name you would like to give your local image + +## Running the docker image locally +1. Follow the same steps as in [How to use this image](./README.md#How-to-use-this-image), replacing the image name `galette/galette:latest` with your local container name, e.g. `galette-local`. diff --git a/Dockerfile b/Dockerfile index 966ddb3..4f153e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,20 @@ # Using PHP-Apache image FROM php:8.1-apache -ARG galetteversion="1.0.1" -ARG phpversion="8.1" - # Maintained by GrasDK for Galette community LABEL maintainer="GrasDK" # @author Hiob " # @author GrasDK +LABEL phpversion="8.1" +ARG galetteversion="1.0.1" +## Plugins versions +ARG plugin_auto_version="2.0.0" +ARG plugin_events_version="2.0.0" +ARG plugin_fullcard_version="2.0.0" +ARG plugin_maps_version="2.0.0" +ARG plugin_objectslend_version="2.0.0" +ARG plugin_paypal_version="2.0.0" LABEL version=$galetteversion LABEL description="PHP $phpversion / Apache 2 / Galette $galetteversion" @@ -24,41 +30,36 @@ ARG plugin_package_url="https://galette.eu/download/plugins/" # Install APT dependencies RUN a2enmod rewrite -RUN apt-get -y update && apt-get install -y \ - cron \ - wget \ - libfreetype6-dev \ - libicu-dev \ - libjpeg62-turbo-dev \ - libpng-dev \ - libtidy-dev \ - tzdata +RUN apt-get -y update \ + && apt-get install --no-install-recommends -y \ + cron=3.0pl1-162 \ + wget=1.21.3-1+b2 \ + libfreetype6-dev=2.12.1+dfsg-5 \ + libicu-dev=72.1-3 \ + libjpeg62-turbo-dev=1:2.1.5-2 \ + libpng-dev=1.6.39-2 \ + libtidy-dev=2:5.6.0-11 \ + tzdata=2024a-0+deb12u1 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* # Install, Configure and Enable PHP extensions -RUN docker-php-ext-install -j$(nproc) tidy gettext intl && \ +RUN docker-php-ext-install "-j$(nproc)" tidy gettext intl && \ docker-php-ext-install mysqli pdo pdo_mysql && \ docker-php-ext-enable mysqli && \ docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ && \ - docker-php-ext-install -j$(nproc) gd + docker-php-ext-install "-j$(nproc)" gd RUN apachectl restart # Enabling apache vhost COPY vhost.conf /etc/apache2/sites-available/vhost.conf -RUN sed -i 's/galette.localhost/galette.${HOSTNAME}/' /etc/apache2/sites-available/vhost.conf \ - && a2dissite * && a2ensite vhost.conf +RUN sed -i "s/galette.localhost/galette.${HOSTNAME}/" /etc/apache2/sites-available/vhost.conf \ + && a2dissite -- * && a2ensite vhost.conf # ENVIRONMENT VARIABLES ## Galette version ENV GALETTE_VERSION=$galetteversion -## Plugins versions -ENV PLUGIN_AUTO 2.0.0 -ENV PLUGIN_EVENTS 2.0.0 -ENV PLUGIN_FULLCARD 2.0.0 -ENV PLUGIN_MAPS 2.0.0 -ENV PLUGIN_OBJECTSLEND 2.0.0 -ENV PLUGIN_PAYPAL 2.0.0 - ## Galette ENV ENV GALETTE_CONFIG /var/www/galette/config ENV GALETTE_DATA /var/www/galette/data @@ -70,62 +71,62 @@ ENV RM_INSTALL_FOLDER 0 RUN mkdir $GALETTE_INSTALL ENV APACHE_DOCUMENT_ROOT $GALETTE_INSTALL -RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf -RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf +RUN sed -ri -e "s!/var/www/html!${APACHE_DOCUMENT_ROOT}!g" /etc/apache2/sites-available/*.conf \ + && sed -ri -e "s!/var/www/!${APACHE_DOCUMENT_ROOT}!g" /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf ## Timezone ENV TZ Europe/Paris RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone -# Installation Galette + Plugins +# Installation Galette and plugins ## Galette -RUN cd /usr/src; wget ${main_package_url}galette-${GALETTE_VERSION}.tar.bz2 -RUN cd /usr/src; tar jxvf galette-${GALETTE_VERSION}.tar.bz2; mv galette-${GALETTE_VERSION}/galette/* ${GALETTE_INSTALL} ; rm galette-${GALETTE_VERSION}.tar.bz2 +WORKDIR /usr/src +RUN wget --progress=dot:giga ${main_package_url}galette-${GALETTE_VERSION}.tar.bz2 +RUN tar jxvf galette-${GALETTE_VERSION}.tar.bz2; mv galette-${GALETTE_VERSION}/galette/* ${GALETTE_INSTALL} ; rm galette-${GALETTE_VERSION}.tar.bz2 -# Install official plugins -## Auto -RUN cd ${GALETTE_INSTALL}/plugins; wget ${plugin_package_url}galette-plugin-auto-${PLUGIN_AUTO}.tar.bz2 -RUN cd ${GALETTE_INSTALL}/plugins; tar jxvf galette-plugin-auto-${PLUGIN_AUTO}.tar.bz2; rm galette-plugin-auto-${PLUGIN_AUTO}.tar.bz2; mv galette-plugin-auto-${PLUGIN_AUTO} plugin-auto +## Official plugins +WORKDIR ${GALETTE_INSTALL}/plugins +### Auto +RUN wget --progress=dot:giga ${plugin_package_url}galette-plugin-auto-${plugin_auto_version}.tar.bz2 +RUN tar jxvf galette-plugin-auto-${plugin_auto_version}.tar.bz2; rm galette-plugin-auto-${plugin_auto_version}.tar.bz2; mv galette-plugin-auto-${plugin_auto_version} plugin-auto -## Events -RUN cd ${GALETTE_INSTALL}/plugins; wget ${plugin_package_url}galette-plugin-events-${PLUGIN_EVENTS}.tar.bz2 -RUN cd ${GALETTE_INSTALL}/plugins; tar jxvf galette-plugin-events-${PLUGIN_EVENTS}.tar.bz2; rm galette-plugin-events-${PLUGIN_EVENTS}.tar.bz2; mv galette-plugin-events-${PLUGIN_EVENTS} plugin-events +### Events +RUN wget --progress=dot:giga ${plugin_package_url}galette-plugin-events-${plugin_events_version}.tar.bz2 +RUN tar jxvf galette-plugin-events-${plugin_events_version}.tar.bz2; rm galette-plugin-events-${plugin_events_version}.tar.bz2; mv galette-plugin-events-${plugin_events_version} plugin-events -## FullCard -RUN cd ${GALETTE_INSTALL}/plugins; wget ${plugin_package_url}galette-plugin-fullcard-${PLUGIN_FULLCARD}.tar.bz2 -RUN cd ${GALETTE_INSTALL}/plugins; tar jxvf galette-plugin-fullcard-${PLUGIN_FULLCARD}.tar.bz2; rm galette-plugin-fullcard-${PLUGIN_FULLCARD}.tar.bz2; mv galette-plugin-fullcard-${PLUGIN_FULLCARD} plugin-fullcard +### FullCard +RUN wget --progress=dot:giga ${plugin_package_url}galette-plugin-fullcard-${plugin_fullcard_version}.tar.bz2 +RUN tar jxvf galette-plugin-fullcard-${plugin_fullcard_version}.tar.bz2; rm galette-plugin-fullcard-${plugin_fullcard_version}.tar.bz2; mv galette-plugin-fullcard-${plugin_fullcard_version} plugin-fullcard -## Maps -RUN cd ${GALETTE_INSTALL}/plugins; wget ${plugin_package_url}galette-plugin-maps-${PLUGIN_MAPS}.tar.bz2 -RUN cd ${GALETTE_INSTALL}/plugins; tar jxvf galette-plugin-maps-${PLUGIN_MAPS}.tar.bz2; rm galette-plugin-maps-${PLUGIN_MAPS}.tar.bz2; mv galette-plugin-maps-${PLUGIN_MAPS} plugin-maps +### Maps +RUN wget --progress=dot:giga ${plugin_package_url}galette-plugin-maps-${plugin_maps_version}.tar.bz2 +RUN tar jxvf galette-plugin-maps-${plugin_maps_version}.tar.bz2; rm galette-plugin-maps-${plugin_maps_version}.tar.bz2; mv galette-plugin-maps-${plugin_maps_version} plugin-maps -## ObjectsLend -RUN cd ${GALETTE_INSTALL}/plugins; wget ${plugin_package_url}galette-plugin-objectslend-${PLUGIN_OBJECTSLEND}.tar.bz2 -RUN cd ${GALETTE_INSTALL}/plugins; tar jxvf galette-plugin-objectslend-${PLUGIN_OBJECTSLEND}.tar.bz2; rm galette-plugin-objectslend-${PLUGIN_OBJECTSLEND}.tar.bz2; mv galette-plugin-objectslend-${PLUGIN_OBJECTSLEND} plugin-objectslend +### ObjectsLend +RUN wget --progress=dot:giga ${plugin_package_url}galette-plugin-objectslend-${plugin_objectslend_version}.tar.bz2 +RUN tar jxvf galette-plugin-objectslend-${plugin_objectslend_version}.tar.bz2; rm galette-plugin-objectslend-${plugin_objectslend_version}.tar.bz2; mv galette-plugin-objectslend-${plugin_objectslend_version} plugin-objectslend -## Paypal -RUN cd ${GALETTE_INSTALL}/plugins; wget ${plugin_package_url}galette-plugin-paypal-${PLUGIN_PAYPAL}.tar.bz2 -RUN cd ${GALETTE_INSTALL}/plugins; tar jxvf galette-plugin-paypal-${PLUGIN_PAYPAL}.tar.bz2; rm galette-plugin-paypal-${PLUGIN_PAYPAL}.tar.bz2; mv galette-plugin-paypal-${PLUGIN_PAYPAL} plugin-paypal +### Paypal +RUN wget --progress=dot:giga ${plugin_package_url}galette-plugin-paypal-${plugin_paypal_version}.tar.bz2 +RUN tar jxvf galette-plugin-paypal-${plugin_paypal_version}.tar.bz2; rm galette-plugin-paypal-${plugin_paypal_version}.tar.bz2; mv galette-plugin-paypal-${plugin_paypal_version} plugin-paypal # CRON Auto-Reminder ## Copy galette-cron file to the cron.d directory COPY galette-cron /etc/cron.d/galette-cron ## Give execution rights on the cron job -RUN chmod 0644 /etc/cron.d/galette-cron - ## Apply cron job -RUN crontab -u www-data /etc/cron.d/galette-cron - # Create the log file to be able to run tail -RUN touch /var/log/cron.log +RUN chmod 0644 /etc/cron.d/galette-cron \ + && crontab -u www-data /etc/cron.d/galette-cron \ + && touch /var/log/cron.log # Run the command on container startup -CMD cron && tail -f /var/log/cron.log +CMD ["cron", "tail -f /var/log/cron.log"] # Chown /var/www/galette -RUN chown -R www-data:www-data $GALETTE_INSTALL -RUN chmod -R 0755 $GALETTE_DATA +RUN chown -R www-data:www-data $GALETTE_INSTALL \ + && chmod -R 0755 $GALETTE_DATA # Mount volumes VOLUME $GALETTE_DATA From fa313cb6ee808ffac7cbc03a19ca2ba2aad8ad24 Mon Sep 17 00:00:00 2001 From: grasdk Date: Tue, 23 Apr 2024 21:57:03 +0200 Subject: [PATCH 3/5] added github action for hadolint --- .github/workflows/dockerfile-hadolint.yml | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/dockerfile-hadolint.yml diff --git a/.github/workflows/dockerfile-hadolint.yml b/.github/workflows/dockerfile-hadolint.yml new file mode 100644 index 0000000..d155d99 --- /dev/null +++ b/.github/workflows/dockerfile-hadolint.yml @@ -0,0 +1,25 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# GitHub recommends pinning actions to a commit SHA. +# To get a newer version, you will need to update the SHA. +# You can also reference a tag or branch, but the action may change without warning. + +name: Lint Dockerfile + +on: + push: + branches: + - '**' +jobs: + dockerfile_linting: + name: Dockerfile linting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: hadolint/hadolint-action@v3.1.0 + with: + dockerfile: ./Dockerfile + config: ./.config/hadolint.yml From ee51e6d75758813887d9a4accde5c8bf6846d111 Mon Sep 17 00:00:00 2001 From: grasdk Date: Tue, 23 Apr 2024 21:59:44 +0200 Subject: [PATCH 4/5] changed ignored hadolint problem to test the github action --- .config/hadolint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/hadolint.yml b/.config/hadolint.yml index 202bf50..e4896fe 100644 --- a/.config/hadolint.yml +++ b/.config/hadolint.yml @@ -1,2 +1,2 @@ ignored: - - SC3028 + - SC3029 From c5ebf72cd38dde43da0e925750fc9a19dc599c2a Mon Sep 17 00:00:00 2001 From: grasdk Date: Tue, 23 Apr 2024 22:00:37 +0200 Subject: [PATCH 5/5] test completed with success, reverting change --- .config/hadolint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/hadolint.yml b/.config/hadolint.yml index e4896fe..202bf50 100644 --- a/.config/hadolint.yml +++ b/.config/hadolint.yml @@ -1,2 +1,2 @@ ignored: - - SC3029 + - SC3028