-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (45 loc) · 1.9 KB
/
Dockerfile
File metadata and controls
64 lines (45 loc) · 1.9 KB
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
ARG BUILDPLATFORM
ARG WEBPKI_ROOTS=false
FROM --platform=$BUILDPLATFORM bitshock/linux-musl-rust:1.91.1 AS builder
WORKDIR /app
COPY Cargo.toml ./
COPY Cargo.lock ./
COPY server/src ./server/src
COPY server/Cargo.toml ./server/Cargo.toml
COPY service-api/src ./service-api/src
COPY service-api/Cargo.toml ./service-api/Cargo.toml
COPY service/src ./service/src
COPY service/Cargo.toml ./service/Cargo.toml
COPY components/src ./components/src
COPY components/Cargo.toml ./components/Cargo.toml
COPY components/proto ./components/proto
COPY components/build.rs ./components/build.rs
COPY pingora/src ./pingora/src
COPY pingora/Cargo.toml ./pingora/Cargo.toml
COPY migration/src ./migration/src
COPY migration/Cargo.toml ./migration/Cargo.toml
COPY switchgear/src ./switchgear/src
COPY switchgear/Cargo.toml ./switchgear/Cargo.toml
COPY testing/Cargo.toml ./testing/Cargo-src.toml
RUN sed '/^\[dependencies\]/q' ./testing/Cargo-src.toml > ./testing/Cargo.toml
RUN mkdir -p ./testing/src && touch ./testing/src/lib.rs
ARG TARGETPLATFORM
RUN case ${TARGETPLATFORM} in \
"linux/amd64") echo "RUST_TARGET=x86_64-unknown-linux-musl" > /app/build.env ;; \
"linux/arm64") echo "RUST_TARGET=aarch64-unknown-linux-musl" > /app/build.env ;; \
*) echo "Unsupported platform: ${TARGETPLATFORM}" && exit 1 ;; \
esac
RUN . /app/build.env && \
cargo build --release \
--config /opt/rust/linux-musl-rust.toml \
--target ${RUST_TARGET} && \
cp /app/target/${RUST_TARGET}/release/swgr /app/swgr
FROM scratch AS webpki-roots-true
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
FROM scratch AS webpki-roots-false
FROM webpki-roots-$WEBPKI_ROOTS AS final
COPY --from=builder /app/swgr /usr/sbin/swgr
COPY server/config/persistence.yaml /etc/swgr/config.yaml
ENV RUST_LOG=info
CMD ["service", "--config", "/etc/swgr/config.yaml"]
ENTRYPOINT ["/usr/sbin/swgr"]