diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..9c6e38f --- /dev/null +++ b/Caddyfile @@ -0,0 +1,10 @@ +:80 { + + root * /usr/share/caddy + file_server + + handle_errors { + rewrite * /{http.error.status_code}.html + file_server + } +} diff --git a/Dockerfile b/Dockerfile index 3d54013..a4a66d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/README.md b/README.md index 85bf7c1..0d5a12a 100644 --- a/README.md +++ b/README.md @@ -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 -``` \ No newline at end of file +cp env.example .env +make && docker-compose up -d +``` + +Le site est disponible sur http://localhost:8888/. diff --git a/rawdog/.gitignore b/config/.gitignore similarity index 100% rename from rawdog/.gitignore rename to config/.gitignore diff --git a/rawdog/config b/config/config similarity index 99% rename from rawdog/config rename to config/config index 2583a9b..4c4ed86 100644 --- a/rawdog/config +++ b/config/config @@ -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 tag in the generated diff --git a/rawdog/item.bl4n b/config/item.bl4n similarity index 100% rename from rawdog/item.bl4n rename to config/item.bl4n diff --git a/rawdog/item.dec23 b/config/item.dec23 similarity index 100% rename from rawdog/item.dec23 rename to config/item.dec23 diff --git a/rawdog/plugins/truncate.py b/config/plugins/truncate.py similarity index 100% rename from rawdog/plugins/truncate.py rename to config/plugins/truncate.py diff --git a/rawdog/template.bl4n b/config/template.bl4n similarity index 100% rename from rawdog/template.bl4n rename to config/template.bl4n diff --git a/rawdog/template.dec23 b/config/template.dec23 similarity index 100% rename from rawdog/template.dec23 rename to config/template.dec23 diff --git a/crontabs b/crontabs new file mode 100644 index 0000000..29deb97 --- /dev/null +++ b/crontabs @@ -0,0 +1 @@ +0 * * * * /opt/rawdog/startup.sh diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c85e940 --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/env.example b/env.example new file mode 100644 index 0000000..d43a310 --- /dev/null +++ b/env.example @@ -0,0 +1 @@ +UTILISATEUR=1000 diff --git a/hourly/launch_rawdog b/hourly/launch_rawdog deleted file mode 100755 index 8cddeb9..0000000 --- a/hourly/launch_rawdog +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -UTILISATEUR=${UTILISATEUR:-1000} - -/opt/rawdog/rawdog -d /root/.rawdog -uw && chown ${UTILISATEUR} /srv/http/veille -R || exit 1 diff --git a/rawdog.service b/rawdog.service deleted file mode 100644 index 55725df..0000000 --- a/rawdog.service +++ /dev/null @@ -1,7 +0,0 @@ -[Unit] -Description=Rawdog - -[Service] -Type=simple -User=od -ExecStart=/usr/bin/rawdog -d /home/od/.rawdog -uw diff --git a/rawdog.timer b/rawdog.timer deleted file mode 100644 index 723d81a..0000000 --- a/rawdog.timer +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Runs rawdog every hour - -[Timer] -OnCalendar=hourly -Persistent=True -Unit=rawdog.service - -[Install] -WantedBy=multi-user.target diff --git a/startup.sh b/startup.sh new file mode 100755 index 0000000..92481a8 --- /dev/null +++ b/startup.sh @@ -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