提交 627f9bf2 编写于 作者: 徐晓伟's avatar 徐晓伟

👷 docker

上级 a04b4133
stages:
- build
- publish
# 代码同步
- pages
- docker:build
- docker:deploy
- sync
variables:
DOCKER_TAG: 0.0.1
pages:
stage: build
stage: pages
image: node:18.17.1
cache:
key: "${CI_JOB_NAME}"
......@@ -15,6 +18,9 @@ pages:
- if [ $CI_SERVER_HOST == 'gitlab.helm.xuxiaowei.cn' ]; then
yarn config set registry https://registry.npmmirror.com;
fi
- if [ $CI_SERVER_HOST == 'jihulab.com' ]; then
yarn config set registry https://registry.npmmirror.com;
fi
- yarn
- yarn build
- mv build/ public/
......@@ -23,10 +29,10 @@ pages:
paths:
- public/
rules:
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_COMMIT_BRANCH == "main" && $ENABLE_DOCS == "true"
build:npm:
stage: build
stage: pages
image: node:18.17.1
cache:
key: "${CI_JOB_NAME}"
......@@ -36,6 +42,9 @@ build:npm:
- if [ $CI_SERVER_HOST == 'gitlab.helm.xuxiaowei.cn' ]; then
npm config set registry https://registry.npmmirror.com;
fi
- if [ $CI_SERVER_HOST == 'jihulab.com' ]; then
npm config set registry https://registry.npmmirror.com;
fi
- npm install
- npm run build
- mv build/ public/
......@@ -47,7 +56,7 @@ build:npm:
- if: $CI_COMMIT_BRANCH == "main"
build:pnpm:
stage: build
stage: pages
image: node:18.17.1
cache:
key: "${CI_JOB_NAME}"
......@@ -57,6 +66,9 @@ build:pnpm:
- if [ $CI_SERVER_HOST == 'gitlab.helm.xuxiaowei.cn' ]; then
yarn config set registry https://registry.npmmirror.com;
fi
- if [ $CI_SERVER_HOST == 'jihulab.com' ]; then
yarn config set registry https://registry.npmmirror.com;
fi
- yarn global add pnpm
- if [ $CI_SERVER_HOST == 'gitlab.helm.xuxiaowei.cn' ]; then
pnpm config set registry https://registry.npmmirror.com;
......@@ -71,25 +83,45 @@ build:pnpm:
rules:
- if: $CI_COMMIT_BRANCH == "main"
publish-gitee-pages:
stage: publish
docker:build:
stage: docker:build
image:
name: xuxiaoweicomcn/kaniko-project-executor:v1.22.0-debug
entrypoint: [""]
needs:
- job: pages
artifacts: true
image: bitnami/git:2.40.1
before_script:
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"},\"https://index.docker.io/v1/\":{\"auth\":\"$(printf "%s:%s" ${DOCKER_USERNAME} "${DOCKER_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
script:
- git config --global user.email $GITLAB_USER_EMAIL
- git config --global user.name $GITLAB_USER_NAME
- git config --global user.email
- git config --global user.name
- echo 当前分支:$CI_COMMIT_BRANCH
- git checkout -b $CI_COMMIT_BRANCH
- git add -f public/
- git commit -m "发布 Gitee Pages"
- git remote add gitee https://xuxiaowei-com-cn:$GITEE_PRIVATE_TOKEN@gitee.com/$CI_PROJECT_PATH.git
- git push -f -u gitee $CI_COMMIT_BRANCH:pages
- echo $DOCKER_TAG
- /kaniko/executor version
- /kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
--build-arg "CI_PIPELINE_URL=${CI_PIPELINE_URL}"
--destination "${CI_REGISTRY_IMAGE}:${DOCKER_TAG}"
--destination "${CI_REGISTRY_IMAGE}:${DOCKER_TAG}-${CI_PIPELINE_ID}"
--destination "xuxiaoweicomcn/gitlab-k8s:${DOCKER_TAG}"
--destination "xuxiaoweicomcn/gitlab-k8s:${DOCKER_TAG}-${CI_PIPELINE_ID}"
rules:
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_COMMIT_BRANCH == "main" && $ENABLE_DOCS_DOCKER == "true"
docker:deploy:
stage: docker:deploy
needs:
- job: docker:build
image: docker:26.1.1-cli
variables:
DOCKER_HOST: $DEPLOY_DOCKER_HOST
script:
- docker info
- docker compose up -d
environment: production
rules:
- if: $CI_COMMIT_BRANCH == "main" && $ENABLE_DOCS_DOCKER_DEPLOY == "true"
tags:
- lighthouse-docker
# 嵌入
include:
......
FROM nginx:1.26.0
LABEL maintainer="徐晓伟 <xuxiaowei@xuxiaowei.com.cn>"
ARG CI_PIPELINE_URL
ENV CI_PIPELINE_URL=${CI_PIPELINE_URL}
ADD public /usr/share/nginx/html/gitlab-k8s
ADD docker/nginx.conf /etc/nginx/conf.d/default.conf
RUN sed -i '/http {/a\ server_tokens off;' /etc/nginx/nginx.conf
services:
gitlab-k8s:
image: ${CI_REGISTRY_IMAGE}:${DOCKER_TAG}-${CI_PIPELINE_ID}
restart: always
ports:
- ${GITLAB_K8S_PORT:-45650}:80
volumes:
- /gitlab-k8s/logs:/var/log/nginx
container_name: gitlab-k8s
server {
listen 80;
listen [::]:80;
server_name localhost;
server_tokens off;
access_log /var/log/nginx/gitlab-k8s.access.log main;
error_log /var/log/nginx/gitlab-k8s.error.log notice;
location / {
root /usr/share/nginx/html/gitlab-k8s;
index index.html index.htm;
}
location /gitlab-k8s {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册