-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
30 lines (27 loc) · 1.38 KB
/
Dockerfile
File metadata and controls
30 lines (27 loc) · 1.38 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
# syntax = docker/dockerfile:1
FROM rust:1.94-slim-trixie AS runtime
WORKDIR /usr/src
RUN --mount=type=cache,id=api:/var/cache/apt,target=/var/cache/apt \
--mount=type=cache,id=api:/var/lib/apt/lists,target=/var/lib/apt/lists \
apt-get update && apt-get install --no-install-recommends -y \
clang \
make \
&& rm -rf /var/lib/apt/lists/*
FROM runtime AS development
FROM runtime AS builder
RUN --mount=type=bind,source=crates,target=crates \
--mount=type=bind,source=Cargo.toml,target=Cargo.toml \
--mount=type=bind,source=Cargo.lock,target=Cargo.lock \
--mount=type=cache,id=api:/usr/local/cargo/registry,target=/usr/local/cargo/registry \
--mount=type=cache,id=api:/usr/src/target,target=/usr/src/target \
cargo build --release --no-default-features --features=vendored,server \
&& cp target/release/kanatrans /usr/local/bin/kanatrans \
&& mkdir -p /kanatrans/lib \
&& ldd /usr/local/bin/kanatrans | awk '/=>/{ print $3 }' | xargs cp --dereference --target-directory=/kanatrans/lib
FROM scratch AS kanatrans
LABEL io.github.hexium310.kanatrans.app=kanatrans
LABEL org.opencontainers.image.source=https://github.com/hexium310/kanatrans
COPY --link --from=builder /kanatrans/lib/* /lib/
COPY --link --from=builder /lib64/ld-linux-x86-64.so* /lib64/
COPY --link --from=builder /usr/local/bin/kanatrans /usr/local/bin/kanatrans
ENTRYPOINT ["kanatrans", "--serve"]