-
Notifications
You must be signed in to change notification settings - Fork 14
/
Dockerfile
29 lines (21 loc) · 808 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
FROM golang:1.13.5-alpine3.10 AS builder
WORKDIR /app
COPY . /app
ENV GOPATH=/app
# Install Git because we need to install Go module from GitHub
RUN apk update && apk upgrade && \
apk add --no-cache bash git
# Build wasm file
RUN go get github.com/skip2/go-qrcode
RUN cd wasm;GOARCH=wasm GOOS=js go build -o index.wasm wasm_main.go
# Copy the wasm_exec.js file from the GOROOT of the image, to further ensure consistency
RUN cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" static/js/wasm_exec.js
RUN go build -o bin/main main.go
# For smaller image size
# see https://medium.com/@gdiener/how-to-build-a-smaller-docker-image-76779e18d48a
FROM alpine:3.10
WORKDIR /app
COPY --from=builder /app/static ./static
COPY --from=builder /app/wasm ./wasm
COPY --from=builder /app/bin ./bin
CMD ["./bin/main"]