dongsii commited on
Commit
1bb6a5c
·
verified ·
1 Parent(s): 872c166

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +26 -7
Dockerfile CHANGED
@@ -1,23 +1,42 @@
1
  # ===== BUILD STAGE =====
2
  FROM golang:1.22-alpine AS builder
3
 
 
4
  WORKDIR /app
5
 
6
- # Buat go.mod & go.sum otomatis dengan nama module gemini_textai
7
- RUN go mod init gemini_textai
8
- COPY main.go ./
9
- RUN go mod tidy
10
 
11
- # Build binary
12
- RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app
 
 
 
 
 
 
13
 
14
  # ===== RUNTIME STAGE =====
15
  FROM alpine:latest
16
 
 
 
 
 
17
  WORKDIR /app
 
 
18
  COPY --from=builder /app/app .
19
 
 
20
  ENV PORT=7860
 
 
21
  EXPOSE 7860
22
 
23
- CMD ["./app"]
 
 
 
 
 
 
1
  # ===== BUILD STAGE =====
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
+ # Initialize module dan download dependencies
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"]