Skip to content

Commit

Permalink
feat: Dockerfile with Node 20
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinszuchet committed Jan 8, 2025
1 parent d1b2885 commit 11d32fb
Show file tree
Hide file tree
Showing 3 changed files with 206 additions and 204 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.18.0
35 changes: 18 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
ARG RUN

FROM node:lts as builderenv
FROM node:20-alpine as builderenv

WORKDIR /app

# some packages require a build step
RUN apt-get update && apt-get -y -qq install build-essential

# We use Tini to handle signals and PID1 (https://github.com/krallin/tini, read why here https://github.com/krallin/tini/issues/8)
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini

# install dependencies
COPY package.json /app/package.json
COPY yarn.lock /app/yarn.lock
RUN yarn
RUN apk update && apk add wget

# build the app
COPY . /app
RUN yarn install --frozen-lockfile
RUN yarn build
RUN yarn test

# remove devDependencies, keep only used dependencies
RUN yarn install --frozen-lockfile --production
RUN yarn install --prod --frozen-lockfile

########################## END OF BUILD STAGE ##########################

FROM node:lts
FROM node:20-alpine

RUN apk update && apk add --update wget && apk add --update tini

# NODE_ENV is used to configure some runtime options, like JSON logger
ENV NODE_ENV production

ARG COMMIT_HASH=local
ENV COMMIT_HASH=${COMMIT_HASH:-local}

ARG CURRENT_VERSION=Unknown
ENV CURRENT_VERSION=${CURRENT_VERSION:-Unknown}

WORKDIR /app
COPY --from=builderenv /app /app
COPY --from=builderenv /tini /tini

RUN echo "" > /app/api/.env
RUN echo "" > /app/processor/.env

# Please _DO NOT_ use a custom ENTRYPOINT because it may prevent signals
# (i.e. SIGTERM) to reach the service
# Read more here: https://aws.amazon.com/blogs/containers/graceful-shutdowns-with-ecs/
# and: https://www.ctl.io/developers/blog/post/gracefully-stopping-docker-containers/
ENTRYPOINT ["/tini", "--"]
ENTRYPOINT ["tini", "--"]
# Run the program under Tini
CMD [ "/usr/local/bin/node", "--trace-warnings", "--abort-on-uncaught-exception", "--unhandled-rejections=strict", "dist/index.js" ]
Loading

0 comments on commit 11d32fb

Please sign in to comment.