Skip to content

Commit

Permalink
Add Dockerfile for building and running Go application
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusziade committed Aug 31, 2023
1 parent df8b426 commit c003a33
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Use the official Go image
FROM golang:1.19 AS build

# Set the working directory
WORKDIR /app

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

# Download dependencies
RUN go mod download

# Copy source code
COPY . .

# Build the application
RUN go build -o main .

# Use a lightweight image for deployment
FROM alpine:latest AS runtime

# Install necessary libraries
RUN apk --no-cache add ca-certificates

# Copy binary
COPY --from=build /app/main /app/

# Set the working directory
WORKDIR /app

# Run the application
CMD [". --download-only"]

0 comments on commit c003a33

Please sign in to comment.