Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +4 -29
Dockerfile
CHANGED
|
@@ -1,42 +1,17 @@
|
|
| 1 |
-
|
| 2 |
-
FROM golang:1.22-alpine AS builder
|
| 3 |
|
| 4 |
-
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
# Copy source code
|
| 8 |
COPY main.go .
|
| 9 |
|
| 10 |
-
#
|
| 11 |
RUN go mod init video-proxy && \
|
| 12 |
-
go mod tidy
|
| 13 |
-
|
| 14 |
-
# Build static binary dengan optimasi
|
| 15 |
-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
| 16 |
-
-ldflags="-s -w -extldflags '-static'" \
|
| 17 |
-
-o app main.go
|
| 18 |
-
|
| 19 |
-
# ===== RUNTIME STAGE =====
|
| 20 |
-
FROM alpine:latest
|
| 21 |
-
|
| 22 |
-
# Install certificates dan timezone data
|
| 23 |
-
RUN apk --no-cache add ca-certificates tzdata
|
| 24 |
-
|
| 25 |
-
# Set working directory
|
| 26 |
-
WORKDIR /app
|
| 27 |
-
|
| 28 |
-
# Copy binary dari builder
|
| 29 |
-
COPY --from=builder /app/app .
|
| 30 |
-
|
| 31 |
-
# Set environment variables
|
| 32 |
-
ENV PORT=7860
|
| 33 |
|
| 34 |
# Expose port
|
| 35 |
EXPOSE 7860
|
| 36 |
|
| 37 |
-
# Health check untuk Hugging Face
|
| 38 |
-
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
| 39 |
-
CMD ["wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:7860/health"] || exit 1
|
| 40 |
-
|
| 41 |
# Jalankan aplikasi
|
| 42 |
CMD ["./app"]
|
|
|
|
| 1 |
+
FROM golang:1.22-alpine
|
|
|
|
| 2 |
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
# Copy source code
|
| 6 |
COPY main.go .
|
| 7 |
|
| 8 |
+
# Install dependencies dan build
|
| 9 |
RUN go mod init video-proxy && \
|
| 10 |
+
go mod tidy && \
|
| 11 |
+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o app main.go
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
# Expose port
|
| 14 |
EXPOSE 7860
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
# Jalankan aplikasi
|
| 17 |
CMD ["./app"]
|