-
Notifications
You must be signed in to change notification settings - Fork 87
/
Dockerfile
37 lines (35 loc) · 1.22 KB
/
Dockerfile
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
# Build environment
FROM alpine AS build
RUN apk add --no-cache build-base
WORKDIR /src
COPY . .
# Hardening GCC opts taken from these sources:
# https://developers.redhat.com/blog/2018/03/21/compiler-and-linker-flags-gcc/
# https://security.stackexchange.com/q/24444/204684
ENV CFLAGS=" \
-static \
-O2 \
-flto \
-D_FORTIFY_SOURCE=2 \
-fstack-clash-protection \
-fstack-protector-strong \
-pipe \
-Wall \
-Werror=format-security \
-Werror=implicit-function-declaration \
-Wl,-z,defs \
-Wl,-z,now \
-Wl,-z,relro \
-Wl,-z,noexecstack \
"
RUN make darkhttpd \
&& strip darkhttpd
# Just the static binary
FROM scratch
WORKDIR /var/www/htdocs
COPY --from=build --chown=0:0 /src/darkhttpd /darkhttpd
COPY --chown=0:0 docker/passwd /etc/passwd
COPY --chown=0:0 docker/group /etc/group
EXPOSE 80
ENTRYPOINT ["/darkhttpd"]
CMD [".", "--chroot", "--uid", "nobody", "--gid", "nobody"]