Merge pull request #2 from ShadowJonathan/coffee

Add docker things
This commit is contained in:
Agatha Lovelace 2023-02-08 13:38:34 +01:00 committed by GitHub
commit c210eb6be1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 12 deletions

View File

@ -6,21 +6,19 @@ WORKDIR /ebooks/
VOLUME /ebooks/data/
RUN apk add --virtual .build-deps gcc musl-dev libffi-dev openssl-dev \
&& pip install -r requirements.txt \
&& apk del --purge .build-deps \
&& ln -s data/config.json . \
&& ln -s data/toots.db .
&& pip install -r requirements.txt \
&& apk del --purge .build-deps \
&& apk add bash \
&& ln -s data/config.json . \
&& ln -s data/toots.db .
ADD *.py /ebooks/
ADD entrypoint.sh ./
RUN chmod +x entrypoint.sh
ADD *.py ./
ENV EBOOKS_SITE=https://botsin.space
ENV POST_TIMINGS="*/30 * * * *"
ENV FETCH_TIMINGS="5 */2 * * *"
RUN (echo "${POST_TIMINGS} cd /ebooks/ && python gen.py"; \
echo "${FETCH_TIMINGS} cd /ebooks/ && python main.py"; \
echo "@reboot cd /ebooks/ && python reply.py") | crontab -
CMD (test -f data/config.json || echo "{\"site\":\"${EBOOKS_SITE}\"}" > data/config.json) \
&& (test -f data/toots.db || (python main.py && exit)) \
&& exec crond -f -L /dev/stdout
ENTRYPOINT [ "/ebooks/entrypoint.sh" ]

13
entrypoint.sh Normal file
View File

@ -0,0 +1,13 @@
#!/bin/bash
set -xe
(echo "${POST_TIMINGS} cd /ebooks/ && python gen.py"; \
echo "${FETCH_TIMINGS} cd /ebooks/ && python main.py"; \
echo "@reboot cd /ebooks/ && python reply.py") | crontab -
test -f data/config.json || echo "{\"site\":\"${EBOOKS_SITE}\"}" > data/config.json
test -f data/toots.db || (python main.py && exit)
exec crond -f -L /dev/stdout