-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
70 lines (49 loc) · 1.79 KB
/
Dockerfile
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
ARG ICONS=no-icons
# BEGIN RUST BUILD
# chef
FROM docker.io/library/rust:1.84.0 AS chef
RUN rustup target add x86_64-unknown-linux-musl && \
apt-get update && \
apt-get install -y --no-install-recommends musl-tools=1.2.3-1 musl-dev=1.2.3-1 && \
rm -rf /var/lib/apt/lists/*
RUN cargo install cargo-chef
WORKDIR /usr/src
# planner
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
# Builder
FROM chef AS builder
COPY --from=planner /usr/src/recipe.json recipe.json
RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json
COPY . .
RUN cargo build --release --target x86_64-unknown-linux-musl --bin adbir
# END RUST BUILD
# BEGIN OPTIONAL ICON
# get dashboard-icons
FROM docker.io/curlimages/curl:8.11.1 AS dashboard-icons
WORKDIR /out
# hadolint ignore=DL4006
RUN curl -o- -L "https://github.com/walkxcode/dashboard-icons/archive/refs/heads/main.tar.gz" | tar xzf - -C /out && \
mv -v /out/dashboard-icons-main /out/icons
# dummy icons (none)
FROM docker.io/library/alpine:3.21.2 AS no-icons
RUN mkdir -vp /out/icons/png /out/icons/svg
# Create selectable intermediate stage based on desired icons
# hadolint ignore=DL3006
FROM ${ICONS} AS icons
# END OPTIONAL ICON
# darkhttpd webserver to generate and host the files
FROM docker.io/library/alpine:3.21.2
ENV UID 1000
ENV GID 1000
RUN apk add -U --no-cache darkhttpd=1.16-r0
WORKDIR /public
RUN chown ${UID}:${GID} /public
COPY entrypoint.sh /entrypoint.sh
COPY --from=builder --chown=${UID}:${GID} /usr/src/target/x86_64-unknown-linux-musl/release/adbir /usr/bin/adbir
COPY --from=icons --chown=${UID}:${GID} /out/icons/png /public/icons/png
COPY --from=icons --chown=${UID}:${GID} /out/icons/svg /public/icons/svg
USER ${UID}:${GID}
EXPOSE 8080
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]