Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (36 loc) · 2.39 KB
/
Copy pathDockerfile
File metadata and controls
59 lines (36 loc) · 2.39 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
# syntax=docker/dockerfile:1
FROM lukemathwalker/cargo-chef:latest-rust-1.99.0-alpine AS chef
WORKDIR /work
ARG FLAGS="-C debuginfo=0 -C codegen-units=1 -C opt-level=3 -C link-arg=-Wl,--icf=safe -C linker-plugin-lto -C lto=thin -C embed-bitcode"
ENV RUSTFLAGS="-C linker=clang-23 -C link-arg=-fuse-ld=lld $FLAGS"
FROM chef AS utils
RUN RUSTFLAGS="-C opt-level=0" cargo install sqlx-cli --no-default-features --features mysql,rustls --locked
FROM chef AS dependencies
RUN apk add --no-cache ncurses-dev ncurses-static zlib-dev zlib-static zstd-dev zstd-static llvm23-static llvm23-dev git mariadb mariadb-client musl-dev llvm23 clang23 clang23-static lld23 curl btrfs-progs-dev --repository=https://dl-cdn.alpinelinux.org/alpine/edge/main
FROM dependencies AS mariadb
RUN mariadb-install-db --user=root --ldata=/var/lib/mysql
RUN echo "USE mysql;FLUSH PRIVILEGES ;GRANT ALL ON *.* TO 'root'@'%' identified by '' WITH GRANT OPTION ;GRANT ALL ON *.* TO 'root'@'localhost' identified by '' WITH GRANT OPTION ;SET PASSWORD FOR 'root'@'localhost'=PASSWORD('') ;DROP DATABASE IF EXISTS test ;FLUSH PRIVILEGES ;" mariadbd --user=root --bootstrap --verbose=0 --skip-name-resolve --skip-networking=0
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM dependencies AS builder
RUN echo '#!/bin/ash' > /llvm-config-static.sh && echo 'if [[ "$1" == "--libs" ]]; then echo "$(/usr/bin/llvm-config-23 "$@" "--link-static")" "-lzstd"; else /usr/bin/llvm-config-23 "$@"; fi' >> /llvm-config-static.sh && chmod +x /llvm-config-static.sh
ENV LLVM_CONFIG_PATH="/llvm-config-static.sh"
COPY --from=planner /work/recipe.json recipe.json
ARG PREPARE_FEATURES="ci"
RUN cargo chef cook --release --recipe-path recipe.json --no-default-features --features "$PREPARE_FEATURES" --bin daemon --target x86_64-unknown-linux-musl
COPY --from=utils /usr/local/cargo/bin/cargo-sqlx /usr/local/cargo/bin/cargo-sqlx
COPY --from=mariadb /var/lib/mysql /var/lib/mysql
COPY . .
ARG FEATURES="ci"
# build
RUN FEATURES="$FEATURES" ./scripts/docker/build_daemon.sh
FROM alpine:latest AS runtime
RUN ln -sf /bin/daemon /usr/bin/daemon
RUN mkdir -p /var/lib/novium_daemon && chown 25335:25335 /var/lib/novium_daemon
WORKDIR /var/lib/novium_daemon
STOPSIGNAL SIGINT
EXPOSE 443
# Copy the binary directly to bin directory (/bin)
COPY --from=builder /work/target/x86_64-unknown-linux-musl/release/daemon /bin/daemon
ENTRYPOINT ["/bin/daemon"]