Skip to content

Instantly share code, notes, and snippets.

@mdrobny
Created September 15, 2021 17:23
Show Gist options
  • Select an option

  • Save mdrobny/d674d3a84209ac86dca3ad3b5edd78e6 to your computer and use it in GitHub Desktop.

Select an option

Save mdrobny/d674d3a84209ac86dca3ad3b5edd78e6 to your computer and use it in GitHub Desktop.

Revisions

  1. mdrobny created this gist Sep 15, 2021.
    31 changes: 31 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    FROM node:14-alpine as builder

    WORKDIR /app

    COPY package*.json .npmrc ./

    # installing deps is separate from copying source to reuse image with deps if none changed
    RUN npm ci

    COPY tsconfig*.json ./
    COPY src ./src
    COPY config ./config

    # Compile TS to JS
    RUN npm run build

    # Remove devDependecies
    RUN npm prune --production

    # Move required files to final dir
    RUN mv package.json ./node_modules ./dist

    # resulting image
    FROM node:14-alpine

    WORKDIR /app
    COPY --from=builder /app/dist ./

    EXPOSE 8080

    CMD ["/usr/local/bin/npm", "start"]