-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
49 lines (34 loc) · 1.13 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
# Use a Rust base image
FROM rust:latest as builder
# Set the working directory to /app
WORKDIR /app
RUN apt-get update && apt-get install -y libsqlcipher-dev
# Copy over your Cargo.toml and Cargo.lock
COPY Cargo.toml Cargo.lock ./
# Create a dummy src/main.rs
RUN mkdir src && \
echo "fn main() {println!(\"Dummy main\");}" > src/main.rs
# Download and compile dependencies
RUN cargo build --release && \
rm -rf /app/target/release/.fingerprint/auth_service-*
# Remove the dummy main.rs
RUN rm src/main.rs
# Copy over your actual source code
COPY src ./src
# Rebuild the application, reusing the cached dependencies
RUN cargo build --release
# Use a minimal runtime image
FROM debian:buster-slim
RUN apt-get update && apt-get install -y libsqlcipher0
# Install SSL certificates
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Set the working directory to /app
WORKDIR /app
# Copy the compiled binary from the builder stage
COPY --from=builder /app/target/release/auth_service .
# Expose port 8080
EXPOSE 8080
# Start the server
CMD ["./auth_service"]