-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-proxy
36 lines (25 loc) · 971 Bytes
/
Dockerfile-proxy
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
ARG BINARY_NAME_DEFAULT=ctf-proxy
FROM clux/muslrust:stable as builder
RUN groupadd -g 10001 -r dockergrp && useradd -r -g dockergrp -u 10001 dockeruser
ARG BINARY_NAME_DEFAULT
ENV BINARY_NAME=$BINARY_NAME_DEFAULT
COPY Cargo.lock .
COPY Cargo.toml .
RUN mkdir src \
&& echo "fn main() {print!(\"Dummy main\");} // dummy file" > src/main.rs
RUN set -x && cargo build --target x86_64-unknown-linux-musl --release
RUN ["/bin/bash", "-c", "set -x && rm target/x86_64-unknown-linux-musl/release/deps/${BINARY_NAME//-/_}*"]
COPY src ./src
RUN set -x && cargo build --target x86_64-unknown-linux-musl --release
RUN mkdir -p /build-out
RUN set -x && cp target/x86_64-unknown-linux-musl/release/$BINARY_NAME /build-out/
FROM scratch
COPY --from=0 /etc/passwd /etc/passwd
USER dockeruser
ARG BINARY_NAME_DEFAULT
ENV BINARY_NAME=$BINARY_NAME_DEFAULT
COPY --from=builder /build-out/$BINARY_NAME /
COPY ./config.yml .
COPY .env .
COPY static ./static
CMD ["/ctf-proxy"]