feat: add Dockerfile and GitLab CI pipeline for Harbor

Multi-stage Docker build: node:20-alpine + nginx:1.27-alpine.
CI builds and pushes to harbor-in-k3s.cheverjohn.me/iloom/iloom-frontend.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Chever John 2026-06-17 10:01:55 +08:00
parent 3093ae18c2
commit e399f0070e
No known key found for this signature in database
GPG Key ID: 2894D52ED1211DF0
2 changed files with 38 additions and 0 deletions

27
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,27 @@
stages:
- build
variables:
HARBOR_REGISTRY: harbor-in-k3s.cheverjohn.me
HARBOR_PROJECT: iloom
DOCKER_TLS_CERTDIR: "/certs"
build-frontend:
stage: build
image: docker:27
services:
- docker:27-dind
before_script:
- echo "$HARBOR_PASSWORD" | docker login $HARBOR_REGISTRY -u "$HARBOR_USER" --password-stdin
script:
- |
if [ -n "$CI_COMMIT_TAG" ]; then
TAG="$CI_COMMIT_TAG"
else
TAG="main-${CI_COMMIT_SHORT_SHA}"
fi
- docker build -t $HARBOR_REGISTRY/$HARBOR_PROJECT/iloom-frontend:$TAG .
- docker push $HARBOR_REGISTRY/$HARBOR_PROJECT/iloom-frontend:$TAG
rules:
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_COMMIT_TAG =~ /^v/

11
Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM node:20-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM nginx:1.27-alpine
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 3015
CMD ["nginx", "-g", "daemon off;"]