-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
53 lines (35 loc) · 815 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#
# swapp / Dockerfile
#
#
# stage 0 -- build
#
# https://hub.docker.com/_/golang
ARG GOLANG_VERSION
FROM golang:${GOLANG_VERSION}-alpine AS swapp-build
ARG APP_NAME
ENV APP_NAME ${APP_NAME}
RUN apk add git
WORKDIR /go/src/${APP_NAME}
COPY . .
#RUN go mod init ${APP_NAME}
RUN go mod tidy
#RUN go install
# build the client -- wasm binary
RUN GOARCH=wasm GOOS=js go build -o web/app.wasm -tags wasm
# build the server
RUN go build ${APP_NAME}
#
# stage 1 -- release
#
FROM alpine:3.16 AS swapp-release
ARG APP_FLAGS
ARG DOCKER_DEV_PORT
ENV APP_FLAGS ${APP_FLAGS}
ENV DOCKER_DEV_PORT ${DOCKER_DEV_PORT}
COPY web/ /opt/web/
COPY --from=swapp-build /go/src/swapp/swapp /opt/swapp
COPY --from=swapp-build /go/src/swapp/web/app.wasm /opt/web/app.wasm
WORKDIR /opt
EXPOSE ${DOCKER_DEV_PORT}
CMD ./swapp