aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.dockerignore2
-rw-r--r--Dockerfile18
-rw-r--r--index.js2
3 files changed, 21 insertions, 1 deletions
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..93f1361
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,2 @@
+node_modules
+npm-debug.log
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..d638b6f
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,18 @@
+FROM node:14
+
+ENV PORT=8080
+ENV NODE_ENV=production
+
+WORKDIR /usr/src/app
+
+COPY package*.json ./
+
+USER node
+
+RUN npm clean-install --only=production
+
+COPY . .
+
+EXPOSE ${PORT}
+
+CMD [ "node", "index.js" ]
diff --git a/index.js b/index.js
index d2e486e..675233e 100644
--- a/index.js
+++ b/index.js
@@ -48,4 +48,4 @@ app.use(oldForm);
app.use('/', webRoutes);
-app.listen(process.env.PORT, () => console.log(`Server started on port ${process.env.PORT}.`));
+app.listen(process.env.PORT || 8080, () => console.log(`Server started on port ${process.env.PORT || 8080}.`));