16
16
17
17
# We use the alpine image because of its small size. The alternative considered was the "slim" image, but it is larger
18
18
# and we already use alpine (without issues) in other projects, so the size reduction seems worth it.
19
- FROM node:18-alpine AS build
19
+ FROM node:18-slim AS build
20
20
WORKDIR /app
21
21
RUN npm install -g pnpm
22
22
# Copy just the "pnpm-lock.yaml" file and use "pnpm fetch" to download all dependencies just from the lockfile. This
@@ -39,13 +39,13 @@ LABEL application="airnode-feed" description="Airnode feed container"
39
39
FROM build AS deployed-airnode-feed
40
40
41
41
RUN pnpm --filter=@api3/airnode-feed --prod deploy deployed-airnode-feed
42
- FROM node:18-alpine as airnode-feed
42
+ FROM node:18-slim as airnode-feed
43
43
WORKDIR /app
44
44
ENV NODE_ENV=production
45
45
46
- RUN addgroup -S deployed-airnode-feed && \
47
- adduser -h /app -s /bin/false -S -D -H -G deployed-airnode-feed deployed-airnode-feed && \
48
- chown -R deployed-airnode-feed /app
46
+ RUN addgroup --system deployed-airnode-feed && \
47
+ adduser --home /app --shell /bin/false --system --disabled-password --ingroup deployed-airnode-feed deployed-airnode-feed && \
48
+ chown --recursive deployed-airnode-feed: deployed-airnode-feed /app
49
49
USER deployed-airnode-feed
50
50
51
51
COPY --chown=deployed-airnode-feed:deployed-airnode-feed --from=deployed-airnode-feed /app/deployed-airnode-feed .
@@ -58,17 +58,21 @@ LABEL application="signed-api" description="Signed API container"
58
58
FROM build AS deployed-signed-api
59
59
60
60
RUN pnpm --filter=@api3/signed-api --prod deploy deployed-signed-api
61
- FROM node:18-alpine as signed-api
61
+ FROM node:18-slim as signed-api
62
62
WORKDIR /app
63
63
ENV NODE_ENV=production
64
64
65
- # Make sure the non-root user can bind to port 80.
66
- RUN apk add --no-cache libcap
65
+ # Update package lists and install libcap
66
+ RUN apt-get update && \
67
+ apt-get install --no-install-recommends -y libcap2-bin && \
68
+ rm -rf /var/lib/apt/lists/*
69
+ # Set capabilities to allow Node.js to bind to well-known ports (<1024) as a non-root user
67
70
RUN setcap 'cap_net_bind_service=+ep' /usr/local/bin/node
68
71
69
- RUN addgroup -S deployed-signed-api && \
70
- adduser -h /app -s /bin/false -S -D -H -G deployed-signed-api deployed-signed-api && \
71
- chown -R deployed-signed-api /app
72
+
73
+ RUN addgroup --system deployed-signed-api && \
74
+ adduser --home /app --shell /bin/false --system --disabled-password --ingroup deployed-signed-api deployed-signed-api && \
75
+ chown --recursive deployed-signed-api:deployed-signed-api /app
72
76
USER deployed-signed-api
73
77
74
78
COPY --chown=deployed-signed-api:deployed-signed-api --from=deployed-signed-api /app/deployed-signed-api .
0 commit comments