-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (48 loc) · 1.66 KB
/
Copy pathDockerfile
File metadata and controls
62 lines (48 loc) · 1.66 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
54
55
56
57
58
59
60
61
62
# syntax=docker/dockerfile:1.26
# Use the official Rust image as the builder stage
FROM rust:1.97-slim AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Set the working directory
WORKDIR /usr/src/lynx
# Copy the entire project
COPY . .
# Build the application. BuildKit persists only this trusted build cache between
# CI runs; Cargo still validates every dependency and source input itself. Copy
# the final binary outside the mount because mount contents never enter a layer.
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/usr/src/lynx/target \
cargo build --release --locked && \
cp target/release/lynx /tmp/lynx
# Use a minimal image for the final stage
FROM debian:trixie-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN groupadd --gid 1000 lynx && \
useradd --uid 1000 --gid 1000 --shell /bin/bash --create-home lynx
# Environment variables (see .env.example for details)
ENV DATABASE_BACKEND=sqlite \
DATABASE_URL=sqlite:///home/lynx/lynx.db \
API_HOST=0.0.0.0 \
API_PORT=8080 \
REDIRECT_HOST=0.0.0.0 \
REDIRECT_PORT=3000 \
AUTH_MODE=none
# Copy the built binary from the builder stage
COPY --from=builder /tmp/lynx /opt/lynx
# Set the user
USER lynx
# Create working directory for database
WORKDIR /home/lynx
# Expose the API and redirect server ports
EXPOSE 8080 3000
# Set the entrypoint
ENTRYPOINT ["/opt/lynx"]