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:
parent
3093ae18c2
commit
e399f0070e
27
.gitlab-ci.yml
Normal file
27
.gitlab-ci.yml
Normal 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
11
Dockerfile
Normal 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;"]
|
||||||
Loading…
x
Reference in New Issue
Block a user