aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin J Hoerr <kjhoerr@protonmail.com>2019-12-10 01:28:46 -0500
committerKevin J Hoerr <kjhoerr@protonmail.com>2019-12-10 01:28:46 -0500
commit5090797f199c4499921126133fc3e5ad4c142060 (patch)
treee1bfe131b6b9d2d605493c76462d005d256867ae
parentefab55d4c8ebd3ae37917969c01cdf525829fa76 (diff)
downloadao-coverage-5090797f199c4499921126133fc3e5ad4c142060.tar.gz
ao-coverage-5090797f199c4499921126133fc3e5ad4c142060.tar.bz2
ao-coverage-5090797f199c4499921126133fc3e5ad4c142060.zip
Add multi-stage dockerfile as node:alpine image
-rw-r--r--.dockerignore6
-rw-r--r--CHANGELOG.md1
-rw-r--r--Dockerfile36
3 files changed, 43 insertions, 0 deletions
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..de6bbd2
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,6 @@
+.git
+.vscode
+build
+.env*
+dist
+node_modules \ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d2b7ef3..036104e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Scripts added: `start:dev` for integrated watcher, `start:prod` for running server as production
- Formatting and linting scripts
- Template file converter, and bash template for serving
+- Multi-stage dockerfile
### Changed
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..31b60f5
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,36 @@
+# Stage 1. Base
+FROM node:carbon AS base
+WORKDIR /app
+
+# Stage 2. Dependencies
+FROM base AS dependencies
+COPY package*.json ./
+RUN npm install
+
+# Stage 3. TS compilation
+FROM dependencies AS build
+COPY src /app/src
+COPY tsconfig.json /app
+RUN npm run tsc
+
+# Stage 4. Release Image
+FROM node:alpine AS release
+WORKDIR /app
+
+COPY --from=dependencies /app/package.json ./
+RUN npm install --only=production
+COPY --from=build /app/build ./build
+COPY public ./public
+
+ENV NODE_ENV=production \
+ PORT=8080 \
+ BIND_ADDRESS=0.0.0.0 \
+ UPLOAD_LIMIT=134217700 \
+ LOG_LEVEL=info \
+ HOST_DIR=/data
+
+RUN mkdir -p ${HOST_DIR}
+VOLUME [ ${HOST_DIR} ]
+EXPOSE ${PORT}
+
+CMD [ "node", "./build/index.js" ] \ No newline at end of file