Spaces:
Paused
Paused
| # builder stage - builds a static Go binary | |
| FROM golang:1.21-alpine3.18 as builder | |
| RUN apk update && apk upgrade --available && sync | |
| WORKDIR /app | |
| COPY . . | |
| # Build a static binary that does not depend on C libraries | |
| RUN CGO_ENABLED=0 go build -o /app/fsb -ldflags="-w -s" ./cmd/fsb | |
| # final stage - creates the final image for Hugging Face | |
| FROM alpine:latest | |
| # This is the most critical step, inspired by the GitHub issue. | |
| # Copy the essential system files needed by Go's networking stack | |
| # from the full builder image into our minimal final image. | |
| COPY --from=builder /etc/passwd /etc/group /etc/ | |
| COPY --from=builder /etc/nsswitch.conf /etc/ | |
| # Set the application's working directory. | |
| WORKDIR /app | |
| # Copy the application binary itself. | |
| COPY --from=builder /app/fsb /app/fsb | |
| # Create the symbolic links to redirect writes to the writable /tmp directory. | |
| # This handles both logging and the session file. | |
| RUN ln -s /tmp /app/logs && \ | |
| ln -s /tmp/telegram.session /app/session.session | |
| # Run the application. It now has the files it needs for networking, | |
| # and its write attempts will be redirected to /tmp. | |
| ENTRYPOINT ["/app/fsb", "run"] |