This commit is contained in:
Your Name
2025-05-03 13:19:41 +12:00
parent a1ea611e32
commit 11dccca171
9 changed files with 373 additions and 41 deletions

View File

@@ -1,40 +1,17 @@
FROM alpine:latest AS builder
# Install build dependencies
RUN apk add --no-cache \
build-base \
cmake \
git \
musl-dev \
sqlite-dev \
tar \
gzip \
zlib-dev
# Copy source code
COPY . /src
WORKDIR /src
# Build
RUN rm -rf build && mkdir build && cd build && \
cmake .. -DCMAKE_EXE_LINKER_FLAGS="-static" && \
make -j$(nproc)
# Create final image
FROM scratch
FROM alpine:latest
ARG TARGETOS
ARG TARGETARCH
# Copy binary from builder
COPY --from=builder /src/build/simple_object_storage /sos
# Create data directory (though mounting is preferred)
# RUN mkdir -p /data
# VOLUME /data
RUN mkdir -p /sos
# Set working directory (optional for scratch)
# WORKDIR /data
COPY exe/simple_object_storage-${TARGETOS}-${TARGETARCH} /sos/sos
# Expose port
EXPOSE 80
# Run server (assuming config is mounted at /data/config.json)
ENTRYPOINT ["/sos"]
CMD ["/sos/sos"]