-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (54 loc) · 1.64 KB
/
Dockerfile
File metadata and controls
70 lines (54 loc) · 1.64 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# ========================
# Build Stage
# ========================
FROM rust:1.90.0-alpine3.22 AS builder
# Build platform argument (x86_64 or aarch64) (default: x86_64)
ARG TARGETARCH
RUN echo "TARGETARCH: $TARGETARCH"
# Install build dependencies, including static OpenSSL libraries
RUN apk add --no-cache \
musl-dev \
openssl-dev \
openssl-libs-static \
pkgconfig \
build-base \
curl \
git
# Set PATH only if we installed the cross compiler (will be empty string for x86)
ENV PATH="$(cat /tmp/musl_cross_path):$PATH"
# Set environment variables for static linking with OpenSSL
ENV OPENSSL_STATIC=yes
ENV OPENSSL_LIB_DIR=/usr/lib
ENV OPENSSL_INCLUDE_DIR=/usr/include
# Set the working directory
WORKDIR /usr/src/app
# Copy over Cargo.toml and Cargo.lock for dependency caching
COPY Cargo.toml Cargo.lock ./
# Copy over all the source code
COPY . .
# Build the project in release mode for the MUSL target
RUN cargo build --release --bin nexusd
# Strip the binaries to reduce size
RUN strip target/release/nexusd
# ========================
# Runtime Stage
# ========================
FROM alpine:3.22
ARG TARGETARCH
# Install runtime dependencies
RUN apk add --no-cache ca-certificates \
imagemagick \
imagemagick-webp \
imagemagick-heic \
imagemagick-svg \
imagemagick-jpeg \
imagemagick-tiff \
imagemagick-raw
# Copy the compiled binaries from the builder stage
COPY --from=builder /usr/src/app/target/release/nexusd /usr/local/bin/nexusd
# Set the working directory
WORKDIR /usr/local/bin
# Expose the port the service listens on
EXPOSE 8080
# Set the default command to run the service binary
CMD ["nexusd"]