Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
85 lines (67 loc) · 2.83 KB
/
Copy pathDockerfile
File metadata and controls
85 lines (67 loc) · 2.83 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Stage 1: Build
FROM rust:1.93.1-bookworm AS builder
# Install clippy and rustfmt first to allow the persistent cache to cover them
RUN rustup component add clippy rustfmt
# Install build dependencies
RUN apt-get update && apt-get install -y \
clang \
pkg-config \
libssl-dev \
wget \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/sashiko
COPY . .
## Download Linux kernel bundle (~2.5GB) during build time
## This makes the image large but ensures fast startup in Cloud Run
#RUN wget -c https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/clone.bundle -O /usr/src/sashiko/linux-kernel.bundle
# Build for release with persistent cache
# Note: some Docker versions could run into bugs when a later stage accesses a
# cached directory from previous stages, so copy the binaries into a separate
# directory first.
RUN --mount=type=cache,target=/usr/src/sashiko/target/ \
--mount=type=cache,target=/usr/local/cargo/git/db/ \
--mount=type=cache,target=/usr/local/cargo/registry/ \
cargo build --release && \
mkdir -p /app && \
cd /usr/src/sashiko/target/release/ && \
cp -a sashiko sashiko-cli /app
# Stage 2: Runtime
FROM debian:bookworm-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
procps \
tini \
git \
libssl3 \
ca-certificates \
wget \
curl \
&& rm -rf /var/lib/apt/lists/*
# Configure Git to rewrite git:// to https:// for hosts known to support Smart HTTP
RUN git config --global url."https://git.kernel.org/".insteadOf "git://git.kernel.org/" && \
git config --global url."https://github.com/".insteadOf "git://github.com/" && \
git config --global url."https://gitlab.com/".insteadOf "git://gitlab.com/" && \
git config --global url."https://gitlab.freedesktop.org/".insteadOf "git://gitlab.freedesktop.org/"
WORKDIR /app
# Copy binaries from builder
COPY --from=builder /app /usr/local/bin
## Copy the pre-downloaded kernel bundle
#COPY --from=builder /usr/src/sashiko/linux-kernel.bundle /opt/linux-kernel.bundle
# Copy default settings and assets
COPY Settings.toml /app/Settings.toml
COPY projects /app/projects
RUN ln -s /app/projects/linux/mailing_lists.toml /app/email_policy.toml
COPY static /app/static
# Copy entrypoint script
COPY scripts/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Data directory for database, worktrees and logs
RUN mkdir -p /data/db /data/logs /tmp/sashiko_worktrees /app/third_party/linux
# Default environment variables
ENV SASHIKO__DATABASE__URL=/data/db/sashiko.db \
SASHIKO__GIT__REPOSITORY_PATH=/app/third_party/linux \
SASHIKO__REVIEW__WORKTREE_DIR=/tmp/sashiko_worktrees \
SASHIKO__SERVER__HOST=0.0.0.0 \
SASHIKO__SERVER__PORT=8080
EXPOSE 8080
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/docker-entrypoint.sh"]