-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (33 loc) · 1.32 KB
/
Copy pathDockerfile
File metadata and controls
42 lines (33 loc) · 1.32 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
# Multi-stage Dockerfile for yamldap
# This builds the binary from source for multi-platform support
# Build stage
FROM rust:1.87 AS builder
# Install musl tools for static linking
RUN apt-get update && \
apt-get install -y musl-tools && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
COPY src ./src
# Detect target platform and build accordingly
ARG TARGETPLATFORM
RUN case "$TARGETPLATFORM" in \
"linux/amd64") RUST_TARGET="x86_64-unknown-linux-musl" ;; \
"linux/arm64") RUST_TARGET="aarch64-unknown-linux-musl" ;; \
*) echo "Unsupported platform: $TARGETPLATFORM" && exit 1 ;; \
esac && \
rustup target add $RUST_TARGET && \
RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target $RUST_TARGET && \
cp target/$RUST_TARGET/release/yamldap /yamldap
# Runtime stage - using scratch (empty image)
FROM scratch
# Link container to GitHub repository
LABEL org.opencontainers.image.source=https://github.com/rvben/yamldap
LABEL org.opencontainers.image.description="YamlDAP - A functional LDAP server that serves directory data from YAML files"
LABEL org.opencontainers.image.licenses=MIT
# Copy only the binary
COPY --from=builder /yamldap /yamldap
# Default to port 389 (standard LDAP port)
EXPOSE 389
# The binary is the entrypoint
ENTRYPOINT ["/yamldap"]