.gitlab-ci.yml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # https://docs.gitlab.com/ee/ci/yaml/
  2. # https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
  3. # https://docs.gitlab.com/ee/ci/migration/github_actions.html
  4. # https://gitlab.com/gitlab-org/gitlab/-/tree/master/lib/gitlab/ci/templates/Jobs
  5. stages:
  6. - build
  7. variables:
  8. PUB_DOCKER_USER: "niliaerith"
  9. PUB_DOCKER_IMAGE_NAME: $PUB_DOCKER_USER/$CI_PROJECT_NAME
  10. PRI_DOCKER_USER: "nili"
  11. PRI_DOCKER_IMAGE_NAME: $PRI_DOCKER_URL/$CI_PROJECT_NAME
  12. 构建Docker镜像:
  13. stage: build
  14. # Use the official docker image.
  15. tags:
  16. - gxy
  17. image: docker:dind
  18. #image: docker:latest
  19. #image: docker:cli
  20. #services:
  21. # - name: docker:dind
  22. # command: ["--registry-mirror=https://dhcr-cf.niliovo.top"]
  23. before_script:
  24. - docker run --privileged --rm tonistiigi/binfmt --install all
  25. - docker buildx create --use --name mybuilder
  26. - docker login -u "$PRI_DOCKER_USER" -p "$DOCKER_PASSWORD" $PRI_DOCKER_URL
  27. - TIME=$(TZ='UTC-8' date +'%Y%m%d-%H-%M-%S')
  28. # All branches are tagged with $DOCKER_IMAGE_NAME (defaults to commit ref slug)
  29. # Default branch is also tagged with `latest`
  30. script:
  31. - docker buildx build --file Dockerfile --progress=plain --tag "$PRI_DOCKER_IMAGE_NAME:latest" --tag "$PRI_DOCKER_IMAGE_NAME:$TIME" --platform linux/amd64,linux/arm64 --push .
  32. #linux/amd64,linux/arm64,linux/386,linux/arm/v7
  33. # Run this job in a branch where a Dockerfile exists
  34. rules:
  35. - if: $CI_COMMIT_BRANCH
  36. exists:
  37. - Dockerfile
粤ICP备19079148号