-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile.frontend
48 lines (30 loc) · 1.05 KB
/
Dockerfile.frontend
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
#Build stage
FROM golang:1.19-alpine3.16 AS buildstage
ENV CGO_ENABLED=0
WORKDIR /app
COPY common ./common
COPY frontend ./frontend
RUN cd frontend && go install gioui.org/cmd/gogio@latest
RUN cd common && go mod tidy
RUN cd frontend && go mod tidy
RUN cd frontend && gogio -target js -o dist cmd/main.go
RUN cd frontend && go build -o static cmd/static/main.go
COPY frontend/cmd/static/dist/index.html frontend/dist
COPY frontend/cmd/static/dist/wasm.js frontend/dist/wasm.js
COPY frontend/assets/appicon.ico frontend/dist/favicon.ico
COPY frontend/assets/images/thumbnail.png frontend/dist/images/thumbnail.png
ARG API_URL=http://localhost:8001
ENV API_URL ${API_URL}
ARG STATIC_FOLDER=dist
ENV STATIC_FOLDER ${STATIC_FOLDER}
RUN echo "window.API_URL = '${API_URL}';" >> frontend/dist/wasm.js
RUN echo "window.STATIC_FOLDER = '${STATIC_FOLDER}';" >> frontend/dist/wasm.js
# Runtime
FROM scratch
EXPOSE 8080
VOLUME /data
WORKDIR /
COPY --from=buildstage /app/frontend/dist /dist
COPY --from=buildstage /app/frontend/static /static
ENTRYPOINT ["/static"]
CMD []