Skip to content

Commit

Permalink
build: fix dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
awlayton committed May 21, 2024
1 parent dedadeb commit 7006309
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
41 changes: 20 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,42 @@
ARG NODE_VER=20-alpine
ARG DIR=/usr/src/app/

FROM node:$NODE_VER AS install
FROM node:$NODE_VER AS base
ARG DIR

# Install needed packages
RUN apk add --no-cache \
dumb-init

WORKDIR ${DIR}

COPY ./.yarn ${DIR}.yarn
COPY ./package.json ./yarn.lock ./.yarnrc.yml ${DIR}

RUN chown -R node:node ${DIR}
# Do not run service as root
USER node

RUN yarn workspaces focus --all --production

FROM install AS build
# Launch entrypoint with dumb-init
# Remap SIGTERM to SIGINT https://github.com/Yelp/dumb-init#signal-rewriting
ENTRYPOINT ["/usr/bin/dumb-init", "--rewrite", "15:2", "--", "yarn", "run"]
CMD ["start"]

FROM base AS build
ARG DIR

# Install dev deps too
RUN yarn install --immutable

COPY . ${DIR}

# Build code and remove dev deps
RUN yarn build --verbose && rm -rfv .yarn .pnp*
# Build code
RUN yarn build --verbose

FROM node:$NODE_VER AS production
FROM base AS production
ARG DIR

# Install needed packages
RUN apk add --no-cache \
dumb-init

# Do not run service as root
USER node

WORKDIR ${DIR}

COPY --from=install ${DIR} ${DIR}
COPY --from=build ${DIR} ${DIR}

# Launch entrypoint with dumb-init
# Remap SIGTERM to SIGINT https://github.com/Yelp/dumb-init#signal-rewriting
ENTRYPOINT ["/usr/bin/dumb-init", "--rewrite", "15:2", "--", "yarn", "run"]
CMD ["start"]
# Copy in build code
COPY --from=build ${DIR}/dist ${DIR}/dist
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trellisfw/monitor",
"version": "2.2.0",
"version": "2.2.2",
"description": "A Trellis microservice to respond to monitor pings, spawn and check things internally, and respond with success or fail",
"main": "dist/index.js",
"type": "module",
Expand Down

0 comments on commit 7006309

Please sign in to comment.