Skip to content

Commit 7006309

Browse files
committed
build: fix dockerfile
1 parent dedadeb commit 7006309

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

Dockerfile

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,42 @@
1515
ARG NODE_VER=20-alpine
1616
ARG DIR=/usr/src/app/
1717

18-
FROM node:$NODE_VER AS install
18+
FROM node:$NODE_VER AS base
1919
ARG DIR
2020

21+
# Install needed packages
22+
RUN apk add --no-cache \
23+
dumb-init
24+
2125
WORKDIR ${DIR}
2226

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

30+
RUN chown -R node:node ${DIR}
31+
# Do not run service as root
32+
USER node
33+
2634
RUN yarn workspaces focus --all --production
2735

28-
FROM install AS build
36+
# Launch entrypoint with dumb-init
37+
# Remap SIGTERM to SIGINT https://github.com/Yelp/dumb-init#signal-rewriting
38+
ENTRYPOINT ["/usr/bin/dumb-init", "--rewrite", "15:2", "--", "yarn", "run"]
39+
CMD ["start"]
40+
41+
FROM base AS build
2942
ARG DIR
3043

3144
# Install dev deps too
3245
RUN yarn install --immutable
3346

3447
COPY . ${DIR}
3548

36-
# Build code and remove dev deps
37-
RUN yarn build --verbose && rm -rfv .yarn .pnp*
49+
# Build code
50+
RUN yarn build --verbose
3851

39-
FROM node:$NODE_VER AS production
52+
FROM base AS production
4053
ARG DIR
4154

42-
# Install needed packages
43-
RUN apk add --no-cache \
44-
dumb-init
45-
46-
# Do not run service as root
47-
USER node
48-
49-
WORKDIR ${DIR}
50-
51-
COPY --from=install ${DIR} ${DIR}
52-
COPY --from=build ${DIR} ${DIR}
53-
54-
# Launch entrypoint with dumb-init
55-
# Remap SIGTERM to SIGINT https://github.com/Yelp/dumb-init#signal-rewriting
56-
ENTRYPOINT ["/usr/bin/dumb-init", "--rewrite", "15:2", "--", "yarn", "run"]
57-
CMD ["start"]
55+
# Copy in build code
56+
COPY --from=build ${DIR}/dist ${DIR}/dist

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@trellisfw/monitor",
3-
"version": "2.2.0",
3+
"version": "2.2.2",
44
"description": "A Trellis microservice to respond to monitor pings, spawn and check things internally, and respond with success or fail",
55
"main": "dist/index.js",
66
"type": "module",

0 commit comments

Comments
 (0)