File size: 530 Bytes
5ef026e 5368f37 f9f149f 5ef026e 5368f37 5ef026e | 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 | # Build stage
FROM golang:1.21-alpine AS builder
WORKDIR /app
# Install git for go mod download
RUN apk add --no-cache git
# Copy all source files first
COPY go.mod ./
COPY *.go ./
# Download dependencies based on actual imports
RUN go mod tidy && go mod download
# Build
RUN CGO_ENABLED=0 GOOS=linux go build -o imgprocessor .
# Runtime stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /app/imgprocessor .
# HF Spaces uses port 7860
EXPOSE 7860
CMD ["./imgprocessor"]
|