chore: update Docker build configuration
This commit is contained in:
parent
6cc02b5efc
commit
b177e603da
1 changed files with 24 additions and 6 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
# Simple Dockerfile for homelab use
|
# Simple Dockerfile for homelab use
|
||||||
FROM golang:1.25-alpine AS builder
|
FROM golang:1.25-alpine AS builder
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies including C++ build tools
|
||||||
RUN apk add --no-cache git make gcc musl-dev
|
RUN apk add --no-cache git make gcc g++ musl-dev cmake
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
@ -16,15 +16,21 @@ RUN go mod download
|
||||||
# Copy source code
|
# Copy source code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build Go binaries
|
# Copy and build native C++ libraries
|
||||||
|
COPY native/ ./native/
|
||||||
|
RUN rm -rf native/build && cd native && mkdir -p build && cd build && \
|
||||||
|
cmake .. -DCMAKE_BUILD_TYPE=Release && \
|
||||||
|
make -j$(nproc)
|
||||||
|
|
||||||
|
# Build Go binaries with native libs
|
||||||
RUN CGO_ENABLED=1 go build -o bin/api-server cmd/api-server/main.go && \
|
RUN CGO_ENABLED=1 go build -o bin/api-server cmd/api-server/main.go && \
|
||||||
CGO_ENABLED=1 go build -o bin/worker ./cmd/worker
|
CGO_ENABLED=1 go build -o bin/worker ./cmd/worker
|
||||||
|
|
||||||
# Final stage
|
# Final stage
|
||||||
FROM alpine:3.19
|
FROM alpine:3.19
|
||||||
|
|
||||||
# Install runtime dependencies
|
# Install runtime dependencies including C++ stdlib
|
||||||
RUN apk add --no-cache bash ca-certificates redis openssl curl podman fuse-overlayfs slirp4netns iptables
|
RUN apk add --no-cache bash ca-certificates redis openssl curl podman fuse-overlayfs slirp4netns iptables libstdc++
|
||||||
|
|
||||||
# Create app user
|
# Create app user
|
||||||
RUN addgroup -g 1001 -S appgroup && \
|
RUN addgroup -g 1001 -S appgroup && \
|
||||||
|
|
@ -33,8 +39,20 @@ RUN addgroup -g 1001 -S appgroup && \
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy binaries from builder
|
# Copy binaries and native libs from builder
|
||||||
COPY --from=builder /app/bin/ /usr/local/bin/
|
COPY --from=builder /app/bin/ /usr/local/bin/
|
||||||
|
RUN mkdir -p /usr/local/lib
|
||||||
|
COPY --from=builder /app/native/build/lib*.so /usr/local/lib/
|
||||||
|
|
||||||
|
# Create versioned symlinks expected by the binaries
|
||||||
|
RUN cd /usr/local/lib && \
|
||||||
|
for lib in *.so; do \
|
||||||
|
ln -sf "$lib" "${lib}.0" 2>/dev/null || true; \
|
||||||
|
done
|
||||||
|
|
||||||
|
# Update library cache and set library path
|
||||||
|
RUN ldconfig /usr/local/lib 2>/dev/null || true
|
||||||
|
ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:$LD_LIBRARY_PATH
|
||||||
|
|
||||||
# Copy configs and templates
|
# Copy configs and templates
|
||||||
COPY --from=builder /app/configs/ /app/configs/
|
COPY --from=builder /app/configs/ /app/configs/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue