Skip to content

Commit 71506ab

Browse files
fmartankyleo
andcommitted
Add Dockerfile
Co-authored-by: Leo Nash <hello@leonash.net>
1 parent c4c26ba commit 71506ab

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

rust/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target/

rust/Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Build stage
2+
FROM rust:1.91-bookworm AS builder
3+
4+
WORKDIR /build
5+
6+
# Copy workspace files
7+
COPY Cargo.toml Cargo.lock ./
8+
COPY rustfmt.toml ./
9+
10+
# Copy all workspace members
11+
COPY server ./server
12+
COPY api ./api
13+
COPY impls ./impls
14+
COPY auth-impls ./auth-impls
15+
16+
# Build the application in release mode
17+
RUN cargo build --locked --release --bin vss-server
18+
19+
# Runtime stage
20+
FROM debian:bookworm-slim
21+
22+
# Install runtime dependencies and create an unprivileged runtime user
23+
RUN apt-get update && \
24+
apt-get install -y --no-install-recommends \
25+
ca-certificates \
26+
libssl3 \
27+
&& rm -rf /var/lib/apt/lists/* \
28+
&& groupadd --system vss \
29+
&& useradd --system --gid vss --home-dir /app --shell /usr/sbin/nologin vss \
30+
&& mkdir -p /app \
31+
&& chown vss:vss /app
32+
33+
WORKDIR /app
34+
35+
# Copy the compiled binary from builder
36+
COPY --from=builder --chown=vss:vss /build/target/release/vss-server /app/vss-server
37+
38+
# Copy default configuration file
39+
COPY --chown=vss:vss server/vss-server-config.toml /app/vss-server-config.toml
40+
41+
USER vss:vss
42+
43+
ENV VSS_BIND_ADDRESS=0.0.0.0:8080
44+
45+
EXPOSE 8080
46+
47+
# Run the server with the config file
48+
CMD ["/app/vss-server", "/app/vss-server-config.toml"]

0 commit comments

Comments
 (0)