Browse Source

Add multi-stage dockerfile as node:alpine image

trunk
Kevin Hoerr 1 year ago
parent
commit
5090797f19
Signed by: kjhoerr GPG Key ID: 78E4BD33ACC22C86
3 changed files with 43 additions and 0 deletions
  1. +6
    -0
      .dockerignore
  2. +1
    -0
      CHANGELOG.md
  3. +36
    -0
      Dockerfile

+ 6
- 0
.dockerignore View File

@ -0,0 +1,6 @@
.git
.vscode
build
.env*
dist
node_modules

+ 1
- 0
CHANGELOG.md View File

@ -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


+ 36
- 0
Dockerfile View File

@ -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" ]

Loading…
Cancel
Save