aboutsummaryrefslogtreecommitdiff
path: root/Dockerfile
blob: 0d55f14bb996c10eb28123f9610eb827dc5f8b8b (plain) (blame)
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
# syntax=docker/dockerfile:1.7

ARG RUSTC_VERSION=nightly-2025-01-21

FROM clux/muslrust:${RUSTC_VERSION} AS build

RUN rustup component add rust-src

WORKDIR /source

RUN cargo new locus

WORKDIR /source/locus

COPY amenadiel/ ./amenadiel/
COPY Cargo.toml Cargo.lock ./

RUN --mount=type=cache,target=/root/.cargo/registry \
  --mount=type=cache,target=/root/.cargo/git \
  cargo build --release -Zbuild-std

COPY .git ./.git
COPY content ./content
COPY src ./src
COPY build.rs ./build.rs
COPY yarte.toml ./yarte.toml

RUN find ./content -name "*.DS_Store" -delete
RUN --mount=type=cache,target=/root/.cargo/registry \
  --mount=type=cache,target=/root/.cargo/git \
  cargo build --release --bin locus
RUN set -eux; \
  bin_path="$(find /source/locus/target -type f -path '*/release/locus' | head -n 1)"; \
  test -n "${bin_path}"; \
  strip -s "${bin_path}"; \
  cp "${bin_path}" /source/locus/locus
RUN strip -s /source/locus/locus
RUN mkdir /new_tmp

FROM scratch AS runtime

WORKDIR /locus

COPY --from=build /source/locus/locus ./locus
COPY --from=build /source/locus/content ./content
COPY --from=build /new_tmp /tmp

EXPOSE 1965

ENTRYPOINT ["./locus"]