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
3 changes: 2 additions & 1 deletion .config/hadolint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ignored:
- SC3028
- DL3008
- DL3008
- DL3066
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Prerequisite is that you are co-admin of galette docker on docker hub: https://h
7. Select "Read, Write, Delete"
8. Click "Generate"
9. Copy your personal access token (if you don't you have to restart this guide)
10. Go to https://github.com/galette-community/docker/settings/secrets/actions
10. Go to https://github.com/galette/docker/settings/secrets/actions
11. Click New repository secret
12. Name `DOCKERHUB_TOKEN`
13. Secret must be the code you copied from step 9.
Expand Down
158 changes: 81 additions & 77 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ARG PHP_VERSION=8.3
ARG PHP_VERSION=8.5

# Using PHP-Apache image
FROM php:${PHP_VERSION}-apache
ARG PHP_VERSION
ARG GALETTE_VERSION=1.2.1
ARG GALETTE_VERSION=1.3.0
ARG GALETTE_RELEASE=galette-${GALETTE_VERSION}

# Maintained by GrasDK for Galette community
Expand All @@ -13,124 +13,128 @@ LABEL maintainer="GrasDK"


## Plugins versions
ARG PLUGIN_AUTO_VERSION="2.2.1"
ARG PLUGIN_EVENTS_VERSION="2.2.1"
ARG PLUGIN_FULLCARD_VERSION="2.2.1"
ARG PLUGIN_MAPS_VERSION="2.2.1"
ARG PLUGIN_OBJECTSLEND_VERSION="2.2.1"
ARG PLUGIN_PAYPAL_VERSION="2.2.1"
ARG PLUGIN_ACTIVITIES_VERSION="1.1.0"
ARG PLUGIN_AUTO_VERSION="2.3.0"
ARG PLUGIN_EVENTS_VERSION="2.3.0"
ARG PLUGIN_FULLCARD_VERSION="2.3.0"
ARG PLUGIN_MAPS_VERSION="2.3.0"
ARG PLUGIN_OBJECTSLEND_VERSION="2.3.0"
ARG PLUGIN_PAYPAL_VERSION="2.3.0"
ARG PLUGIN_ACTIVITIES_VERSION="1.2.0"

LABEL description="PHP $PHP_VERSION / Apache 2 / $GALETTE_RELEASE"

LABEL org.opencontainers.image.source=https://github.com/galette-community/docker
LABEL org.opencontainers.image.source=https://github.com/galette/docker
LABEL org.opencontainers.image.description="Galette is a membership management web application towards non profit organizations."
LABEL org.opencontainers.image.licenses=GPL-3.0-or-later

ARG MAIN_PACKAGE_URL="https://galette.eu/download/"
ARG PLUGIN_PACKAGE_URL="https://galette.eu/download/plugins/"
#ARG MAIN_PACKAGE_URL="https://download.tuxfamily.org/galette/"
#ARG PLUGIN_PACKAGE_URL="https://download.tuxfamily.org/galette/plugins/"

## Supercronic runs scheduled tasks without root privileges
## https://github.com/aptible/supercronic/releases
ARG SUPERCRONIC_VERSION="v0.2.49"
ARG SUPERCRONIC_SHA1SUM_AMD64="e63c11a9726b775a6a11801e81af4f3fb926aa68"
ARG SUPERCRONIC_SHA1SUM_ARM64="0b6c5bb743e0b0dafed1132198c81807927ac413"
ARG SUPERCRONIC_SHA1SUM_ARM="c98e10fc30de1147bfef8d7f2722f43c0db04fe5"
## Set by buildx for each platform
ARG TARGETARCH

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Install APT dependencies
RUN a2enmod rewrite
RUN apt-get -y update \
&& apt-get install --no-install-recommends -y \
cron \
wget \
libfreetype6-dev \
libicu-dev \
libjpeg62-turbo-dev \
libpng-dev \
libwebp-dev \
libtidy-dev \
libpq-dev \
tzdata \
&& 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 && \
docker-php-ext-install mysqli pdo pdo_mysql && \
# Install, Configure and Enable PHP extensions
## opcache is always built in since PHP 8.5
RUN docker-php-ext-install "-j$(nproc)" gettext intl && \
{ php -m | grep -q "Zend OPcache" || docker-php-ext-install opcache; } && \
docker-php-ext-install mysqli pdo pdo_mysql pdo_pgsql && \
docker-php-ext-enable mysqli && \
docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ --with-webp=/usr/include/ && \
docker-php-ext-install "-j$(nproc)" gd
RUN apachectl restart
docker-php-ext-install "-j$(nproc)" gd

# 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 a2dissite -- * && a2ensite vhost.conf

# ENVIRONMENT VARIABLES
## Galette ENV
ENV GALETTE_CONFIG /var/www/galette/config
ENV GALETTE_DATA /var/www/galette/data
ENV GALETTE_INSTALL /var/www/galette
ENV GALETTE_WEBROOT /var/www/galette/webroot
ENV RM_INSTALL_FOLDER 0
## Galette ENV
ENV GALETTE_CONFIG=/var/www/galette/config
ENV GALETTE_DATA=/var/www/galette/data
ENV GALETTE_INSTALL=/var/www/galette
ENV GALETTE_WEBROOT=/var/www/galette/webroot
ENV RM_INSTALL_FOLDER=0

# Changing DOCUMENT ROOT
RUN mkdir $GALETTE_INSTALL
ENV APACHE_DOCUMENT_ROOT $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 \
&& sed -ri -e "s!/var/www/!${APACHE_DOCUMENT_ROOT}!g" /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf

## Timezone
ENV TZ Europe/Paris
ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# Installation Galette and plugins
# Installation Galette and plugins
# Download, extract and remove archives in a single layer, so they do not remain in the image
## Galette
## bin/console is shipped next to the galette directory, and finds it from its own location
WORKDIR /usr/src
RUN wget --progress=dot:giga ${MAIN_PACKAGE_URL}${GALETTE_RELEASE}.tar.bz2
RUN tar jxvf ${GALETTE_RELEASE}.tar.bz2; mv ${GALETTE_RELEASE}/galette/* ${GALETTE_INSTALL} ; rm ${GALETTE_RELEASE}.tar.bz2
RUN wget -q ${MAIN_PACKAGE_URL}${GALETTE_RELEASE}.tar.bz2 \
&& tar jxf ${GALETTE_RELEASE}.tar.bz2 \
&& mv ${GALETTE_RELEASE}/galette/* ${GALETTE_INSTALL} \
&& mv ${GALETTE_RELEASE}/bin /var/www/bin \
&& rm -rf ${GALETTE_RELEASE} ${GALETTE_RELEASE}.tar.bz2

## Official plugins
## 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 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 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 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 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 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

### Activities
RUN wget --progress=dot:giga ${PLUGIN_PACKAGE_URL}galette-plugin-activities-${PLUGIN_ACTIVITIES_VERSION}.tar.bz2
RUN tar jxvf galette-plugin-activities-${PLUGIN_ACTIVITIES_VERSION}.tar.bz2; rm galette-plugin-activities-${PLUGIN_ACTIVITIES_VERSION}.tar.bz2; mv galette-plugin-activities-${PLUGIN_ACTIVITIES_VERSION} plugin-activities


# 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
## Apply cron job
# Create the log file to be able to run tail
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"]

# Chown /var/www/galette
RUN for plugin in \
auto:${PLUGIN_AUTO_VERSION} \
events:${PLUGIN_EVENTS_VERSION} \
fullcard:${PLUGIN_FULLCARD_VERSION} \
maps:${PLUGIN_MAPS_VERSION} \
objectslend:${PLUGIN_OBJECTSLEND_VERSION} \
paypal:${PLUGIN_PAYPAL_VERSION} \
activities:${PLUGIN_ACTIVITIES_VERSION} \
; do \
name="${plugin%%:*}"; version="${plugin##*:}"; \
archive="galette-plugin-${name}-${version}"; \
wget -q "${PLUGIN_PACKAGE_URL}${archive}.tar.bz2" \
&& tar jxf "${archive}.tar.bz2" \
&& rm "${archive}.tar.bz2" \
&& mv "${archive}" "plugin-${name}" \
|| exit 1; \
done


# CRON (reminders and mailing queue)
## Run by supercronic from the entrypoint, as www-data; output goes to the container logs
RUN case "${TARGETARCH}" in \
amd64) sum="${SUPERCRONIC_SHA1SUM_AMD64}" ;; \
arm64) sum="${SUPERCRONIC_SHA1SUM_ARM64}" ;; \
arm) sum="${SUPERCRONIC_SHA1SUM_ARM}" ;; \
*) echo "Unsupported architecture: ${TARGETARCH}"; exit 1 ;; \
esac \
&& wget -q -O /usr/local/bin/supercronic \
"https://github.com/aptible/supercronic/releases/download/${SUPERCRONIC_VERSION}/supercronic-linux-${TARGETARCH}" \
&& echo "${sum} /usr/local/bin/supercronic" | sha1sum -c - \
&& chmod +x /usr/local/bin/supercronic
COPY galette-cron /etc/galette-cron

# Chown /var/www/galette
RUN chown -R www-data:www-data $GALETTE_INSTALL \
&& chmod -R 0755 $GALETTE_DATA

Expand Down
42 changes: 34 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,55 @@ Current repository hosts sources of the [Galette docker image](https://hub.docke
If you want to contribute to containerized galette, take a look [here](./CONTRIBUTING.md).

## Features
* integrated plugins : [events](https://github.com/galette/plugin-events), [fullcard](https://github.com/galette/plugin-fullcard), [maps](https://github.com/galette/plugin-maps), [objectslend](https://github.com/galette/plugin-objectslend) and [paypal](https://github.com/galette/plugin-paypal)
* integrated plugins : [activities](https://github.com/galette-plugins/plugin-activities), [auto](https://github.com/galette-plugins/plugin-auto), [events](https://github.com/galette-plugins/plugin-events), [fullcard](https://github.com/galette-plugins/plugin-fullcard), [maps](https://github.com/galette-plugins/plugin-maps), [objectslend](https://github.com/galette-plugins/plugin-objectslend) and [paypal](https://github.com/galette-plugins/plugin-paypal)
* MySQL/MariaDB and PostgreSQL support
* mount volume to keep persistent database settings (*config.inc.php*)
* keep data (images, logs, etc) persistent by mounting volumes
* enabling Log IP addresses behind a proxy (*optional*)
* customize your CSS (volume)
* user www-data instead of root
* a crontab will run `reminder.php` (with user www-data) every day at 8:30am to send reminder mail
* Apache and cron jobs run as www-data
* scheduled tasks send reminders every day at 8:30am, and drain the mailing queue every 15 minutes (see [Scheduled tasks](#scheduled-tasks))
* Galette command line, see [Command line](#command-line)
* only webroot is exposed via Apache DocumentRoot and vhost
* you can use reverse proxy to access Galette by domain or subdomain

## Prerequisites
This docker image has no included database, so you need to have that separately. Since you probably already are running docker, take a look [here](https://mariadb.com/kb/en/installing-and-using-mariadb-via-docker/#creating-a-container) for a guide on how to run MariaDB in a container.

**Important!**: Following the instructions instructions for Galette versions earlier than 1.1.0 will **not** work, due to differences in volumes. If you are using a Galette version earlier than 1.1.0, please follow [the earlier version of these instructions](https://github.com/galette-community/docker/blob/1.0.4/README.md#how-to-use-this-image-using-docker-command-line). Instructions for version 1.0.4 should work for all ealier versions, but if you run into trouble with those, you can follow [version-specific instructions](https://github.com/galette-community/docker/tags).
**Important!**: Following the instructions instructions for Galette versions earlier than 1.1.0 will **not** work, due to differences in volumes. If you are using a Galette version earlier than 1.1.0, please follow [the earlier version of these instructions](https://github.com/galette/docker/blob/1.0.4/README.md#how-to-use-this-image-using-docker-command-line). Instructions for version 1.0.4 should work for all ealier versions, but if you run into trouble with those, you can follow [version-specific instructions](https://github.com/galette/docker/tags).

## How to use this image using docker command line

Galette has a really nice installer, that runs you through database setup and initial admin user creation. The installer creates a configuration file in the `config` folder, which you should keep on a volume outside the docker image, for reuse when you upgrade to a newer version. You also have the option to create files for advanced configuration in the same `config` folder (see step 6).

Therefore it is really important that you follow this guide exactly.

> [!IMPORTANT]
> Owner is the `www-data` user of the base image. UID is `33` on Debian; you can check using `docker run --rm --entrypoint id galette/galette:1.3.0 www-data`

If you are upgrading from an earlier version, you can skip step 1, 2 and 4 below.

1. Create folders corresponding to all the volumes in the next step.
1. Create folders corresponding to all the volumes in the next step, and give them to `www-data` (uid and gid 33), which runs Apache and the console in the container; otherwise Galette cannot write its configuration file nor its data.
```
sudo chown -R 33:33 /path/to/config /path/to/data
```
2. Optional: Create a file `config.inc.php` in the `config` folder. You can also copy [this](.example/config/config.inc.php) and alter it to suit your configuration. You can put in your database details up front, or wait until step 4.
3. Start a container with the version of galette you want (e.g. V1.1.0) and the proper list of volumes.
3. Start a container with the version of galette you want (e.g. 1.3.0) and the proper list of volumes.
```
docker run -d -p 8080:80 --name galette \
-v /path/to/config:/var/www/galette/config \
-v /path/to/data/attachments:/var/www/galette/data/attachments \
-v /path/to/data/cache:/var/www/galette/data/cache \
-v /path/to/data/documents:/var/www/galette/data/documents \
-v /path/to/data/exports:/var/www/galette/data/exports \
-v /path/to/data/files:/var/www/galette/data/files \
-v /path/to/data/imports:/var/www/galette/data/imports \
-v /path/to/data/plugins:/var/www/galette/data/plugins \
-v /path/to/data/logs:/var/www/galette/data/logs \
-v /path/to/data/photos:/var/www/galette/data/photos \
-v /path/to/data/tempimages:/var/www/galette/data/tempimages \
-v /path/to/data/templates_c:/var/www/galette/data/templates_c \
galette/galette:1.1.0
galette/galette:1.3.0
```
Remember to replace `./path/to/` with your own path.

Expand Down Expand Up @@ -81,10 +93,24 @@ If you are upgrading from an earlier version, you can skip step 1, 2 and 4 below
### Configure plugins
From the main page of galette, click the plugin icon and manage the built-in modules. You can disable/enable them an initialize their database configuration from the UI.

### Scheduled tasks
The image runs two scheduled tasks as www-data, using [supercronic](https://github.com/aptible/supercronic); their output goes to the container logs (`docker logs galette`):
- `cron/reminder.php`, every day at 8:30am, sends membership reminders;
- `cron/mailing_queue.php`, every 15 minutes, sends queued mass mailings and reminders when hourly or daily sending limits are set (new in Galette 1.3.0).

Both need the public address of your instance, since they have no incoming request to guess it from: set `pref_galette_url` from **Configuration > Advanced configuration** in Galette. Until then, each run logs a message asking for it.

### Command line
Galette console is available in the container, run it as www-data:

docker exec -u www-data galette php /var/www/bin/console list

For example, `galette:install` can replace the web installer, and `galette:plugins:install-db` initializes plugins database.

## How to use this image using Docker Compose
1. Copy [`docker-compose/galette/docker-compose.yml`](docker-compose/galette/docker-compose.yml) and [`docker-compose/galette/.env`](docker-compose/galette/.env) to the folder, where you want to persist your configuration.
2. Optionally edit the values in `.env`
3. Create a `config` folder and optionally add a `config.inc.php` file to that folder. You can copy the one from [here](.example/config/config.inc.php) and adjust it.
3. Create a `config` folder and optionally add a `config.inc.php` file to that folder. You can copy the one from [here](.example/config/config.inc.php) and adjust it. Create the `data` folders as well, and give both to `www-data` (uid and gid 33), as Docker would otherwise create missing folders as root: `sudo chown -R 33:33 ./galette/config ./galette/data` (adapt to `GALETTE_DATA_DIR`).
4. Launch with `docker-compose up -d`
5. Go to http://localhost:8080/installer.php and complete installation (database, etc).
- Note that http://localhost:8080 will report a failure, but adding /installer will work.
Expand Down
2 changes: 1 addition & 1 deletion docker-compose/galette-and-mariadb/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GALETTE_VERSION=1.1.4
GALETTE_VERSION=1.3.0
GALETTE_DATA_DIR=./galette
MARIADB_VERSION="10.11"
MARIADB_HOST_DATA_DIR="./mariadb"
Expand Down
5 changes: 3 additions & 2 deletions docker-compose/galette-and-mariadb/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.7'

services:
mariadb:
image: mariadb:${MARIADB_VERSION}
Expand Down Expand Up @@ -29,7 +27,10 @@ services:
volumes:
- ${GALETTE_DATA_DIR}/data/attachments:/var/www/galette/data/attachments
- ${GALETTE_DATA_DIR}/data/cache:/var/www/galette/data/cache
- ${GALETTE_DATA_DIR}/data/documents:/var/www/galette/data/documents
- ${GALETTE_DATA_DIR}/data/exports:/var/www/galette/data/exports
- ${GALETTE_DATA_DIR}/data/files:/var/www/galette/data/files
- ${GALETTE_DATA_DIR}/data/imports:/var/www/galette/data/imports
- ${GALETTE_DATA_DIR}/data/plugins:/var/www/galette/data/plugins
- ${GALETTE_DATA_DIR}/data/logs:/var/www/galette/data/logs
- ${GALETTE_DATA_DIR}/data/photos:/var/www/galette/data/photos
Expand Down
2 changes: 1 addition & 1 deletion docker-compose/galette/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
GALETTE_VERSION=1.1.4
GALETTE_VERSION=1.3.0
GALETTE_DATA_DIR=./galette
5 changes: 3 additions & 2 deletions docker-compose/galette/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.7'

services:
galette:
image: galette/galette:${GALETTE_VERSION}
Expand All @@ -15,7 +13,10 @@ services:
volumes:
- ${GALETTE_DATA_DIR}/data/attachments:/var/www/galette/data/attachments
- ${GALETTE_DATA_DIR}/data/cache:/var/www/galette/data/cache
- ${GALETTE_DATA_DIR}/data/documents:/var/www/galette/data/documents
- ${GALETTE_DATA_DIR}/data/exports:/var/www/galette/data/exports
- ${GALETTE_DATA_DIR}/data/files:/var/www/galette/data/files
- ${GALETTE_DATA_DIR}/data/imports:/var/www/galette/data/imports
- ${GALETTE_DATA_DIR}/data/plugins:/var/www/galette/data/plugins
- ${GALETTE_DATA_DIR}/data/logs:/var/www/galette/data/logs
- ${GALETTE_DATA_DIR}/data/photos:/var/www/galette/data/photos
Expand Down
6 changes: 3 additions & 3 deletions galette-cron
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
30 8 * * * www-data /usr/local/bin/php -f /var/www/galette/cron/reminder.php >> /var/log/cron.log 2>&1
# An empty line is required at the end of this file for a valid cron file.

# Run by supercronic, as www-data
30 8 * * * /usr/local/bin/php -f /var/www/galette/cron/reminder.php
*/15 * * * * /usr/local/bin/php -f /var/www/galette/cron/mailing_queue.php
Loading
Loading