From 4be19d9862de1afafe4a224f0fc3d4e34dfe97d3 Mon Sep 17 00:00:00 2001 From: Frank Moskal Date: Fri, 17 Jul 2020 22:07:46 -0400 Subject: [PATCH 1/3] Create Dockerfile --- Dockerfile | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..149fabb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +# use latest stable node +FROM node:lts-alpine + +# set build arguments +ARG VERSION=1.0.0 + +# set environment variables for container +ENV BASE_URL=https://www.kill-the-newsletter.com \ + EMAIL_DOMAIN=kill-the-newsletter.com \ + ISSUE_REPORT=mailto:kill-the-newsletter@leafac.com + +WORKDIR /src + +RUN apk --no-cache add git + +# download release and unpack archive +RUN wget -q -O release.tar.gz https://github.com/leafac/www.kill-the-newsletter.com/archive/$VERSION.tar.gz \ + && tar -C . -xzf release.tar.gz \ + && rm release.tar.gz \ + && mv www.kill-the-newsletter.com-$VERSION/* . \ + && rm -rf www.kill-the-newsletter.com-$VERSION/ + +# install dependencies +RUN npm install \ + && npm audit fix + +VOLUME /static/feeds/ + +# expose http & smtp +EXPOSE 8000 \ + 25 + +# start application +CMD [ "npm", "start" ] \ No newline at end of file From 451781ab37f8e5669cfb13e67f680b8f628ddd66 Mon Sep 17 00:00:00 2001 From: Frank Moskal Date: Fri, 17 Jul 2020 22:20:36 -0400 Subject: [PATCH 2/3] update README with basic docker info --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index b84e9f5..60b29c9 100644 --- a/README.md +++ b/README.md @@ -101,3 +101,12 @@ Install [Node.js](https://nodejs.org/) and run: ```console $ npm install-test ``` + +# Docker Support + +Install [Docker](https://www.docker.com/get-started) and run: + +```console +$ docker build -t kill-the-newsletter:latest . +$ docker run kill-the-newsletter:latest +``` \ No newline at end of file From 33e84b345a421e7da9878259ddf7fb23295df3be Mon Sep 17 00:00:00 2001 From: Leandro Facchinetti Date: Fri, 24 Jul 2020 09:03:17 +0100 Subject: [PATCH 3/3] Changes to Dockerfile based on https://nodejs.org/en/docs/guides/nodejs-docker-webapp/ --- .dockerignore | 5 +++++ Dockerfile | 43 +++++++++++++++---------------------------- README.md | 14 +++++++++----- 3 files changed, 29 insertions(+), 33 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f80343d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +/node_modules +/static/feeds/* +!/static/feeds/.gitkeep +/static/alternate/* +!/static/alternate/.gitkeep diff --git a/Dockerfile b/Dockerfile index 149fabb..83d149d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,34 +1,21 @@ -# use latest stable node -FROM node:lts-alpine +FROM node:latest -# set build arguments -ARG VERSION=1.0.0 +WORKDIR /kill-the-newsletter -# set environment variables for container -ENV BASE_URL=https://www.kill-the-newsletter.com \ - EMAIL_DOMAIN=kill-the-newsletter.com \ - ISSUE_REPORT=mailto:kill-the-newsletter@leafac.com +COPY package*.json ./ +RUN npm ci --production +COPY . . -WORKDIR /src +VOLUME /kill-the-newsletter/static/feeds/ +VOLUME /kill-the-newsletter/static/alternate/ -RUN apk --no-cache add git +ENV WEB_PORT=8000 +ENV EMAIL_PORT=2525 +ENV BASE_URL=http://localhost:8000 +ENV EMAIL_DOMAIN=localhost +ENV ISSUE_REPORT=mailto:kill-the-newsletter@leafac.com -# download release and unpack archive -RUN wget -q -O release.tar.gz https://github.com/leafac/www.kill-the-newsletter.com/archive/$VERSION.tar.gz \ - && tar -C . -xzf release.tar.gz \ - && rm release.tar.gz \ - && mv www.kill-the-newsletter.com-$VERSION/* . \ - && rm -rf www.kill-the-newsletter.com-$VERSION/ +EXPOSE 8000 +EXPOSE 2525 -# install dependencies -RUN npm install \ - && npm audit fix - -VOLUME /static/feeds/ - -# expose http & smtp -EXPOSE 8000 \ - 25 - -# start application -CMD [ "npm", "start" ] \ No newline at end of file +CMD npx ts-node . diff --git a/README.md b/README.md index 60b29c9..4e9115d 100644 --- a/README.md +++ b/README.md @@ -102,11 +102,15 @@ Install [Node.js](https://nodejs.org/) and run: $ npm install-test ``` -# Docker Support +# Docker Support (Experimental) -Install [Docker](https://www.docker.com/get-started) and run: +Install [Docker](https://www.docker.com/) and run: ```console -$ docker build -t kill-the-newsletter:latest . -$ docker run kill-the-newsletter:latest -``` \ No newline at end of file +$ docker build -t kill-the-newsletter . +$ docker run kill-the-newsletter +``` + +The web server will be running at `http://localhost:8000` and the email server at `smtp://localhost:2525`. + +For use in production, start with the example [`Dockerfile`](Dockerfile).