build: add docker image build entrypoint

This commit is contained in:
hy 2026-04-20 15:47:34 +08:00
parent aba2bf6281
commit 2042cba586
3 changed files with 48 additions and 4 deletions

View File

@ -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

27
Dockerfile Normal file
View File

@ -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;"]

14
ci/build-image.sh Executable file
View File

@ -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 <image-ref>" >&2
exit 1
fi
cd "${ROOT_DIR}"
docker build --platform "${DOCKER_PLATFORM}" -t "${IMAGE_REF}" .