Skip to content

Commit 1ed4634

Browse files
committed
updated paths to run as nonroot
1 parent 48c0e7d commit 1ed4634

4 files changed

Lines changed: 49 additions & 26 deletions

File tree

Dockerfile

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
FROM node:21.6-bookworm
1+
FROM node:21.6-bookworm as builder
22

33
# Install dependencies
4-
# Tini allows us to avoid several Docker edge cases, see https://github.com/krallin/tini.
5-
# NOTE: See https://github.com/hexops/dockerfile#is-tini-still-required-in-2020-i-thought-docker-added-it-natively
6-
7-
RUN apt-get update && apt-get install -y \
8-
tini \
9-
&& rm -rf /var/lib/apt/lists/*
104

115
# arguments
126
ARG PORT=3000
137

148
# Set up the directory
15-
WORKDIR /relayer-node
9+
WORKDIR /bundler
1610

1711
# Copy package files
1812
COPY package.json yarn.lock ./
@@ -26,6 +20,16 @@ COPY . /relayer-node
2620
# Build the application
2721
RUN yarn run build
2822

23+
# Second stage
24+
FROM node:21.6-bookworm
25+
26+
# Tini allows us to avoid several Docker edge cases, see https://github.com/krallin/tini.
27+
# NOTE: See https://github.com/hexops/dockerfile#is-tini-still-required-in-2020-i-thought-docker-added-it-natively
28+
29+
RUN apt-get update && apt-get install -y \
30+
tini \
31+
&& rm -rf /var/lib/apt/lists/*
32+
2933
# Expose the port
3034
EXPOSE 3000
3135

@@ -40,6 +44,10 @@ EXPOSE 3000
4044
RUN addgroup --gid 10001 --system nonroot \
4145
&& adduser --uid 10000 --system --ingroup nonroot --home /home/nonroot nonroot
4246

47+
WORKDIR /home/nonroot/bundler
48+
COPY --from=builder --chown=10000:10001 /bundler /home/nonroot/bundler
49+
50+
4351
# Use the non-root user to run our application
4452
USER nonroot
4553

Dockerfile.dev

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
FROM node:21.6-bookworm
1+
FROM node:21.6-bookworm as builder
22

33
# Install dependencies
4-
# Tini allows us to avoid several Docker edge cases, see https://github.com/krallin/tini.
5-
# NOTE: See https://github.com/hexops/dockerfile#is-tini-still-required-in-2020-i-thought-docker-added-it-natively
6-
7-
RUN apt-get update && apt-get install -y \
8-
tini \
9-
&& rm -rf /var/lib/apt/lists/*
104

115
# arguments
126
ARG PORT=3000
137

148
# Set up the directory
15-
WORKDIR /home/nonroot/bundler
9+
WORKDIR /bundler
1610

1711
# Copy package files
1812
COPY package.json yarn.lock ./
@@ -23,6 +17,17 @@ RUN yarn install
2317
# Copy the rest of the files
2418
COPY . .
2519

20+
# Second stage
21+
FROM node:21.6-bookworm
22+
23+
# Tini allows us to avoid several Docker edge cases, see https://github.com/krallin/tini.
24+
# NOTE: See https://github.com/hexops/dockerfile#is-tini-still-required-in-2020-i-thought-docker-added-it-natively
25+
26+
RUN apt-get update && apt-get install -y \
27+
tini \
28+
&& rm -rf /var/lib/apt/lists/*
29+
30+
2631
# Expose the port
2732
EXPOSE 3000
2833

@@ -37,6 +42,9 @@ EXPOSE 3000
3742
RUN addgroup --gid 10001 --system nonroot \
3843
&& adduser --uid 10000 --system --ingroup nonroot --home /home/nonroot nonroot
3944

45+
WORKDIR /home/nonroot/bundler
46+
COPY --from=builder --chown=10000:10001 /bundler /home/nonroot/bundler
47+
4048
# Use the non-root user to run our application
4149
USER nonroot
4250

Dockerfile.helm

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
FROM node:21.6-bookworm
1+
FROM node:21.6-bookworm as builder
22

33
# Install dependencies
4-
# Tini allows us to avoid several Docker edge cases, see https://github.com/krallin/tini.
5-
# NOTE: See https://github.com/hexops/dockerfile#is-tini-still-required-in-2020-i-thought-docker-added-it-natively
6-
7-
RUN apt-get update && apt-get install -y \
8-
tini \
9-
&& rm -rf /var/lib/apt/lists/*
104

115
# Arguments
126
ARG PORT=3000
137

148
# Set up the directory
15-
WORKDIR /relayer-node
9+
WORKDIR /bundler
1610

1711
# Copy package files
1812
COPY package.json yarn.lock ./
@@ -21,11 +15,21 @@ COPY package.json yarn.lock ./
2115
RUN yarn install
2216

2317
# Copy the rest of the files
24-
COPY . /relayer-node
18+
COPY . /bundler
2519

2620
# Build the application
2721
RUN yarn run build
2822

23+
# Second stage
24+
FROM node:21.6-bookworm
25+
26+
# Tini allows us to avoid several Docker edge cases, see https://github.com/krallin/tini.
27+
# NOTE: See https://github.com/hexops/dockerfile#is-tini-still-required-in-2020-i-thought-docker-added-it-natively
28+
29+
RUN apt-get update && apt-get install -y \
30+
tini \
31+
&& rm -rf /var/lib/apt/lists/*
32+
2933
# Expose the port
3034
EXPOSE 3000
3135

@@ -40,6 +44,9 @@ EXPOSE 3000
4044
RUN addgroup --gid 10001 --system nonroot \
4145
&& adduser --uid 10000 --system --ingroup nonroot --home /home/nonroot nonroot
4246

47+
WORKDIR /home/nonroot/bundler
48+
COPY --from=builder --chown=10000:10001 /bundler /home/nonroot/bundler
49+
4350
# Use the non-root user to run our application
4451
USER nonroot
4552

install-bundler/bundler/templates/statefulset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ spec:
9595
{{- end }}
9696

9797
volumeMounts:
98-
- mountPath: "/relayer-node/config.json.enc"
98+
- mountPath: "/home/nonroot/bundler/config.json.enc"
9999
name: gcpsecrets
100100
subPath: "config.json.enc"
101101

0 commit comments

Comments
 (0)