feat(Compose): Passage à Docker Compose et simplification Docker

master
Olivier DOSSMANN 2022-10-07 18:12:10 +02:00
parent c583cbf108
commit 329b069872
17 changed files with 61 additions and 62 deletions

10
Caddyfile 100644
View File

@ -0,0 +1,10 @@
:80 {
root * /usr/share/caddy
file_server
handle_errors {
rewrite * /{http.error.status_code}.html
file_server
}
}

View File

@ -5,22 +5,21 @@ COPY 1.patch 2.patch /opt/
# Récupération de Rawdog
RUN apk update \
&& apk add --no-cache git patch \
&& mkdir /opt/rawdog \
&& git clone https://github.com/echarlie/rawdog-py3.git /opt/rawdog \
&& cd /opt/rawdog \
&& mkdir -p /opt/rawdog/bin \
&& git clone https://github.com/echarlie/rawdog-py3.git /opt/rawdog/bin \
&& cd /opt/rawdog/bin \
&& mv /opt/1.patch . \
&& mv /opt/2.patch . \
&& patch -p1 -i 1.patch \
&& patch -p1 -i 2.patch \
&& pip install --no-cache-dir feedparser \
&& python3 setup.py install \
&& mkdir -p /srv/http/veille
&& python3 setup.py install
COPY public/ /srv/http/veille/
COPY . /opt/rawdog
COPY ./crontabs /etc/crontabs/root
WORKDIR /opt/rawdog
VOLUME /srv/http/veille
VOLUME /root/.rawdog
VOLUME /etc/periodic/hourly
ENTRYPOINT ["crond", "-f", "-l", "8"]
VOLUME /opt/rawdog/public
ENTRYPOINT ["/opt/rawdog/startup.sh"]

View File

@ -6,36 +6,16 @@ C'est un système simple utilisant [Rawdog](https://offog.org/code/rawdog/) pour
Il se lance toutes les heures pour générer - si besoin - une page.
# Installation
# Dépendances
## Dépendances
* Docker
* Docker Compose
* [rawdog](https://archlinux.org/packages/community/any/rawdog/) pour ArchLinux
## Dossiers à créér/installer
* copier le **contenu du dossier `rawdog`** dans **/home/od/.rawdog/**
* copier le **contenu du dossier `public`** dans **/srv/http/ogre/veille/**
* copier les fichiers `rawdog.service` et `rawdog.timer` dans **/etc/systemd/system/**
* configurer le fichier **/home/od/.rawdog/config** pour adapter la ligne suivante :
```python
outputfile /srv/http/ogre/veille/index.html
```
avec l'adresse exacte où vous avez posé les fichiers du dossier *public*.
# En bref
# Utilisation
```bash
rsync -avP ./rawdog/* /home/od/.rawdog
mkdir /srv/http/ogre/veille -p
rsync -avP ./public/* /srv/http/ogre/veille/
sudo cp rawdog.service /etc/systemd/system/
sudo cp rawdog.timer /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable rawdog.timer
sudo systemctl start rawdog.service
```
cp env.example .env
make && docker-compose up -d
```
Le site est disponible sur http://localhost:8888/.

View File

@ -147,7 +147,7 @@ feeditemtemplate default
# directory. Specify this as "-" to write the HTML to stdout.
# (You will probably want to make this an absolute path, else rawdog will write
# to a file in your ~/.rawdog directory.)
outputfile /srv/http/veille/index.html
outputfile /opt/rawdog/public/index.html
#outputfile /home/you/public_html/rawdog.html
# Whether to use a <meta http-equiv="Refresh" ...> tag in the generated

1
crontabs 100644
View File

@ -0,0 +1 @@
0 * * * * /opt/rawdog/startup.sh

25
docker-compose.yml 100644
View File

@ -0,0 +1,25 @@
version: "3"
services:
generator:
image: rawdog:0.1
volumes:
- ${PWD}/public:/opt/rawdog/public:rw
cron:
image: rawdog:0.1
restart: always
entrypoint: /usr/sbin/crond
command: ["-f", "-l", "8"]
volumes:
- ${PWD}/public:/opt/rawdog/public:rw
environment:
- UTILISATEUR
web:
image: caddy:2-alpine
restart: always
volumes:
- ${PWD}/public:/usr/share/caddy:ro
- ${PWD}/Caddyfile:/etc/caddy/Caddyfile
ports:
- 8888:80

1
env.example 100644
View File

@ -0,0 +1 @@
UTILISATEUR=1000

View File

@ -1,5 +0,0 @@
#!/bin/sh
UTILISATEUR=${UTILISATEUR:-1000}
/opt/rawdog/rawdog -d /root/.rawdog -uw && chown ${UTILISATEUR} /srv/http/veille -R || exit 1

View File

@ -1,7 +0,0 @@
[Unit]
Description=Rawdog
[Service]
Type=simple
User=od
ExecStart=/usr/bin/rawdog -d /home/od/.rawdog -uw

View File

@ -1,10 +0,0 @@
[Unit]
Description=Runs rawdog every hour
[Timer]
OnCalendar=hourly
Persistent=True
Unit=rawdog.service
[Install]
WantedBy=multi-user.target

5
startup.sh 100755
View File

@ -0,0 +1,5 @@
#!/bin/sh
UTILISATEUR=${UTILISATEUR:-1000}
/opt/rawdog/bin/rawdog -d /opt/rawdog/config -uw && chown ${UTILISATEUR} /opt/rawdog/public -R || exit 1