Skip to content

Commit 66a837a

Browse files
committed
🔒(build) improve dockerfile security measures
1 parent 0e4781a commit 66a837a

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

‎src/mpa/rspamd/Dockerfile‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM debian:12.10-slim
22

33
RUN apt-get update && \
4-
apt-get install -y lsb-release wget gpg ruby nginx netcat-openbsd procps && \
4+
apt-get install -y --no-install-recommends lsb-release wget gpg ruby nginx netcat-openbsd procps && \
55
rm -rf /var/lib/apt/lists/*
66
RUN mkdir -p /etc/apt/keyrings
77
RUN wget -O- https://rspamd.com/apt-stable/gpg.key | gpg --dearmor | tee /etc/apt/keyrings/rspamd.gpg > /dev/null
@@ -28,6 +28,11 @@ COPY start.sh /start.sh
2828

2929
RUN chmod +x /start.sh
3030

31+
# Ensure _rspamd user can write nginx config at runtime
32+
RUN chown -R _rspamd:_rspamd /etc/nginx
33+
3134
ENV PORT=8010
3235

36+
USER _rspamd
37+
3338
CMD ["/start.sh"]

‎src/mpa/tests/Dockerfile‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ COPY requirements.txt .
66
RUN pip install --no-cache-dir -r requirements.txt
77

88
COPY . .
9+
10+
# Ensure nobody user can write pytest cache files
11+
RUN chown -R nobody:nogroup /app
12+
13+
USER nobody

‎src/socks-proxy/Dockerfile‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ ARG DANTE_VER=1.4.4
44
ARG DANTE_URL=https://www.inet.no/dante/files/dante-$DANTE_VER.tar.gz
55
ARG DANTE_SHA256=1973c7732f1f9f0a4c0ccf2c1ce462c7c25060b25643ea90f9b98f53a813faec
66

7-
RUN <<EOR
8-
apt-get update
9-
apt-get install -y build-essential curl
10-
EOR
7+
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates build-essential curl && rm -rf /var/lib/apt/lists/*
118

129
RUN <<EOR
1310
set -eu
@@ -26,5 +23,7 @@ COPY --from=base /usr/local/sbin/sockd /usr/local/sbin/sockd
2623

2724
COPY --chmod=0755 entrypoint.sh /entrypoint.sh
2825

26+
USER nobody
27+
2928
ENTRYPOINT ["/entrypoint.sh"]
3029
CMD ["/usr/local/sbin/sockd"]

‎src/socks-proxy/tests/Dockerfile‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,10 @@ RUN pip install --no-cache-dir -r requirements.txt
1515
# Copy test files
1616
COPY . .
1717

18+
# Ensure nobody user can write pytest cache and coverage files
19+
RUN chown -R nobody:nogroup /app
20+
21+
USER nobody
22+
1823
# Default command (can be overridden)
1924
CMD ["pytest", "-v"]

0 commit comments

Comments
 (0)