-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
55 lines (39 loc) · 1.5 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
# Generic Dockerfile which can build any sushii-2 packages
# docker build --build-arg TARGET=sushii-2 .
FROM rust:1.62 as build
# Which package to build
ARG TARGET
WORKDIR /usr/src/sushii
# Create a new empty shell project
RUN USER=root cargo new ${TARGET} --bin
# Copy over root manifests, Cargo.lock
COPY ./Cargo.lock ./Cargo.toml ./
# Copy local dependencies, this might be unused by some
COPY ./sushii-model ./sushii-model
# switch to target workspace project to run following commands in target dir
WORKDIR /usr/src/sushii/${TARGET}
# If there's a build.rs required in Cargo.toml
# This requires first file to always exist, 2nd one with * as optional
COPY ./${TARGET}/Cargo.toml ./${TARGET}/build.rs* ./
# Cache dependencies
RUN cargo build --release
RUN rm src/*.rs
# Copy source tree, migrations, queries, sqlx data
COPY ./${TARGET}/ ./
# Remove dummy compiled files (in workspace root)
RUN rm ../target/release/deps/*sushii*
# Test and build the actual package
RUN cargo test --release --locked
RUN cargo build --release --locked
## Final base image with only the built binary
FROM debian:bullseye-slim
ARG TARGET
ENV TARGET ${TARGET}
WORKDIR /config
# Fix sentry HTTPS calls with ca-certificates:
# https://github.com/getsentry/sentry-rust/issues/239
RUN apt-get update && apt-get install -y libssl-dev ca-certificates && rm -rf /var/lib/apt/lists/*
# Target dir is still in workspace root
COPY --from=build /usr/src/sushii/target/release/${TARGET} /usr/local/bin/${TARGET}
EXPOSE 9888
ENTRYPOINT "${TARGET}"