generated from holaplex/hub-rust-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
80 lines (65 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
FROM rust:1.71.0-bookworm as chef
RUN cargo install cargo-chef --locked
WORKDIR /app
RUN apt-get update -y && \
apt-get install -y --no-install-recommends \
cmake \
g++ \
libsasl2-dev \
libssl-dev \
libudev-dev \
pkg-config \
protobuf-compiler \
&& \
rm -rf /var/lib/apt/lists/*
COPY ci/get-protoc.sh ./
RUN chmod +x get-protoc.sh
RUN /app/get-protoc.sh
FROM chef AS planner
COPY Cargo.* ./
COPY app app
COPY migration migration
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --recipe-path recipe.json
# Build application
COPY Cargo.* ./
COPY app app
COPY migration migration
FROM chef as development
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
# Build application
COPY Cargo.* ./
COPY app app
RUN cargo install cargo-watch
RUN cargo check --all
CMD ["cargo", "watch", "-x", "run --bin holaplex-hub-analytics"]
FROM builder AS builder-hub-analytics
RUN cargo build --release --bin holaplex-hub-analytics
FROM builder AS builder-migration
RUN cargo build --release --bin migration
FROM debian:bookworm-slim as base
WORKDIR /app
RUN apt-get update -y && \
apt-get install -y --no-install-recommends \
ca-certificates \
libpq5 \
libssl-dev \
&& \
rm -rf /var/lib/apt/lists/*
FROM base AS hub-analytics
ENV TZ=Etc/UTC
ENV APP_USER=runner
RUN groupadd $APP_USER \
&& useradd --uid 10000 -g $APP_USER $APP_USER \
&& mkdir -p bin
RUN chown -R $APP_USER:$APP_USER bin
USER 10000
COPY --from=builder-hub-analytics /app/target/release/holaplex-hub-analytics /usr/local/bin
CMD ["/usr/local/bin/holaplex-hub-analytics"]
FROM base AS migrator
COPY --from=builder-migration /app/target/release/migration /usr/local/bin
CMD ["/usr/local/bin/migration"]