-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
harden.dockerfile
65 lines (50 loc) · 1.52 KB
/
harden.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
FROM alpine:3.19 AS permissions-giver
WORKDIR /out
FROM alpine:3.19 AS submodule-initializor
# Install git
RUN apk --no-cache add git
WORKDIR /out
COPY .git .git
COPY lib lib
COPY .gitmodules .
RUN git rev-parse --short=8 HEAD > /rev
# Get submodules and remove unneccesary files
RUN git submodule update --init --recursive \
&& rm -rf `find . -type d -name ".git"` \
&& rm .gitmodules
FROM alpine:3.19 AS builder
# Install cmake
RUN apk --no-cache add cmake clang clang-dev make gcc g++ libc-dev linux-headers
# Build
COPY include include
COPY src src
COPY Installer.iss.in .
COPY CMakeLists.txt .
COPY cmake cmake
COPY --from=submodule-initializor /out .
COPY --from=submodule-initializor /rev .
RUN cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DARK_BUILD_EXE=On -DARK_ENABLE_SYSTEM=Off -DARK_COMMIT="$(cat rev)" \
&& cmake --build build --target arkscript -- -j $(nproc)
FROM alpine:3.19 AS organizer
# Files needed to run Ark
WORKDIR /out/ark
COPY --from=builder build build
COPY --from=builder include include
COPY --from=builder lib lib
FROM alpine:3.19 AS runner
# Install cmake
RUN apk --no-cache add cmake
RUN apk add --update duo_unix
# Install Ark
COPY --from=organizer /out/ark .
RUN cmake --install build --config Release
ENV LD_LIBRARY_PATH=/usr/local/lib64
ENV ARKSCRIPT_PATH=/usr/local/lib/Ark
COPY harden_docker.sh /usr/sbin/harden.sh
RUN chmod u+x /usr/sbin/harden.sh
RUN /usr/sbin/harden.sh
USER user
WORKDIR /home/user
ENTRYPOINT [ "arkscript" ]