leafac / kill-the-newsletter

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

Creating docker for unraid #41

Closed mbhkoay closed 3 years ago

mbhkoay commented 3 years ago

Hi, love the idea of subscribing to newsletters through RSS.

I have totally no background in coding but have just followed instructions to install dockers previously. Have a little experience with dockers and debian but not much else. Currently using Unraid as my os, and would like to host my own deployment using docker.

I have successfully run the linux release in the directory /mnt/user/Mine/kill-the-newsletter

After that, I created a Dockerfile following the sample from: https://github.com/leafac/kill-the-newsletter/blob/b9907a8021cebd6cd4a4b3131fd31ac5aa0a2e37/Dockerfile. The only changes made was to the port numbers, changing from 8000 to 11000.

Upon running docker build -t kill-the-newsletter ., system returns the following error:

Sending build context to Docker daemon  75.74MB
Step 1/15 : FROM node:latest
 ---> 7105279fa2ab
Step 2/15 : WORKDIR /kill-the-newsletter
 ---> Using cache
 ---> 034323dbc2cc
Step 3/15 : COPY package*.json ./
COPY failed: no source files were specified

So I made another attempt, by downloading the source code from https://github.com/leafac/kill-the-newsletter/archive/refs/tags/v1.0.1.zip, extracting them to the folder /mnt/user/Mine/kill-the-newsletter, then executing docker build -t kill-the-newsletter . again. The following appeared:

Sending build context to Docker daemon  76.43MB
Step 1/15 : FROM node:latest
 ---> 7105279fa2ab
Step 2/15 : WORKDIR /kill-the-newsletter
 ---> Using cache
 ---> 034323dbc2cc
Step 3/15 : COPY package*.json ./
 ---> Using cache
 ---> 93aa1b3cbb14
Step 4/15 : RUN npm ci --production
 ---> Running in 825ee612d572
npm WARN deprecated request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142

> kill-the-newsletter@1.0.1 prepare
> tsc

sh: 1: tsc: not found
npm notice
npm notice New minor version of npm available! 7.15.1 -> 7.19.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.19.0>
npm notice Run `npm install -g npm@7.19.0` to update!
npm notice
npm ERR! code 127
npm ERR! path /kill-the-newsletter
npm ERR! command failed
npm ERR! command sh -c tsc

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-06-27T15_25_42_508Z-debug.log
The command '/bin/sh -c npm ci --production' returned a non-zero code: 127

Any help is appreciated.

leafac commented 3 years ago

Thanks for reaching out and for using Kill the Newsletter!

You’re running into issues because the architecture of the application changed between the version from you which you copied the Dockerfile and version 1.0.1. I’m not planning on supporting Docker right now; instead I’m favoring the executable binaries you may find at https://github.com/leafac/kill-the-newsletter/releases/tag/v1.0.1 (By the way, they were created with caxa, which is another project of mine.)

The specific issue you’re running into is that the Dockerfile says to run npm ci --production, which attempts to install only the production dependencies, but that doesn’t install TypeScript, which is necessary to build the application, and when it tries to build you get an error saying tsc (the TypeScript compiler) isn’t found.

The way I’d go about this if I were to do a Docker build is to start with an image that has Node.js installed and first run npm ci. That command will install all the dependencies (including development ones) and build the application. I’d then run npm dedupe --production, to strip away the development dependencies (that step removes tsc, but it’s fine because we won’t use it anymore). Finally, to start the application, I’d use node lib/index.js, which runs the JavaScript file produced by the TypeScript compiler.

Good luck. Let me know how it goes.