Created
September 15, 2021 17:23
-
-
Save mdrobny/d674d3a84209ac86dca3ad3b5edd78e6 to your computer and use it in GitHub Desktop.
Dockerfile with TS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment