-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (36 loc) · 1.17 KB
/
Dockerfile
File metadata and controls
52 lines (36 loc) · 1.17 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
# Build stage
FROM rust:1.86 AS builder
# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential libsqlite3-dev pkg-config && \
rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /mostro
# Copy Cargo.toml and Cargo.lock to leverage Docker cache
COPY Cargo.toml Cargo.lock ./
RUN cargo fetch
# Copy source code
COPY . .
# Build the project in release mode
RUN cargo build --release
# Production stage
FROM debian:bookworm-slim
# Install dependencies
RUN apt-get update && apt-get install -y --reinstall ca-certificates
# Add a non-root user
RUN useradd -m mostrouser
# Copy built binary from build stage
COPY --from=builder /mostro/target/release/mostrod /usr/local/bin/mostrod
WORKDIR /home/mostrouser
# Default config for start.sh to copy into /config when missing (DB created at startup)
RUN mkdir -p /mostro
COPY ./settings.tpl.toml /mostro/settings.toml
RUN chown -R mostrouser:mostrouser /mostro
# Copy start script
COPY ./docker/start.sh ./start.sh
RUN chmod +x ./start.sh
RUN chown -R mostrouser:mostrouser /home/mostrouser
# Switch to non-root user
USER mostrouser
# Start mostro
CMD ["./start.sh"]