File size: 1,143 Bytes
5edf1f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# 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"]