Skip to content

Instantly share code, notes, and snippets.

@bennyng
Created March 10, 2021 05:47
Show Gist options
  • Save bennyng/8ae132373cf18c7bfada7f4cdb4fb152 to your computer and use it in GitHub Desktop.
Save bennyng/8ae132373cf18c7bfada7f4cdb4fb152 to your computer and use it in GitHub Desktop.
Dockerfile for go http serving static html built by svelte
# stage 0 - build html
FROM node:14.4-alpine AS html
WORKDIR /app
COPY ./package-lock.json ./package.json ./
RUN npm ci
COPY . .
RUN npm run build
RUN npm run adapt
# stage 1 - build go web
FROM golang:1.16.0-buster AS web
WORKDIR /src
COPY --from=html /app/build .
COPY ./server ./
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags '-w -extldflags "-static"' -o /go_web main.go
# stage 2 - move bin
FROM scratch
COPY --from=web /go_web /app/
ENTRYPOINT ["/app/go_web"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment