Skip to content

Instantly share code, notes, and snippets.

@arshamalh
Last active September 21, 2023 23:11
Show Gist options
  • Save arshamalh/42cdd40b5abb3de1c9c61534e17914bc to your computer and use it in GitHub Desktop.
Save arshamalh/42cdd40b5abb3de1c9c61534e17914bc to your computer and use it in GitHub Desktop.
Go and UI Multistage Dockerfile
FROM golang:1.21-alpine3.18 AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . ./
RUN CGO_ENABLED=0 GOOS=linux go build -a -o main .
FROM node:18-alpine3.15 AS frontend
WORKDIR /ui
COPY ui .
RUN npm install
RUN npm run build
FROM alpine:3.18 AS production
COPY --from=builder /app/main .
COPY --from=frontend /ui/public /ui
CMD ["./main"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment