Skip to content

Instantly share code, notes, and snippets.

@estenssoros
Created September 20, 2023 09:06
Show Gist options
  • Save estenssoros/b9f7c79dab97eaaf31d5188207cae570 to your computer and use it in GitHub Desktop.
Save estenssoros/b9f7c79dab97eaaf31d5188207cae570 to your computer and use it in GitHub Desktop.
Docker, ECR, Elastic Beanstalk, & Terraform Dockerfile
FROM golang:1.20 AS builder
WORKDIR /go/src/github.com/path/to/your/code
COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download
COPY main.go main.go
COPY cmd/ cmd/
COPY pkg/ pkg/
# Other directories or file that you need
RUN CGO_ENABLED=0 GOOS=linux go build -a -o app .
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /go/src/github.com/path/to/your/code/app .
EXPOSE 1323 #or other port
CMD ["./app", "arg"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment