dockerize go app
This commit is contained in:
parent
4084f8dad7
commit
6d859012ce
4 changed files with 53 additions and 0 deletions
28
Dockerfile
Normal file
28
Dockerfile
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# Build stage
|
||||
FROM golang:1.25-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install git if needed for go mod
|
||||
RUN apk add --no-cache git
|
||||
|
||||
# Copy go mod and sum files
|
||||
COPY go.mod go.sum ./
|
||||
|
||||
# Download dependencies
|
||||
RUN go mod download
|
||||
|
||||
COPY main.go .
|
||||
|
||||
RUN go build -o main .
|
||||
|
||||
FROM alpine:latest
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/main .
|
||||
COPY keys ./keys
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["./main", "-cert=./keys/cert.crt.pem", "-key=./keys/localhost_key.pem", "-host=0.0.0.0:8080"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue