Skip to content

Commit

Permalink
chore(docker): build multi-stage docker
Browse files Browse the repository at this point in the history
  • Loading branch information
khiem20tc committed Oct 22, 2023
1 parent de1f9a7 commit 2da30e4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
Empty file modified .husky/commit-msg
100644 → 100755
Empty file.
Empty file modified .husky/pre-commit
100644 → 100755
Empty file.
24 changes: 22 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
FROM golang:1.21
# FROM golang:1.21

# WORKDIR /app

# COPY go.mod go.sum ./

# RUN go mod download

# COPY . ./

# RUN CGO_ENABLED=0 GOOS=linux go build -o /main

# CMD ["/main"]

# Stage 1: Build the application
FROM golang:1.21 AS BUILDER

WORKDIR /app

Expand All @@ -10,4 +25,9 @@ COPY . ./

RUN CGO_ENABLED=0 GOOS=linux go build -o /main

CMD ["/main"]
# Stage 2: Create a minimal image with the built binary
FROM alpine:latest AS RUNNER

COPY --from=builder /main /

CMD ["/main"]
1 change: 0 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: "3.8"

services:
services:
redis:
image: redis:5.0
ports:
Expand Down

0 comments on commit 2da30e4

Please sign in to comment.