-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (40 loc) · 1.14 KB
/
Copy pathDockerfile
File metadata and controls
53 lines (40 loc) · 1.14 KB
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
FROM rust:1.92.0-slim AS builder
ARG GIT_REV
ENV GIT_REV=${GIT_REV}
WORKDIR /app
RUN apt-get update && apt-get install -y \
musl-tools \
clang \
libssl-dev \
pkg-config \
build-essential \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
RUN rustup target add x86_64-unknown-linux-musl
# Copy manifests
COPY Cargo.toml Cargo.lock ./
COPY test-utils/Cargo.toml test-utils/Cargo.toml
# test-utils won't actually be included in the final image
# Cache dependencies
RUN mkdir src && \
echo "fn main() {}" > src/main.rs && \
mkdir -p test-utils/src && \
echo "fn main() {}" > test-utils/src/main.rs && \
cargo build --locked --release && \
rm -rf src
# Copy source code
COPY . .
# Build the application
RUN cargo build --locked --release --target x86_64-unknown-linux-musl
# Runtime stage
FROM scratch
WORKDIR /app
# Copy SSL certificates
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# Copy the binary
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/backup-service /app/backup-service
# Set the entrypoint
USER 100
EXPOSE 8000
EXPOSE 9090
ENTRYPOINT ["/app/backup-service"]