Configure CI/CD to use private Nexus registry

This commit is contained in:
root 2025-12-18 15:20:41 +08:00
parent 3a7daf66a7
commit 2e297cf82f
2 changed files with 10 additions and 7 deletions

View File

@ -5,25 +5,28 @@ stages:
variables: variables:
DOCKER_IMAGE_NAME: file-system-server DOCKER_IMAGE_NAME: file-system-server
DOCKER_TAG: latest DOCKER_TAG: latest
CI_REGISTRY: "192.168.1.154:31010"
CI_REGISTRY_USER: "docker"
CI_REGISTRY_PASSWORD: "dockerxn001624."
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
# 构建镜像 # 构建镜像
build_image: build_image:
stage: build stage: build
image: docker:20.10.16 image: 192.168.1.154:31010/docker:20.10.16
services: services:
- docker:20.10.16-dind - 192.168.1.154:31010/docker:20.10.16-dind
script: script:
- docker build -t $DOCKER_IMAGE_NAME:$DOCKER_TAG . - docker build -t $DOCKER_IMAGE_NAME:$DOCKER_TAG .
# 如果有私有仓库,可以在这里 push
# - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
# - docker push $DOCKER_IMAGE_NAME:$DOCKER_TAG
only: only:
- main - main
# 部署服务 # 部署服务
deploy_service: deploy_service:
stage: deploy stage: deploy
image: docker/compose:latest image: 192.168.1.154:31010/docker/compose:latest
script: script:
# 停止旧容器(如果存在) # 停止旧容器(如果存在)
- docker-compose down --remove-orphans || true - docker-compose down --remove-orphans || true

View File

@ -1,5 +1,5 @@
# Build Stage # Build Stage
FROM golang:1.23-alpine AS builder FROM 192.168.1.154:31010/golang:1.23-alpine AS builder
WORKDIR /app WORKDIR /app