aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Dockerfile35
1 files changed, 35 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..e99d431
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,35 @@
+FROM node:18-alpine
+
+LABEL description="Aniwatch API docker image"
+LABEL org.opencontainers.image.source https://github.com/ghoshRitesh12/aniwatch-api
+
+# create a non-privileged user
+RUN addgroup -S aniwatch && adduser -S zoro -G aniwatch
+
+# set secure folder permissions
+RUN mkdir /app && chown -R zoro:aniwatch /app
+
+# set non-privileged user
+USER zoro
+
+# set working directory
+WORKDIR /app
+
+# copy config file for better use of layers
+COPY --chown=zoro:aniwatch package.json .
+
+# install dependencies
+RUN npm install --omit=dev --ignore-scripts
+
+# copy all necessary files in the container (except ones in .dockerignore)
+COPY --chown=zoro:aniwatch . .
+
+HEALTHCHECK --interval=30s --timeout=3s --start-period=5s CMD [ "npm", "run", "healthcheck" ]
+
+ENV NODE_ENV=production
+ENV PORT=4000
+
+# exposed port
+EXPOSE 4000
+
+CMD [ "node", "dist/server.js" ]