diff --git a/Dockerfile b/Dockerfile index 87cfb2b63..655255a71 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,18 @@ # All-in-one Dockerfile for building the SPX GUI -ARG image_address -FROM ghcr.io/goplus/gop:1.2 AS go-builder +ARG GOP_BASE_IMAGE=ghcr.io/goplus/gop:1.2 +ARG NODE_BASE_IMAGE=node:20.11.1 +ARG NGINX_BASE_IMAGE=nginx:1.27 + +FROM ${GOP_BASE_IMAGE} AS go-builder WORKDIR /app COPY tools ./tools COPY spx-backend ./spx-backend +ARG GOPROXY + # Build WASM WORKDIR /app/tools/fmt RUN ./build.sh @@ -18,12 +23,14 @@ RUN ./build.sh WORKDIR /app/spx-backend RUN gop build -o spx-backend ./cmd/spx-backend -FROM ${image_address}node:20.11.1 AS frontend-builder +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 . @@ -34,7 +41,7 @@ COPY --from=go-builder /app/tools/ispx/main.wasm /app/spx-gui/src/assets/ispx/ma RUN npm run build -FROM ${image_address}nginx:1.27 +FROM ${NGINX_BASE_IMAGE} COPY --from=go-builder /app/spx-backend/spx-backend /app/spx-backend/spx-backend COPY --from=frontend-builder /app/spx-gui/dist /usr/share/nginx/html @@ -47,4 +54,4 @@ EXPOSE 80 WORKDIR /app -CMD ["sh", "-c", "nginx && ./spx-backend/spx-backend"] +CMD ["sh", "-c", "nginx && exec ./spx-backend/spx-backend"] diff --git a/scripts/pr-preview.sh b/scripts/pr-preview.sh index 0985d70f9..fe1bdaec7 100755 --- a/scripts/pr-preview.sh +++ b/scripts/pr-preview.sh @@ -6,11 +6,23 @@ set -ex echo "WORKSPACE: ${PWD}" -PREVIEW_URL=http://goplus-builder-pr-${PULL_NUMBER}.goplus-pr-review.svc.jfcs-qa1.local +PREVIEW_URL="http://goplus-builder-pr-${PULL_NUMBER}.goplus-pr-review.svc.jfcs-qa1.local" -echo VITE_PUBLISH_BASE_URL="${PREVIEW_URL}"/ > spx-gui/.env.local -CONTAINER_IMAGE=aslan-spock-register.qiniu.io/goplus/goplus-builder-pr:${PULL_NUMBER}-${PULL_PULL_SHA:0:8} -docker build -t "${CONTAINER_IMAGE}" --build-arg image_address=aslan-spock-register.qiniu.io/goplus/ -f ./Dockerfile . --builder="kube" --push +echo "VITE_PUBLISH_BASE_URL=${PREVIEW_URL}/" > spx-gui/.env.local + +GOPLUS_REGISTRY_REPO=aslan-spock-register.qiniu.io/goplus +CONTAINER_IMAGE="${GOPLUS_REGISTRY_REPO}/goplus-builder-pr:${PULL_NUMBER}-${PULL_PULL_SHA:0:8}" +docker build \ + --builder kube \ + --push \ + -f ./Dockerfile \ + -t "${CONTAINER_IMAGE}" \ + --build-arg GOP_BASE_IMAGE="${GOPLUS_REGISTRY_REPO}/gop:1.2" \ + --build-arg NODE_BASE_IMAGE="${GOPLUS_REGISTRY_REPO}/node:20.11.1" \ + --build-arg NGINX_BASE_IMAGE="${GOPLUS_REGISTRY_REPO}/nginx:1.27" \ + --build-arg GOPROXY=https://goproxy.cn,direct \ + --build-arg NPM_CONFIG_REGISTRY=https://registry.npmmirror.com \ + . CURRENT_TIME="$(date "--iso-8601=seconds")" # generate kubernetes yaml with unique flag for PR