fix: add OpenSSL static linking for musl builds

Added openssl-libs-static and OPENSSL_STATIC=1 environment variable
to fix reqwest/native-tls compilation errors with musl target.

Changes:
- Install openssl-libs-static in builder
- Set OPENSSL_STATIC=1 and OPENSSL_DIR=/usr
- Ensures OpenSSL is statically linked for all services
This commit is contained in:
Ashwin Kumar 2026-04-09 11:59:57 +02:00
parent 5b4e8fe908
commit 73d167c333
18 changed files with 74 additions and 18 deletions

View file

@ -2,13 +2,16 @@ FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin catering_services --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime

View file

@ -2,13 +2,16 @@ FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin companies --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime

View file

@ -2,13 +2,16 @@ FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin cron --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime

View file

@ -2,13 +2,16 @@ FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin customers --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime

View file

@ -2,13 +2,16 @@ FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin developers --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime

View file

@ -2,13 +2,16 @@ FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin employees --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime

View file

@ -2,13 +2,16 @@ FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin fitness_trainers --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime

View file

@ -2,13 +2,18 @@ FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
# Install build dependencies including openssl for musl
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
# Build with OpenSSL static linking
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin gateway --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime

View file

@ -2,13 +2,16 @@ FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin graphic_designers --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime

View file

@ -2,13 +2,16 @@ FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin job_seekers --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime

View file

@ -2,13 +2,16 @@ FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin makeup_artists --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime

View file

@ -2,13 +2,16 @@ FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin payments --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime

View file

@ -2,13 +2,16 @@ FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin photographers --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime

View file

@ -2,13 +2,16 @@ FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin social_media_managers --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime

View file

@ -2,13 +2,16 @@ FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin tutors --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime

View file

@ -2,13 +2,16 @@ FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin ugc_content_creators --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime

View file

@ -2,13 +2,16 @@ FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin users --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime

View file

@ -2,13 +2,16 @@ FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin video_editors --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime