From 04d3b106f444f66dc77ee94c0391706213e8b8e5 Mon Sep 17 00:00:00 2001 From: Juanma Hidalgo Date: Fri, 15 Nov 2024 18:58:47 +0100 Subject: [PATCH 1/2] feat: add Dockerfile --- Dockerfile | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2b40d3b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +ARG RUN + +FROM node:18.18-alpine as builderenv + +WORKDIR /app + +# some packages require a build step +RUN apk update +RUN apk add --no-cache py3-setuptools python3-dev build-base g++ make py3-pip libpng-dev jpeg-dev pango-dev cairo-dev giflib-dev librsvg-dev + +# install dependencies +COPY package.json /app/package.json +COPY package-lock.json /app/package-lock.json +RUN npm install + +# build the app +COPY . /app +RUN npm run build +RUN npm run test + +# remove devDependencies, keep only used dependencies +RUN npm install --only=production --ignore-scripts + +########################## END OF BUILD STAGE ########################## + +FROM node:18.18-alpine + +RUN apk update +RUN apk add --no-cache tini libpng jpeg cairo pango giflib librsvg-dev + +# NODE_ENV is used to configure some runtime options, like JSON logger +ENV NODE_ENV production + +WORKDIR /app +COPY --from=builderenv /app /app +# Please _DO NOT_ use a custom ENTRYPOINT because it may prevent signals +# (i.e. SIGTERM) to reach the service +# Read more here: https://aws.amazon.com/blogs/containers/graceful-shutdowns-with-ecs/ +# and: https://www.ctl.io/developers/blog/post/gracefully-stopping-docker-containers/ +ENTRYPOINT ["/sbin/tini", "--"] +# Run the program under Tini +CMD [ "/usr/local/bin/node", "--trace-warnings", "--abort-on-uncaught-exception", "--unhandled-rejections=strict", "dist/src/index.js" ] \ No newline at end of file From 8963ef57aec84c484b126d9f0819920d7221a6fb Mon Sep 17 00:00:00 2001 From: Juanma Hidalgo Date: Fri, 15 Nov 2024 19:01:43 +0100 Subject: [PATCH 2/2] feat: add .dockerignore --- .dockerignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5171c54 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +node_modules +npm-debug.log \ No newline at end of file