Skip to content

Commit

Permalink
Create container for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilkybarkid committed Dec 4, 2023
1 parent 3c485f6 commit f4012e6
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
FROM node:20.10.0-alpine3.18 AS node
ENV NODE_OPTIONS --unhandled-rejections=strict --enable-source-maps
WORKDIR /app

#
# Stage: NPM environment
#
FROM node AS npm
COPY .npmrc \
package.json \
package-lock.json \
./

#
# Stage: Development NPM install
#
FROM npm AS npm-dev

RUN npm ci

#
# Stage: Production NPM install
#
FROM npm AS npm-prod

RUN npm ci --production

#
# Stage: Production build
#
FROM npm AS build-prod
ENV NODE_ENV=production

COPY --from=npm-dev /app/node_modules/ node_modules/
COPY tsconfig.build.json \
tsconfig.json \
./
COPY src/ src/

RUN npx tsc --project tsconfig.build.json

#
# Stage: Production environment
#
FROM node AS prod
ENV NODE_ENV=production

RUN echo "{\"type\": \"module\"}" > package.json
COPY --from=npm-prod /app/node_modules/ node_modules/
COPY --from=build-prod /app/dist/ dist/

HEALTHCHECK --interval=5s --timeout=1s \
CMD wget --quiet --tries=1 --spider http://localhost:3000/health || exit 1

EXPOSE 3000
USER node

CMD ["node", "dist/index.js"]

0 comments on commit f4012e6

Please sign in to comment.