forked from brunojppb/turbo-cache-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (37 loc) · 1.49 KB
/
Dockerfile
File metadata and controls
44 lines (37 loc) · 1.49 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
FROM alpine:3.23.4 AS ca-certificates
RUN apk add --no-cache ca-certificates
FROM --platform=$BUILDPLATFORM rust:alpine AS chef
WORKDIR /app
ENV PKGCONFIG_SYSROOTDIR=/
RUN apk add --no-cache musl-dev openssl-dev zig perl make && \
cargo install --locked cargo-zigbuild cargo-chef && \
rustup target add x86_64-unknown-linux-musl aarch64-unknown-linux-musl
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --recipe-path recipe.json \
--release \
--zigbuild \
--target x86_64-unknown-linux-musl --target aarch64-unknown-linux-musl
COPY . .
RUN cargo zigbuild -r \
--target x86_64-unknown-linux-musl --target aarch64-unknown-linux-musl && \
mkdir /app/linux && \
cp target/aarch64-unknown-linux-musl/release/decay /app/linux/arm64 && \
cp target/x86_64-unknown-linux-musl/release/decay /app/linux/amd64
FROM ghcr.io/rust-cross/cargo-zigbuild AS macos-builder
WORKDIR /app
RUN rustup target add x86_64-apple-darwin aarch64-apple-darwin
COPY . .
RUN cargo zigbuild --release --target universal2-apple-darwin && \
cp target/universal2-apple-darwin/release/decay /app/decay-darwin-universal
FROM scratch
WORKDIR /app
ARG TARGETPLATFORM
COPY --from=builder /app/${TARGETPLATFORM} /usr/bin/decay
COPY --from=ca-certificates /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# Allow the server to bind and be available to the local network
ENV HOST="0.0.0.0"
CMD ["/usr/bin/decay"]