-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
37 lines (25 loc) · 905 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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 . .
# Set environment variables for cross-compilation
ENV CGO_ENABLED=1
ENV GOOS=linux
# Build the Go application
RUN go build -o SuhaibMessageQueue
# Stage 2: Create the final image
FROM alpine:latest
# Set the working directory in the container
WORKDIR /app
# Create a directory for the database
VOLUME /db
# 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"]