-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
64 lines (48 loc) · 1.89 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
FROM debian:12 as build-env
WORKDIR /src
# Install dependencies
RUN apt-get update && \
apt-get install -y 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/base-api-types/src
RUN mkdir -p ./crates/postgres-docker-utils/src
RUN mkdir -p ./crates/tx-sitter-client/src
# Copy only Cargo.toml for better caching
COPY .cargo/config.toml .cargo/config.toml
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
COPY ./crates/base-api-types/Cargo.toml ./crates/base-api-types/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
RUN echo "fn main() {}" > ./src/main.rs
RUN echo "fn main() {}" > ./crates/base-api-types/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
# Prebuild dependencies
RUN cargo fetch
RUN cargo build --release --no-default-features
# Copy all the source files
# .dockerignore ignores the target dir
COPY . .
# Build the binary
RUN cargo fetch
RUN cargo build --release --no-default-features
# Make sure it runs
RUN /src/target/release/tx-sitter --version
# cc variant because we need libgcc and others
FROM gcr.io/distroless/cc-debian12:nonroot
# Copy the tx-sitter binary
COPY --from=build-env --chown=0:10001 --chmod=010 /src/target/release/tx-sitter /bin/tx-sitter
ENTRYPOINT [ "/bin/tx-sitter" ]