-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
63 lines (52 loc) · 1.5 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
# Builder stage
FROM golang:1.22-bookworm AS builder
ARG TARGETPLATFORM
WORKDIR /app
# System dependencies layer
RUN apt-get update && apt-get install -y \
gcc-aarch64-linux-gnu \
libc6-dev-arm64-cross \
g++-x86-64-linux-gnu \
libc6-dev-amd64-cross \
build-essential
# Rust installation layer
ENV RUST_VERSION=1.82.0
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- -y --default-toolchain ${RUST_VERSION} --profile minimal
ENV PATH="/root/.cargo/bin:${PATH}"
# Pre-compile Rust shared library
COPY Makefile ./
COPY mk ./mk/
COPY . .
RUN make rust
# Go dependencies layer
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
# Source code layer
COPY . .
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
make install
# Release stage
FROM debian:bookworm-slim AS release
WORKDIR /app
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
jq \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
COPY --from=builder /app/.lib/libstork.so /usr/local/lib/
ENV LD_LIBRARY_PATH=/usr/local/lib
# Ensure SERVICE is defined
ARG SERVICE
ENV SERVICE=${SERVICE}
RUN if [ -z "$SERVICE" ]; then echo "SERVICE argument is not defined"; exit 1; fi
COPY --from=builder /app/.bin/${SERVICE} /app/
COPY docker-entrypoint.sh /app/
COPY version.txt /app/
RUN chmod +x /app/docker-entrypoint.sh
ENTRYPOINT ["/app/docker-entrypoint.sh"]
CMD []