-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathalpine.Dockerfile
More file actions
56 lines (41 loc) · 1.7 KB
/
alpine.Dockerfile
File metadata and controls
56 lines (41 loc) · 1.7 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
45
46
47
48
49
50
51
52
53
54
55
56
# Usage:
# docker buildx build -f alpine.Dockerfile -t image:tag --build-arg='ARCH=x86_64' --platform linux/amd64 .
# docker buildx build -f alpine.Dockerfile -t image:tag --build-arg='ARCH=aarch64' --platform linux/arm64 .
ARG ARCH=x86_64
FROM messense/rust-musl-cross:${ARCH}-musl AS builder
ARG ARCH=x86_64
ARG APP_NAME=nittei
ARG RUST_VERSION=1.95.0
# Install and set the specific Rust version
RUN rustup install ${RUST_VERSION} && rustup default ${RUST_VERSION}
# Install the musl target for the correct architecture
RUN rustup target add ${ARCH}-unknown-linux-musl
# Verify the Rust and target setup
RUN rustc --version && rustup show
# Copy source code
COPY ./Cargo.toml ./Cargo.lock ./
COPY ./crates ./crates
COPY ./bins ./bins
COPY ./clients/rust ./clients/rust
# Build application
RUN cargo build --release --target ${ARCH}-unknown-linux-musl && \
cp ./target/${ARCH}-unknown-linux-musl/release/${APP_NAME} /${APP_NAME}
# Build migrate binary
RUN cargo build --release --bin nittei-migrate --target ${ARCH}-unknown-linux-musl && \
cp ./target/${ARCH}-unknown-linux-musl/release/nittei-migrate /nittei-migrate
#Create a new stage with a minimal image
FROM alpine:3.23.4
# Set the git repository url and commit hash for DD
ARG GIT_REPO_URL
ARG GIT_COMMIT_HASH
ENV DD_GIT_REPOSITORY_URL=${GIT_REPO_URL}
ENV DD_GIT_COMMIT_SHA=${GIT_COMMIT_HASH}
ENV DD_SOURCE_CODE_PATH_MAPPING="/app/nittei/bins:/bins,/app/nittei/crates:/crates"
# Set the backtrace level by default to 1
ARG RUST_BACKTRACE=1
ENV RUST_BACKTRACE=${RUST_BACKTRACE}
ARG APP_NAME=nittei
ENV APP_NAME=${APP_NAME}
COPY --from=builder /${APP_NAME} /${APP_NAME}
COPY --from=builder /nittei-migrate /nittei-migrate
CMD ["/bin/sh", "-c", "exec /${APP_NAME}"]