diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..d78bf0a --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v18.20.4 diff --git a/Dockerfile b/Dockerfile index db828b6..be416c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,44 +1,43 @@ -ARG RUN -FROM node:lts as builderenv +FROM node:18-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 --no-cache 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:18-alpine + +RUN apk update && apk add --no-cache wget 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/.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" ]