forked from celo-org/snark-setup-operator
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
68 lines (47 loc) · 2.33 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
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
66
67
68
# Dockerfile format ripped from here: https://shaneutt.com/blog/rust-fast-small-docker-image-builds/
# ------------------------------------------------------------------------------
# Cargo Build Stage
# ------------------------------------------------------------------------------
FROM rust:latest as cargo-build
RUN apt-get update
RUN apt-get install musl-tools -y
RUN rustup target add x86_64-unknown-linux-musl
WORKDIR /usr/src/main
COPY Cargo.lock Cargo.lock
COPY Cargo.toml Cargo.toml
RUN mkdir src/
RUN echo "fn main() {println!(\"if you see this, the build cache was invalidated\")}" > src/main.rs
RUN cargo build --release --target=x86_64-unknown-linux-musl
RUN rm -f target/x86_64-unknown-linux-musl/release/deps/snark-setup-operator*
COPY src ./src
COPY LICENSE .
COPY Cargo.lock .
COPY README.md .
RUN cargo build --release --bin generate --target=x86_64-unknown-linux-musl
RUN cargo build --release --bin contribute --target=x86_64-unknown-linux-musl
RUN cargo build --release --bin control --target=x86_64-unknown-linux-musl
RUN cargo build --release --bin monitor --target=x86_64-unknown-linux-musl
RUN cargo build --release --bin new_ceremony --target=x86_64-unknown-linux-musl
RUN cargo build --release --bin verify_transcript --target=x86_64-unknown-linux-musl
# ------------------------------------------------------------------------------
# Final Stage
# ------------------------------------------------------------------------------
FROM alpine:latest
RUN addgroup -g 1000 main
RUN adduser -D -s /bin/sh -u 1000 -G main main
WORKDIR /home/main/bin/
COPY --from=cargo-build /usr/src/main/target/x86_64-unknown-linux-musl/release/contribute .
COPY --from=cargo-build /usr/src/main/target/x86_64-unknown-linux-musl/release/generate .
COPY --from=cargo-build /usr/src/main/target/x86_64-unknown-linux-musl/release/control .
COPY --from=cargo-build /usr/src/main/target/x86_64-unknown-linux-musl/release/monitor .
COPY --from=cargo-build /usr/src/main/target/x86_64-unknown-linux-musl/release/new_ceremony .
COPY --from=cargo-build /usr/src/main/target/x86_64-unknown-linux-musl/release/verify_transcript .
RUN chown main:main contribute
RUN chown main:main generate
RUN chown main:main control
RUN chown main:main monitor
RUN chown main:main new_ceremony
RUN chown main:main verify_transcript
RUN chown main:main .
USER main
CMD ["./contribute"]