leafac / kill-the-newsletter

Convert email newsletters into Atom feeds
https://kill-the-newsletter.com
MIT License
2.31k stars 113 forks source link

Cannot run KtN in Docker construct #107

Open hycday opened 6 days ago

hycday commented 6 days ago

Hi team,

I am trying to run a version of KtN locally hosted. However, I am not that familiar with deployment of node, but I feel at ease with Docker.

I think I am also done, but some last part is missing. Once done I would be glad to provide full instructions for anyone to run it locally using Docker.

So, I have the following Dockerfile file:

FROM node:latest

WORKDIR /app

RUN git clone https://github.com/leafac/kill-the-newsletter.git .
RUN npm install

EXPOSE 8000
EXPOSE 2525

CMD npm start

and I have the following docker-compose.yml file:

version: "2.1"
services:
  app:
    build: .
    environment:
      EMAIL_DOMAIN: "mydomain.tld"
      ISSUE_REPORT: "mailto:error@mydomain.tld"
      WEB_PORT: 8000
      EMAIL_PORT: 2525
      BASE_URL: "http://sub.mydomain.tld:8000"
      TUNNEL: "sub.mydomain.tld"
    ports:
      - "8000:8000"
      - "2525:2525"
    restart: always
    volumes:
      - "./static/alternate/:/static/alternate/"
      - "./static/feeds/:/static/feeds/"
#everything below is proper to my caddy config
    networks:
      - caddy
    labels:
      caddy: sub.mydomain.tld
      caddy.reverse_proxy: "{{upstreams 8000}}"

networks:
  caddy:
    external: true

I did run a docker-compose up -d --build command I can see that the container is properly running with docker ps -a

when I go to http://sub.mydomain.tld:8000 (my domain is different of course) nothing happens, same without the 8000 port. DNS is properly configured.

When i check the docker logs of the container I see the following error (looping):

Node.js v22.3.0
2024-06-26T16:46:41.106Z        KILL THE NEWSLETTER!    2.0.7   START   email
node:internal/fs/promises:641
  return new FileHandle(await PromisePrototypeThen(
                        ^

Error: ENOENT: no such file or directory, open '/root/.local/share/caddy/certificates/local/localhost/localhost.key'
    at async open (node:internal/fs/promises:641:25)
    at async Object.readFile (node:internal/fs/promises:1254:14)
    at async file:///app/build/index.mjs:942:10 {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/root/.local/share/caddy/certificates/local/localhost/localhost.key'
}

and here is where I am lost now...

When I look at your video @leafac here https://youtu.be/507WU47x8HI?t=2666 I see that there is a reference to some js file (which i see here https://github.com/leafac/kill-the-newsletter/tree/main/configuration) but I am using caddy to handle the certificates parts...therefore I am not sure how to solve this one (or even if this is actually the issue).

Any help would be welcomed. I understand that this is Docker and not official per se, but the issue I am having is with deploying the app itself anyway and even if I don't use Docker I believe I would ran to the same issue more or less.

Thanks for any help

Note: I know issue is similar to https://github.com/leafac/kill-the-newsletter/issues/103 but it is not exactly the same, so didn't want to hijack his thread

hycday commented 6 days ago

so I tried something else, I modified development.mjs, pointing to the crt and key file of my domain, tried to run again, then checked the logs of the docker container and i see this :

2024-06-26T21:46:07.163Z        KILL THE NEWSLETTER!    2.0.7   START   https://sub.mydomain.tld
2024-06-26T21:46:08.076Z        KILL THE NEWSLETTER!    2.0.7   START   server  18000
2024-06-26T21:46:08.099Z        SERVER  18000   START
2024-06-26T21:46:08.125Z        KILL THE NEWSLETTER!    2.0.7   START   backgroundJob   18001
2024-06-26T21:46:08.252Z        KILL THE NEWSLETTER!    2.0.7   START   server  18001
2024-06-26T21:46:08.255Z        KILL THE NEWSLETTER!    2.0.7   START   email
2024-06-26T21:46:08.268Z        SERVER  18001   START
2024-06-26T21:46:08.266Z        KILL THE NEWSLETTER!    2.0.7   START   backgroundJob   18000

however, when going to sub.mydomain.tld I get a blank page....