Version V2023-08-13

This commit is contained in:
Eric Coissac
2023-08-13 23:11:46 +02:00
parent 76ef463775
commit b6d3b1d848
5 changed files with 116 additions and 27 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
Personal_notes.md
README.html
README_files

View File

@@ -4,12 +4,31 @@ WORKDIR /opt
RUN apt-get update && apt-get install -y \
python3-pip \
git \
ffmpeg \
cron \
moreutils \
bsdextrautils \
htop \
vim \
nano \
&& rm -rf /var/lib/apt/lists/*
RUN pip3 install sigal
RUN python3 -m pip install 'sigal @ git+https://github.com/saimn/sigal.git'
COPY run.sh sigal.conf.py auth.conf auth.htpasswd ./
RUN mkdir -p /themes
RUN mkdir -p /config
RUN mkdir -p /plugins/local_plugins
RUN touch /plugins/local_plugins/__init__.py
ENV LANG C.UTF-8
COPY run.sh auth.conf auth.htpasswd ./
ENV JPEG_QUALITY=90
ENV LANG=C.UTF-8
ENV PYTHONPATH="/themes:/plugins:/config"
COPY build_sigal.sh /usr/local/bin/build_sigal
RUN chmod +x /usr/local/bin/build_sigal
CMD ["./run.sh"]

View File

@@ -1,33 +1,65 @@
# docker-sigal
# sigal Docker image
Docker image based on nginx official one for [sigal](http://sigal.saimon.org/en/latest/) gallery.
This project is a fork of the [remche/docker-sigal](https://github.com/remche/docker-sigal) project.
The Docker image, based on nginx official one, includes the code for running a [sigal](http://sigal.saimon.org/en/latest/) gallery website.
Run with :
Default configuration use the galleria theme, keep original and put gallery in /usr/share/nginx/html. You can use a docker volume if you want it permanent
## Exposed volumes
docker run -p 80:80 -v /path/to/your/pictures/:/pictures --name sigal-ct -d remche/docker-sigal
- `/pictures` : Where your data files are stored.
- `/config` : Where you can find and edit the configuration file
- `/themes` : Where you can store external themes
- `/plugins` : Where you can store external plugins
- `/usr/share/nginx/html` : Where the generated HTML code is stored.
Decalring it as a volume allows for making it permanent
docker run command setting all these volumes
```bash
mkdir -p pictures config themes plugins html
docker run -p 8888:80 \
-v ./pictures:/pictures \
-v ./config:/config \
-v ./themes:/themes \
-v ./plugins:/plugins \
-v ./html:/usr/share/nginx/html \
-n sigal-server \
-d zafacs/sigal
```
## Environment variables
- `JPEG_QUALITY`: set the default quality for *JPEG* conversion.
Option to be added to the docker run command :
- `HTPASSWD`: Allows for setting a basic authentication in `htpasswd`.
You might then use SSL with
[nginx-proxy](https://hub.docker.com/r/jwilder/nginx-proxy/).
- `CRONJOB`: Allows to define a `cron` task in the docker container that will
update the website. The value of the CRONJOB variable is a text
constituted of 5 items defining at witch time the update has to be done.
The syntax follows the [crontab syntax](https://tecadmin.net/crontab-in-linux-with-20-examples-of-cron-schedule/)
+ `* * * * *` : The site is updated every minute.
+ `10 * * * *` : The site is updated every hour at the $10^{th}$ minute.
+ `*/15 * * * *` : The site is updated every 15 minutes.
Default configuration use the galleria theme, keep original and put gallery in /usr/share/nginx/html. You can use a docker volume if you want it permanent :
```bash
docker run -p 8888:80 \
-v ./pictures:/pictures \
-v ./config:/config \
-v ./themes:/themes \
-v ./plugins:/plugins \
-v ./html:/usr/share/nginx/html \
-n sigal-server \
-e JPEG_QUALITY=80 \
-e HTPASSWD='foo:$apr1$odHl5EJN$KbxMfo86Qdve2FH4owePn.' \
-e CRONJOB='*/15 * * * *' \
-d zafacs/sigal
```
docker run -p 80:80 -v /path/to/your/pictures/:/pictures -v sigal-html:/usr/share/nginx/html --name sigal-ct -d remche/docker-sigal
You can use the following command to force the regeneration of gallery :
If you want to override this conf, you can use your own sigal.conf.py :
docker run -p 80:80 -v /path/to/your/pictures/:/pictures -v/path/to/your/sigal.conf.py:/opt/sigal.conf.py --name sigal-ct -d remche/docker-sigal
You can set a basic authentication in htpasswd format by setting HTPASSWD env variable :
docker run -p 80:80 -v /path/to/your/pictures/:/pictures -e HTPASSWD='foo:$apr1$odHl5EJN$KbxMfo86Qdve2FH4owePn.' --name sigal-ct -d remche/docker-sigal
You might then use SSL with [nginx-proxy](https://hub.docker.com/r/jwilder/nginx-proxy/).
You can use the following command to regenerate gallery :
docker exec sigal-ct sigal build
Using a cron or incron to run it is a good way to keep your gallery up to date.
```bash
docker exec sigal-ct build_sigal
```

15
build_sigal.sh Normal file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
cd /opt || exit
rm -f ./sigal.conf.py
if [[ -f /config/sigal.conf.py ]] ; then
ln -s /config/sigal.conf.py sigal.conf.py
else
sigal init
fi
/usr/local/bin/sigal build 2>&1 \
| col -b \
| /usr/bin/ts '%Y/%m/%d %H:%M:%S [sigal build]:' \
| tee /proc/1/fd/1

24
run.sh
View File

@@ -1,11 +1,31 @@
#!/bin/bash
if [[ $HTPASSWD ]]
if [[ -n "$HTPASSWD" ]]
then
cp auth.conf /etc/nginx/conf.d/default.conf
envsubst < auth.htpasswd > /etc/nginx/auth.htpasswd
fi
sigal build
if [[ ! -f /config/sigal.conf.py ]] ; then
sed -E 's@#? *source = .*$@source = "/pictures"@' \
"$(find /usr -name sigal.conf.py)" | \
sed -E 's@#? *destination = .*$@destination = "/usr/share/nginx/html"@'| \
sed -E 's@#? *keep_orig = .*$@keep_orig = True@' | \
sed -E 's@#? *zip_gallery = .*$@zip_gallery = "archive.zip"@' | \
sed -E 's@#? *orig_link = .*$@orig_link = True@' | \
sed -E 's@quality: *[0-9]+ *,$@quality: '$JPEG_QUALITY',@' \
> /config/sigal.conf.py
fi
build_sigal
if [[ -n "$CRONJOB" ]]
then
( echo "${CRONJOB} root /usr/local/bin/build_sigal 2>&1 > /dev/null" > /etc/cron.d/sigal \
&& echo "Create sigal build crontab" ) 2>&1 | /usr/bin/ts '%Y/%m/%d %H:%M:%S [cronjob]:'
service cron start 2>&1 | /usr/bin/ts '%Y/%m/%d %H:%M:%S [cronjob]:'
fi
exec nginx -g "daemon off;"