diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cfb2153 --- /dev/null +++ b/Dockerfile @@ -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"] + diff --git a/.gitignore b/app/.gitignore similarity index 100% rename from .gitignore rename to app/.gitignore diff --git a/LICENSE-MIT b/app/LICENSE-MIT similarity index 100% rename from LICENSE-MIT rename to app/LICENSE-MIT diff --git a/README.md b/app/README.md similarity index 100% rename from README.md rename to app/README.md diff --git a/config.json.template b/app/config.json.template similarity index 100% rename from config.json.template rename to app/config.json.template diff --git a/data/.gitignore b/app/data/.gitignore similarity index 100% rename from data/.gitignore rename to app/data/.gitignore diff --git a/index.js b/app/index.js similarity index 100% rename from index.js rename to app/index.js diff --git a/package.json b/app/package.json similarity index 100% rename from package.json rename to app/package.json diff --git a/public/convert/index.html b/app/public/convert/index.html similarity index 100% rename from public/convert/index.html rename to app/public/convert/index.html diff --git a/queueFeeds.js b/app/queueFeeds.js similarity index 100% rename from queueFeeds.js rename to app/queueFeeds.js diff --git a/routes/api.js b/app/routes/api.js similarity index 100% rename from routes/api.js rename to app/routes/api.js diff --git a/routes/inbox.js b/app/routes/inbox.js similarity index 100% rename from routes/inbox.js rename to app/routes/inbox.js diff --git a/routes/index.js b/app/routes/index.js similarity index 100% rename from routes/index.js rename to app/routes/index.js diff --git a/routes/message.js b/app/routes/message.js similarity index 100% rename from routes/message.js rename to app/routes/message.js diff --git a/routes/user.js b/app/routes/user.js similarity index 100% rename from routes/user.js rename to app/routes/user.js diff --git a/routes/webfinger.js b/app/routes/webfinger.js similarity index 100% rename from routes/webfinger.js rename to app/routes/webfinger.js diff --git a/updateFeeds.js b/app/updateFeeds.js similarity index 100% rename from updateFeeds.js rename to app/updateFeeds.js diff --git a/views/home.pug b/app/views/home.pug similarity index 100% rename from views/home.pug rename to app/views/home.pug diff --git a/views/message.pug b/app/views/message.pug similarity index 100% rename from views/message.pug rename to app/views/message.pug diff --git a/views/style.css b/app/views/style.css similarity index 100% rename from views/style.css rename to app/views/style.css diff --git a/views/user.pug b/app/views/user.pug similarity index 100% rename from views/user.pug rename to app/views/user.pug diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7814a4d --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/feed-cron b/feed-cron new file mode 100755 index 0000000..afb24de --- /dev/null +++ b/feed-cron @@ -0,0 +1 @@ +/bin/sh -c "cd /app && node queueFeeds.js" >/dev/null 2>&1 diff --git a/init-update.sh b/init-update.sh new file mode 100755 index 0000000..63127bb --- /dev/null +++ b/init-update.sh @@ -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 + diff --git a/init.sh b/init.sh new file mode 100755 index 0000000..9a61842 --- /dev/null +++ b/init.sh @@ -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 +