Skip to content

Commit c942c56

Browse files
committed
fix: alpine docker image 2
1 parent 03b2962 commit c942c56

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

backend/Dockerfile

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,28 @@
11
# Build stage
22
FROM golang:1.23.4-alpine AS builder
3-
43
# Set working directory
54
WORKDIR /app
6-
75
# Copy go mod and sum files first to leverage Docker cache
86
COPY go.mod go.sum ./
97
RUN go mod download
108
COPY .env .env
11-
129
# Copy the source code
1310
COPY . .
14-
1511
# Build the application
1612
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o /app/backend ./cmd/server/main.go
1713

1814
# Final stage
1915
FROM alpine:latest
20-
21-
# Update and install ca-certificates for HTTPS
22-
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
23-
16+
# Update and install ca-certificates for HTTPS (using apk instead of apt-get)
17+
RUN apk update && apk add --no-cache ca-certificates && rm -rf /var/cache/apk/*
2418
WORKDIR /root/
25-
2619
# Copy the binary from builder
2720
COPY --from=builder /app/backend /root/backend
28-
COPY .env /root/.env
21+
# Copy environment file (note: you had this twice in your original)
2922
COPY --from=builder /app/.env /root/.env
30-
3123
# Copy config files if needed
3224
# COPY --from=builder /app/config /root/config
33-
3425
# Expose the port your application runs on
3526
EXPOSE 8080
36-
3727
# Command to run
38-
CMD ["./backend"]
28+
CMD ["./backend"]

0 commit comments

Comments
 (0)