Skip to content

Commit

Permalink
refactor: Update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
abdealijaroli committed Sep 2, 2024
1 parent 465114a commit 5f38483
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
docker pull abdealijaroli/jaro:latest
docker stop jaro || true
docker rm jaro || true
docker run -d --name jaro -p 8008:8008 --env DB_URL="${{ secrets.DB_URL }}" abdealijaroli/jaro:latest
docker run -d --name jaro -e DB_URL="${{ secrets.DB_URL }}" -p 8008:8008 abdealijaroli/jaro:latest
21 changes: 12 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
# Stage 1: Build the Go binary
FROM golang:1.22.3 AS builder
FROM golang:1.20 AS builder

WORKDIR /app

LABEL maintainer="Abdeali Jaroli <[email protected]>"

# Copy go mod and sum files
COPY go.mod go.sum ./

RUN go mod download

# Copy source files
COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -o jaro .
# Build the Go binary
RUN go build -o jaro

# Stage 2: Create a lightweight image to run the binary
# Create a minimal image for running the Go binary
FROM alpine:latest

WORKDIR /root/

# Copy the Go binary from the builder stage
COPY --from=builder /app/jaro .

ENV DB_URL="add-your-own-db-url"
# Copy the web files into the image
COPY web /root/web

# Expose port 8008
EXPOSE 8008

CMD ["/root/jaro"]
# Run the Go binary
CMD ["./jaro"]

0 comments on commit 5f38483

Please sign in to comment.