Skip to content

Commit

Permalink
Update dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Suhaibinator committed Oct 12, 2024
1 parent 24bccf7 commit b8dd451
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
# Use a minimal base image

# Stage 1: Build the Go binary
FROM golang:1.23-alpine AS builder

# Install git, gcc, and other dependencies required for Go modules and CGO
RUN apk add --no-cache git gcc musl-dev sqlite-dev curl make

# Set the working directory inside the builder container
WORKDIR /src

# Copy the Go source code to the builder container
COPY . .

# Build the Go application
RUN CGO_ENABLED=1 GOOS=linux go build -o SuhaibMessageQueue

# Stage 2: Create the final image
FROM alpine:latest

# Set the working directory in the container
Expand All @@ -7,11 +23,11 @@ WORKDIR /app
# Create a directory for the database
VOLUME /db

# Copy the binary to the working directory
COPY SuhaibMessageQueue .
# Copy the binary from the builder stage to the working directory
COPY --from=builder /src/SuhaibMessageQueue .

# Make the binary executable
RUN chmod +x SuhaibMessageQueue

# Specify the command to run when the container starts
CMD [ "./SuhaibMessageQueue" ]
CMD ["./SuhaibMessageQueue"]

0 comments on commit b8dd451

Please sign in to comment.