Skip to content

Commit 87acfba

Browse files
committed
fix container
1 parent 7db876d commit 87acfba

1 file changed

Lines changed: 17 additions & 21 deletions

File tree

Containerfile

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
1-
FROM rust:1.92-bookworm AS builder
1+
FROM busybox:glibc
22

3-
WORKDIR /build
3+
ARG TARGETPLATFORM
44

5-
# Cache dependencies by building a dummy project first
6-
COPY Cargo.toml Cargo.lock ./
7-
RUN mkdir src && echo "fn main() {}" > src/main.rs && echo "" > src/lib.rs
8-
RUN cargo build --release 2>/dev/null || true
9-
RUN rm -rf src
5+
# Create user and group
6+
RUN addgroup -g 1000 operator && adduser -D -u 1000 -G operator operator
107

11-
# Build the actual project
12-
COPY src/ src/
13-
RUN touch src/main.rs src/lib.rs && cargo build --release --bin postgres-restore-operator
8+
# Copy all binaries from both architectures
9+
COPY --chmod=0755 amd64/ /tmp/bins/amd64/
10+
COPY --chmod=0755 arm64/ /tmp/bins/arm64/
1411

15-
FROM debian:bookworm-slim
16-
17-
RUN apt-get update && apt-get install -y --no-install-recommends \
18-
ca-certificates \
19-
&& rm -rf /var/lib/apt/lists/*
20-
21-
RUN groupadd -r operator && useradd -r -g operator -s /sbin/nologin operator
22-
23-
COPY --from=builder /build/target/release/postgres-restore-operator /usr/local/bin/
12+
# Select and copy the correct binaries based on target platform
13+
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
14+
cp /tmp/bins/amd64/* /usr/bin/; \
15+
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
16+
cp /tmp/bins/arm64/* /usr/bin/; \
17+
else \
18+
echo "Unknown platform: $TARGETPLATFORM"; exit 1; \
19+
fi && \
20+
rm -rf /tmp/bins
2421

2522
USER operator
26-
27-
ENTRYPOINT ["postgres-restore-operator"]
23+
ENTRYPOINT ["operator"]

0 commit comments

Comments
 (0)