forked from
atscan.net/plcbundle-rs
High-performance implementation of plcbundle written in Rust
1FROM rust:1.90-alpine AS builder
2
3# Determine Rust target based on build platform
4ARG TARGETARCH
5ARG TARGETPLATFORM
6RUN case ${TARGETARCH} in \
7 amd64) RUST_TARGET=x86_64-unknown-linux-musl ;; \
8 arm64) RUST_TARGET=aarch64-unknown-linux-musl ;; \
9 *) echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
10 esac && \
11 echo "Building for ${RUST_TARGET}" && \
12 rustup target add ${RUST_TARGET}
13
14RUN apk update && \
15 apk add --no-cache build-base musl-dev pkgconfig ca-certificates openssl-dev openssl-libs-static
16
17WORKDIR /app
18COPY Cargo.toml Cargo.lock ./
19COPY src ./src
20COPY tests ./tests
21
22ENV OPENSSL_STATIC=1
23ENV OPENSSL_DIR=/usr
24
25# Build with the determined target
26ARG TARGETARCH
27RUN case ${TARGETARCH} in \
28 amd64) RUST_TARGET=x86_64-unknown-linux-musl ;; \
29 arm64) RUST_TARGET=aarch64-unknown-linux-musl ;; \
30 *) echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
31 esac && \
32 cargo build --release --features server --target ${RUST_TARGET} && \
33 cp /app/target/${RUST_TARGET}/release/plcbundle /app/plcbundle
34
35FROM alpine:3 AS runtime
36RUN adduser -D -u 10001 appuser && \
37 apk add --no-cache ca-certificates tzdata && \
38 update-ca-certificates
39
40WORKDIR /data
41
42# Copy the binary from the fixed location in builder stage
43COPY --from=builder --chmod=755 /app/plcbundle /usr/local/bin/plcbundle
44USER appuser
45EXPOSE 8080
46ENTRYPOINT ["plcbundle"]