Skip to content

Instantly share code, notes, and snippets.

@Sampriti-Mitra
Created January 28, 2022 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sampriti-Mitra/501d2997c947ea5e7327b72bf09a29cd to your computer and use it in GitHub Desktop.
Save Sampriti-Mitra/501d2997c947ea5e7327b72bf09a29cd to your computer and use it in GitHub Desktop.
# Build the Go API
FROM golang:latest AS builder
ADD . /app
WORKDIR /app/server
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-w" -a -o /main .
# Build the React application
FROM node:alpine AS node_builder
COPY --from=builder /app/frontend ./
RUN npm install
RUN npm run build
# Final stage build, this will be the container
# that we will deploy to production
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /main ./
COPY --from=node_builder /build ./web
RUN chmod +x ./main
EXPOSE 8080
CMD ./main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment