fix(ci): build single Rust service with workspace-safe Dockerfile
This commit is contained in:
parent
c237c417ef
commit
7aeaeb18ab
1 changed files with 24 additions and 2 deletions
|
|
@ -7,7 +7,7 @@ FROM rust:alpine AS builder
|
||||||
ARG SERVICE_NAME
|
ARG SERVICE_NAME
|
||||||
|
|
||||||
# Install deps
|
# Install deps
|
||||||
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && \
|
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
|
||||||
rustup target add x86_64-unknown-linux-musl
|
rustup target add x86_64-unknown-linux-musl
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
@ -16,11 +16,33 @@ WORKDIR /app
|
||||||
COPY Cargo.toml Cargo.lock ./
|
COPY Cargo.toml Cargo.lock ./
|
||||||
COPY crates/ ./crates/
|
COPY crates/ ./crates/
|
||||||
|
|
||||||
# Copy the specific service
|
# Copy only the target service source (fast path for matrix builds).
|
||||||
COPY apps/${SERVICE_NAME}/ ./apps/${SERVICE_NAME}/
|
COPY apps/${SERVICE_NAME}/ ./apps/${SERVICE_NAME}/
|
||||||
|
|
||||||
|
# Restrict workspace members to the selected service + shared crates.
|
||||||
|
# This avoids requiring every `apps/*` manifest while preserving workspace deps.
|
||||||
|
RUN awk -v svc="${SERVICE_NAME}" '\
|
||||||
|
BEGIN { in_members = 0 } \
|
||||||
|
/^members = \[/ { \
|
||||||
|
print "members = ["; \
|
||||||
|
print " \"apps/" svc "\","; \
|
||||||
|
print " \"crates/contracts\","; \
|
||||||
|
print " \"crates/db\","; \
|
||||||
|
print " \"crates/auth\","; \
|
||||||
|
print " \"crates/storage\","; \
|
||||||
|
print " \"crates/cache\","; \
|
||||||
|
print " \"crates/email\""; \
|
||||||
|
in_members = 1; \
|
||||||
|
next; \
|
||||||
|
} \
|
||||||
|
in_members && /^\]/ { in_members = 0; print "]"; next } \
|
||||||
|
in_members { next } \
|
||||||
|
{ print }' Cargo.toml > Cargo.toml.tmp && mv Cargo.toml.tmp Cargo.toml
|
||||||
|
|
||||||
# Build with all optimizations
|
# Build with all optimizations
|
||||||
ENV RUSTFLAGS="-C target-feature=+crt-static -C link-arg=-s"
|
ENV RUSTFLAGS="-C target-feature=+crt-static -C link-arg=-s"
|
||||||
|
ENV OPENSSL_STATIC=1
|
||||||
|
ENV OPENSSL_DIR=/usr
|
||||||
RUN cargo build --release \
|
RUN cargo build --release \
|
||||||
--bin ${SERVICE_NAME} \
|
--bin ${SERVICE_NAME} \
|
||||||
--target x86_64-unknown-linux-musl
|
--target x86_64-unknown-linux-musl
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue