docker version

This commit is contained in:
virus 2021-01-29 14:26:55 +01:00
parent db150f9a81
commit a81fe87664
25 changed files with 165 additions and 0 deletions

30
Dockerfile Normal file
View File

@ -0,0 +1,30 @@
FROM node:10-alpine
RUN apk add --no-cache \
python2 \
make \
g++
RUN mkdir /app
COPY ./app /app
RUN cd /app && \
npm i
COPY ./init.sh /
RUN chmod +x /init.sh
COPY ./init-update.sh /
RUN chmod +x /init-update.sh
COPY ./feed-cron /etc/periodic/15min/
RUN chmod +x /etc/periodic/15min/feed-cron
WORKDIR /app
CMD ["/init.sh"]

View File

62
docker-compose.yml Normal file
View File

@ -0,0 +1,62 @@
version: '3'
services:
app:
restart: unless-stopped
image: rss-to-activity-pub
environment:
- DOMAIN=rss.fediwersum.pl
labels:
traefik.enable: "true"
# traefik.http.routers.rss-to-activity-pub-conv.entrypoints: websecure
# traefik.http.routers.rss-to-activity-pub-conv.rule: (Host(`rss.fediwersum.pl`) && PathPrefix(`/convert`))
# traefik.http.routers.rss-to-activity-pub-conv.middlewares: rss-to-activity-pub-auth
# traefik.http.routers.rss-to-activity-pub-conv.tls.certresolver: le
# traefik.http.middlewares.rss-to-activity-pub-auth.basicauth.users: some:user
traefik.http.routers.rss-to-activity-pub.entrypoints: websecure
traefik.http.routers.rss-to-activity-pub.rule: Host(`rss.fediwersum.pl`)
traefik.http.routers.rss-to-activity-pub.tls.certresolver: le
traefik.http.services.rss-to-activity-pub.loadbalancer.server.port: 3000
networks:
- frontend
- beanstalk
volumes:
- data:/app/data
cron:
restart: unless-stopped
image: rss-to-activity-pub
environment:
- DOMAIN=rss.fediwersum.pl
command: /usr/sbin/crond -f -l 0
volumes:
- data:/app/data
networks:
- beanstalk
update-feeds:
restart: unless-stopped
image: rss-to-activity-pub
environment:
- DOMAIN=rss.fediwersum.pl
command: /init-update.sh
volumes:
- data:/app/data
networks:
- beanstalk
beanstalkd:
restart: unless-stopped
image: schickling/beanstalkd
networks:
- beanstalk
networks:
frontend:
external: true
beanstalk:
driver: overlay
volumes:
data:
driver: local

1
feed-cron Executable file
View File

@ -0,0 +1 @@
/bin/sh -c "cd /app && node queueFeeds.js" >/dev/null 2>&1

36
init-update.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/sh
cd /app
cp config.json.template config.json
if [[ ! -z ${DOMAIN+x} ]]; then
sed -i "s/\"DOMAIN\": \"\"/\"DOMAIN\": \"${DOMAIN}\"/g" config.json
else
echo 'Env var $DOMAIN is not set. Set it before starting the container'
exit 1
fi
if [[ ! -z ${PORT_HTTP+x} ]]; then
sed -i "s/\"PORT_HTTP\": \"3000\"/\"PORT_HTTP\": \"${PORT_HTTP}\"/g" config.json
fi
if [[ ! -z ${PORT_HTTPS+x} ]]; then
sed -i "s/\"PORT_HTTPS\": \"8443\"/\"PORT_HTTPS\": \"${PORT_HTTPS}\"/g" config.json
fi
if [[ ! -z ${PRIVKEY_PATH+x} ]]; then
sed -i "s@\"PRIVKEY_PATH\": \"\"@\"PRIVKEY_PATH\": \"${PRIVKEY_PATH}\"@g" config.json
fi
if [[ ! -z ${CERT_PATH+x} ]]; then
sed -i "s@\"CERT_PATH\": \"\"@\"CERT_PATH\": \"${CERT_PATH}\"@g" config.json
fi
echo "Configuration file :"
cat config.json
node updateFeeds.js

36
init.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/sh
cd /app
cp config.json.template config.json
if [[ ! -z ${DOMAIN+x} ]]; then
sed -i "s/\"DOMAIN\": \"\"/\"DOMAIN\": \"${DOMAIN}\"/g" config.json
else
echo 'Env var $DOMAIN is not set. Set it before starting the container'
exit 1
fi
if [[ ! -z ${PORT_HTTP+x} ]]; then
sed -i "s/\"PORT_HTTP\": \"3000\"/\"PORT_HTTP\": \"${PORT_HTTP}\"/g" config.json
fi
if [[ ! -z ${PORT_HTTPS+x} ]]; then
sed -i "s/\"PORT_HTTPS\": \"8443\"/\"PORT_HTTPS\": \"${PORT_HTTPS}\"/g" config.json
fi
if [[ ! -z ${PRIVKEY_PATH+x} ]]; then
sed -i "s@\"PRIVKEY_PATH\": \"\"@\"PRIVKEY_PATH\": \"${PRIVKEY_PATH}\"@g" config.json
fi
if [[ ! -z ${CERT_PATH+x} ]]; then
sed -i "s@\"CERT_PATH\": \"\"@\"CERT_PATH\": \"${CERT_PATH}\"@g" config.json
fi
echo "Configuration file :"
cat config.json
node index.js