-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
33 lines (23 loc) · 768 Bytes
/
Dockerfile
File metadata and controls
33 lines (23 loc) · 768 Bytes
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
# Build Stage
FROM golang:1.21-alpine3.18 AS builder
# Install necessary packages for building (including CGO support)
RUN apk add --no-cache bash build-base git
# Set the working directory
WORKDIR /app
# Copy the entire application directory into the container
COPY . .
# Build the Go application with CGO enabled
RUN CGO_ENABLED=1 go build -o main ./main.go
# Run Stage
FROM alpine:3.18
# Set the working directory in the second stage
WORKDIR /app
# Copy the built binary from the builder stage
COPY --from=builder /app/main .
# Copy other required assets like templates and static files
COPY templates templates/
COPY static static/
# Expose the port your application will listen on
EXPOSE 8080
# Define the command to run your application
CMD ["./main"]