-
Notifications
You must be signed in to change notification settings - Fork 10
/
Dockerfile
41 lines (32 loc) · 1.08 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
FROM rust:1.81.0-slim-bookworm as builder
WORKDIR /usr/src/starboard
# force cargo to update the crates.io index.
# putting this first means that the cache won't be
# invalidated if src/migrations/cargo.toml/cargo.lock
# is changed.
RUN cargo search --limit 1
# install pkg-config (required for reqwest dependency)
RUN apt-get update
RUN apt-get install -y pkg-config libssl-dev
# doing this allows caching of compiled dependencies
COPY Cargo.toml Cargo.toml
COPY Cargo.lock Cargo.lock
RUN mkdir src
RUN echo "fn main() { dbg!(1); }" > src/main.rs
RUN cargo build --release
RUN rm -r src && rm target/release/starboard
# copy stuff over to the image that we need
COPY build.rs build.rs
COPY ./src ./src
COPY ./migrations ./migrations
COPY sqlx-data.json sqlx-data.json
# install starboard
RUN cargo build --release
# get rid of cargo
FROM debian:bookworm-slim
# install certificates
RUN apt-get update && apt-get install -y ca-certificates
# copy starboard over from the builder
COPY --from=builder /usr/src/starboard/target/release/starboard /usr/local/bin/starboard
# run starboard
CMD ["starboard"]