-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (31 loc) · 1.27 KB
/
Dockerfile
File metadata and controls
41 lines (31 loc) · 1.27 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
# 1. This tells docker to use the Rust official image
FROM rust:1.88 as builder
# Install ALSA development libraries for rodio
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libasound2-dev \
&& rm -rf /var/lib/apt/lists/*
# 2. Copy dependency files first for better layer caching
COPY Cargo.toml Cargo.lock ./
# 3. Create a dummy src directory to cache dependencies
RUN mkdir src && echo "fn main() {}" > src/main.rs && \
cargo build --release && \
rm -rf src
# 4. Copy the actual source code
COPY src/ ./src/
# 5. Build your program for release
RUN cargo build --release
FROM debian:bookworm-slim AS runner
# Install SSL libraries required by reqwest and ALSA runtime libraries for rodio
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libssl3 \
libasound2 \
ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Configure ALSA to use a null device to suppress error messages when no audio hardware is available
# This prevents ALSA from spamming stderr with errors in Docker containers
RUN echo 'pcm.!default { type null }' > /etc/asound.conf && \
echo 'ctl.!default { type null }' >> /etc/asound.conf
COPY --from=builder /target/release/chess-tui /usr/bin/chess-tui
ENTRYPOINT [ "/usr/bin/chess-tui" ]