forked from goplus/builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
81 lines (51 loc) · 1.87 KB
/
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# All-in-one Dockerfile for building the SPX GUI
ARG GOP_BASE_IMAGE=ghcr.io/goplus/gop:1.2
ARG GO_BASE_IMAGE=golang:1.23.4
ARG NODE_BASE_IMAGE=node:20.11.1
ARG NGINX_BASE_IMAGE=nginx:1.27
################################################################################
FROM ${GOP_BASE_IMAGE} AS gop-builder
WORKDIR /app
COPY tools ./tools
COPY spx-backend ./spx-backend
ARG GOPROXY
# Build WASM
WORKDIR /app/tools/fmt
RUN ./build.sh
WORKDIR /app/tools/ispx
RUN ./build.sh
# Build backend
WORKDIR /app/spx-backend
RUN gop build -trimpath -o spx-backend ./cmd/spx-backend
################################################################################
FROM ${GO_BASE_IMAGE} AS go-builder
WORKDIR /app
COPY tools ./tools
ARG GOPROXY
# Build WASM for spxls
WORKDIR /app/tools/spxls
RUN ./build.sh
################################################################################
FROM ${NODE_BASE_IMAGE} AS frontend-builder
WORKDIR /app/spx-gui
COPY spx-gui/package.json spx-gui/package-lock.json ./
ARG NPM_CONFIG_REGISTRY
RUN npm install
COPY spx-gui .
COPY docs ../docs
COPY tools ../tools
COPY --from=gop-builder /app/tools/fmt/static/main.wasm /app/spx-gui/src/assets/format.wasm
COPY --from=gop-builder /app/tools/ispx/main.wasm /app/spx-gui/src/assets/ispx/main.wasm
COPY --from=go-builder /app/tools/spxls/spxls.wasm /app/spx-gui/src/assets/spxls.wasm
ARG NODE_ENV
RUN npm run build
################################################################################
FROM ${NGINX_BASE_IMAGE}
COPY --from=gop-builder /app/spx-backend/spx-backend /app/spx-backend/spx-backend
COPY --from=frontend-builder /app/spx-gui/dist /usr/share/nginx/html
COPY scripts/nginx.conf /etc/nginx/conf.d/default.conf
# Compress WASM files for gzip_static
RUN find /usr/share/nginx/html -name "*.wasm" -exec gzip -9 -k {} \;
EXPOSE 80
WORKDIR /app
CMD ["sh", "-c", "nginx && exec ./spx-backend/spx-backend"]