Ashad001 commited on
Commit
7d7c4dc
·
verified ·
1 Parent(s): e50cf10

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -13
Dockerfile CHANGED
@@ -1,27 +1,26 @@
1
- # Build stage
2
  FROM golang:1.22.3 as builder
3
 
4
  WORKDIR /app
5
 
6
- # Copy the source code into the container
7
  COPY . .
8
 
9
- # Build the Go app
10
- RUN go build -o main .
11
 
12
- # Ensure the binary has execute permissions
13
- RUN chmod +x main
14
-
15
- # Final stage
16
  FROM alpine:latest
17
 
18
  WORKDIR /app
19
 
20
- # Copy the binary from the builder stage
21
- COPY --from=builder /app/main .
 
 
 
22
 
23
- # Ensure the binary has execute permissions (redundant but safe)
24
- RUN chmod +x main
 
25
 
26
- # Run the binary
27
  CMD ["./main"]
 
 
1
  FROM golang:1.22.3 as builder
2
 
3
  WORKDIR /app
4
 
 
5
  COPY . .
6
 
7
+ # Build the Go application
8
+ RUN go build -o main ./main.go
9
 
10
+ # Use a minimal base image
 
 
 
11
  FROM alpine:latest
12
 
13
  WORKDIR /app
14
 
15
+ # Copy the Go binary from the builder stage
16
+ COPY --from=builder /app/main /app/
17
+
18
+ # Ensure the binary has execution permissions
19
+ RUN chmod +x /app/main
20
 
21
+ # Verify the binary is in place and executable
22
+ RUN ls -l /app
23
+ RUN pwd
24
 
25
+ # Set the entrypoint to run the Go binary
26
  CMD ["./main"]