Skip to content

Instantly share code, notes, and snippets.

@edr3x
Last active February 18, 2023 16:38
Show Gist options
  • Save edr3x/56031a547cb0ad9d697c3daf4de5a5db to your computer and use it in GitHub Desktop.
Save edr3x/56031a547cb0ad9d697c3daf4de5a5db to your computer and use it in GitHub Desktop.
Dockerfile for containerizing golang projects
FROM golang:alpine as builder

RUN mkdir /build

ADD . /build

WORKDIR /build

RUN go build -o main .

FROM alpine

RUN adduser -S -D -H -h /app appuser

USER appuser

COPY . /app

COPY --from=builder /build/main /app/

WORKDIR /app

EXPOSE 3000

CMD ["./main"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment