-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDockerfile
More file actions
85 lines (65 loc) · 2.51 KB
/
Dockerfile
File metadata and controls
85 lines (65 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# checkov:skip=CKV_DOCKER_3: entrypoint uses su-exec for runtime privilege drop
# Common Stage
FROM node:24-alpine@sha256:7fddd9ddeae8196abf4a3ef2de34e11f7b1a722119f91f28ddf1e99dcafdf114 AS base
WORKDIR /home/node/app
LABEL maintainer="CodesWhat"
EXPOSE 3000
ARG DD_VERSION=unknown
ENV WORKDIR=/home/node/app
ENV DD_LOG_FORMAT=text
ENV DD_VERSION=$DD_VERSION
HEALTHCHECK --interval=30s --timeout=5s CMD ["sh", "-c", "if [ -n \"$DD_SERVER_ENABLED\" ] && [ \"$DD_SERVER_ENABLED\" != 'true' ]; then exit 0; fi; if [ \"$DD_SERVER_TLS_ENABLED\" = 'true' ]; then curl --fail --insecure https://localhost:${DD_SERVER_PORT:-3000}/health || exit 1; else curl --fail http://localhost:${DD_SERVER_PORT:-3000}/health || exit 1; fi"]
# Install system packages, trivy, and cosign
# hadolint ignore=DL3018,DL3028,DL4006
RUN apk add --no-cache \
bash \
curl \
git \
jq \
openssl \
su-exec \
tini \
tzdata \
&& apk add --no-cache cosign \
&& apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing trivy=0.69.3-r1 \
&& apk upgrade --no-cache zlib \
&& mkdir /store && chown node:node /store
# Build stage for backend app
FROM base AS app-build
# Copy app package.json
COPY app/package* ./
# Install dependencies (including dev)
RUN npm ci --include=dev --omit=optional --no-audit --no-fund --no-update-notifier
# Copy app source
COPY app/ ./
# Build and remove dev dependencies
RUN npm run build \
&& npm prune --omit=dev
# Build stage for frontend UI
FROM base AS ui-build
WORKDIR /home/node/ui
# Copy ui package.json
COPY ui/package* ./
# Install ui dependencies
RUN npm ci --no-audit --no-fund --no-update-notifier
# Copy ui sources and build static assets
COPY ui/ ./
RUN npm run build
# Release stage
FROM base AS release
ENV DD_LOG_FORMAT=json
# Remove unnecessary network utilities (busybox symlinks) and npm to reduce attack surface.
# curl is kept for the HEALTHCHECK probe; npm is only needed during build stages.
RUN rm -f /usr/bin/wget /usr/bin/nc \
&& rm -rf /usr/local/lib/node_modules/npm /usr/local/bin/npm /usr/local/bin/npx
# Default entrypoint
COPY --chmod=755 Docker.entrypoint.sh /usr/bin/entrypoint.sh
ENTRYPOINT ["tini", "-g", "--", "/usr/bin/entrypoint.sh"]
CMD ["node", "dist/index.js"]
## Copy node_modules
COPY --from=app-build /home/node/app/node_modules ./node_modules
# Copy app (dist)
COPY --from=app-build /home/node/app/dist ./dist
COPY --from=app-build /home/node/app/package.json ./package.json
# Copy ui
COPY --from=ui-build /home/node/ui/dist/ ./ui