KaThaNg commited on
Commit
5881998
·
verified ·
1 Parent(s): be2d387

Upload 2 files

Browse files
Files changed (2) hide show
  1. Dockerfile +53 -0
  2. README.md +1 -6
Dockerfile ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Stage 1: Build the Go application
2
+ # Gợi ý: Sử dụng phiên bản Go mới hơn để có các bản vá bảo mật và cải tiến hiệu năng
3
+ FROM golang:1.22-alpine AS builder
4
+
5
+ # Set necessary environment variables
6
+ ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64
7
+
8
+ WORKDIR /build
9
+
10
+ # Copy only the module definition file first
11
+ COPY go.mod ./
12
+ # Download dependencies and ensure go.sum is consistent
13
+ RUN go mod download
14
+
15
+ # Copy the rest of the source code AFTER initial download
16
+ COPY . .
17
+ # Now run tidy to ensure go.mod and go.sum match the code [cite: 5]
18
+ RUN go mod tidy
19
+
20
+ # Verify dependencies (optional but good practice)
21
+ RUN go mod verify
22
+
23
+ # Build the Go application statically linked
24
+ # -ldflags="-w -s" reduces binary size by removing debug info
25
+ RUN go build -ldflags="-w -s" -o /app/proxy-server .
26
+
27
+ # Stage 2: Create the final minimal image
28
+ FROM alpine:latest
29
+
30
+ # Install ca-certificates for HTTPS calls and tzdata for timezone info
31
+ RUN apk update && apk add --no-cache ca-certificates tzdata
32
+
33
+ # Gợi ý: Kích hoạt non-root user để tăng cường bảo mật
34
+ # Tạo group và user riêng cho ứng dụng
35
+ RUN addgroup -S appgroup && adduser -S appuser -G appgroup
36
+
37
+ # Set the working directory
38
+ WORKDIR /app
39
+
40
+ # Copy the built binary from the builder stage
41
+ COPY --from=builder /app/proxy-server /app/proxy-server
42
+
43
+ # Cấp quyền sở hữu thư mục và file cho user mới
44
+ RUN chown -R appuser:appgroup /app
45
+
46
+ # Chuyển sang user không phải root
47
+ USER appuser
48
+
49
+ # Expose the port the app runs on
50
+ EXPOSE 7860
51
+
52
+ # Set the entrypoint command to run the binary
53
+ ENTRYPOINT ["/app/proxy-server"]
README.md CHANGED
@@ -1,10 +1,5 @@
1
  ---
2
  title: MINDSVIP
3
- emoji: 🐢
4
- colorFrom: purple
5
- colorTo: pink
6
  sdk: docker
7
- pinned: false
8
  ---
9
-
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
  title: MINDSVIP
 
 
 
3
  sdk: docker
4
+ app_port: 7860
5
  ---