From 2042cba58688d0deaba9e3918e229b0ab7152aab Mon Sep 17 00:00:00 2001 From: hy Date: Mon, 20 Apr 2026 15:47:34 +0800 Subject: [PATCH] build: add docker image build entrypoint --- .dockerignore | 11 +++++++---- Dockerfile | 27 +++++++++++++++++++++++++++ ci/build-image.sh | 14 ++++++++++++++ 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 Dockerfile create mode 100755 ci/build-image.sh diff --git a/.dockerignore b/.dockerignore index 52b833a..d39faff 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,10 @@ -node_modules .git .gitignore -*.md -dist +node_modules +apps/node_modules +apps/.turbo +apps/dist .turbo -dist.zip +dist +coverage +**/.DS_Store diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..da589db --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM node:22-slim AS builder + +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" +ENV NODE_OPTIONS="--max-old-space-size=8192" +ENV TZ="Asia/Shanghai" +ENV CI="true" + +RUN npm i -g corepack && corepack enable + +WORKDIR /app +COPY . /app + +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile +RUN pnpm run build:antdv-next + +FROM nginx:stable-alpine + +RUN echo "types { application/javascript js mjs; }" > /etc/nginx/conf.d/mjs.conf \ + && rm -rf /etc/nginx/conf.d/default.conf + +COPY --from=builder /app/apps/dist /usr/share/nginx/html +COPY --from=builder /app/scripts/deploy/nginx.conf /etc/nginx/nginx.conf + +EXPOSE 8080 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/ci/build-image.sh b/ci/build-image.sh new file mode 100755 index 0000000..8c52f31 --- /dev/null +++ b/ci/build-image.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)" +IMAGE_REF="${1:-}" +DOCKER_PLATFORM="${DOCKER_PLATFORM:-linux/amd64}" + +if [ -z "${IMAGE_REF}" ]; then + echo "usage: ci/build-image.sh " >&2 + exit 1 +fi + +cd "${ROOT_DIR}" +docker build --platform "${DOCKER_PLATFORM}" -t "${IMAGE_REF}" .