generated from recmo/rust-service-template
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathDockerfile
77 lines (61 loc) · 2.44 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
69
70
71
72
73
74
75
76
77
FROM debian:12 AS build-env
WORKDIR /src
# Install dependencies
RUN apt-get update && \
apt-get install -y git curl build-essential libssl-dev texinfo libcap2-bin pkg-config
# TODO: Use a specific version of rustup
# Install rustup
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
# Copy only rust-toolchain.toml for better caching
COPY ./rust-toolchain.toml ./rust-toolchain.toml
# Set environment variables
ENV PATH="/root/.cargo/bin:${PATH}"
ENV RUSTUP_HOME="/root/.rustup"
ENV CARGO_HOME="/root/.cargo"
# Install the toolchain
RUN rustup component add cargo
# TODO: Hacky but it works
RUN mkdir -p ./src
RUN mkdir -p ./crates/cognitoauth/src
RUN mkdir -p ./crates/micro-oz/src
RUN mkdir -p ./crates/oz-api/src
RUN mkdir -p ./crates/postgres-docker-utils/src
RUN mkdir -p ./crates/tx-sitter-client/src
RUN mkdir -p ./e2e_tests/scenarios/src
# Copy only Cargo.toml for better caching
COPY ./build.rs ./build.rs
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
COPY ./crates/cognitoauth/Cargo.toml ./crates/cognitoauth/Cargo.toml
COPY ./crates/micro-oz/Cargo.toml ./crates/micro-oz/Cargo.toml
COPY ./crates/oz-api/Cargo.toml ./crates/oz-api/Cargo.toml
COPY ./crates/postgres-docker-utils/Cargo.toml ./crates/postgres-docker-utils/Cargo.toml
COPY ./crates/tx-sitter-client/Cargo.toml ./crates/tx-sitter-client/Cargo.toml
COPY ./e2e_tests/scenarios/Cargo.toml ./e2e_tests/scenarios/Cargo.toml
RUN echo "fn main() {}" > ./src/main.rs
RUN echo "fn main() {}" > ./crates/cognitoauth/src/main.rs
RUN echo "fn main() {}" > ./crates/micro-oz/src/main.rs
RUN echo "fn main() {}" > ./crates/oz-api/src/main.rs
RUN echo "fn main() {}" > ./crates/postgres-docker-utils/src/main.rs
RUN echo "fn main() {}" > ./crates/tx-sitter-client/src/main.rs
RUN echo "fn main() {}" > ./e2e_tests/scenarios/src/main.rs
# Prebuild dependencies
RUN cargo fetch
RUN cargo build --release --workspace
# Copy all the source files
# .dockerignore ignores the target dir
COPY . .
# Build the sequencer
RUN cargo fetch
RUN cargo build --release
# cc variant because we need libgcc and others
FROM gcr.io/distroless/cc-debian12:nonroot
# Expose Prometheus
ENV PROMETHEUS="http://0.0.0.0:9998/metrics"
EXPOSE 9998/tcp
LABEL prometheus.io/scrape="true"
LABEL prometheus.io/port="9998"
LABEL prometheus.io/path="/metrics"
# Copy the sequencer binary
COPY --from=build-env --chown=0:10001 --chmod=454 /src/target/release/signup-sequencer /bin/signup-sequencer
ENTRYPOINT [ "/bin/signup-sequencer" ]