Skip to content

Commit c7e3710

Browse files
authored
Use non-root user for keel container (#800)
This commit drops unnesessary broad permissions for the keel container. Fixes #679 Signed-off-by: Matthias Baur <m.baur@syseleven.de>
1 parent e3bfd63 commit c7e3710

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

Dockerfile

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
1-
FROM golang:1.23.4
1+
FROM golang:1.23.4 as go-build
22
COPY . /go/src/github.com/keel-hq/keel
33
WORKDIR /go/src/github.com/keel-hq/keel
44
RUN make install
55

6-
FROM node:16.20.2-alpine
6+
FROM node:16.20.2-alpine as yarn-build
77
WORKDIR /app
88
COPY ui /app
99
RUN yarn
1010
RUN yarn run lint --no-fix
1111
RUN yarn run build
1212

1313
FROM alpine:3.20.3
14+
ARG USERNAME=keel
15+
ARG USER_ID=666
16+
ARG GROUP_ID=$USER_ID
17+
1418
RUN apk --no-cache add ca-certificates
19+
RUN addgroup --gid $GROUP_ID $USERNAME \
20+
&& adduser --home /data --ingroup $USERNAME --disabled-password --uid $USER_ID $USERNAME \
21+
&& mkdir -p /data && chown $USERNAME:0 /data && chmod g=u /data
22+
23+
COPY --from=go-build /go/bin/keel /bin/keel
24+
COPY --from=yarn-build /app/dist /www
25+
26+
USER $USER_ID
1527

1628
VOLUME /data
1729
ENV XDG_DATA_HOME /data
1830

19-
COPY --from=0 /go/bin/keel /bin/keel
20-
COPY --from=1 /app/dist /www
2131
ENTRYPOINT ["/bin/keel"]
2232
EXPOSE 9300

Dockerfile.debian

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,21 @@ WORKDIR /go/src/github.com/keel-hq/keel
44
RUN make build
55

66
FROM debian:latest
7+
ARG USERNAME=keel
8+
ARG USER_ID=666
9+
ARG GROUP_ID=$USER_ID
10+
711
RUN apt-get update && apt-get install -y \
812
ca-certificates \
913
&& rm -rf /var/lib/apt/lists/*
1014

15+
RUN addgroup --gid $GROUP_ID $USERNAME \
16+
&& adduser --home /data --ingroup $USERNAME --disabled-password --uid $USER_ID $USERNAME \
17+
&& mkdir -p /data && chown $USERNAME:0 /data && chmod g=u /data
18+
1119
COPY --from=0 /go/src/github.com/keel-hq/keel/cmd/keel/keel /bin/keel
20+
21+
USER $USER_ID
1222
ENTRYPOINT ["/bin/keel"]
1323

1424
EXPOSE 9300

0 commit comments

Comments
 (0)