.gitlab-ci.yml 2.87 KB
Newer Older
Tulir Asokan's avatar
Tulir Asokan committed
1 2 3
image: docker:stable

stages:
4
- build frontend
Tulir Asokan's avatar
Tulir Asokan committed
5
- build
Tulir Asokan's avatar
Tulir Asokan committed
6
- manifest
Tulir Asokan's avatar
Tulir Asokan committed
7 8 9 10 11

default:
  before_script:
  - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY

12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
build frontend:
  image: node:lts-alpine
  stage: build frontend
  before_script: []
  variables:
    NODE_ENV: "production"
  cache:
    paths:
    - maubot/management/frontend/node_modules
  script:
  - cd maubot/management/frontend
  - yarn --prod
  - yarn build
  - mv build ../../../frontend
  artifacts:
    paths:
    - frontend
    expire_in: 1 hour

Tulir Asokan's avatar
Tulir Asokan committed
31
build amd64:
Tulir Asokan's avatar
Tulir Asokan committed
32
  stage: build
Tulir Asokan's avatar
Tulir Asokan committed
33 34
  tags:
  - amd64
Tulir Asokan's avatar
Tulir Asokan committed
35
  script:
Tulir Asokan's avatar
Tulir Asokan committed
36
  - echo maubot/management/frontend >> .dockerignore
Tulir Asokan's avatar
Tulir Asokan committed
37
  - docker pull $CI_REGISTRY_IMAGE:latest || true
38
  - docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 . -f Dockerfile.ci
Tulir Asokan's avatar
Tulir Asokan committed
39 40
  - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
  - docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
Tulir Asokan's avatar
Tulir Asokan committed
41

Tulir Asokan's avatar
Tulir Asokan committed
42 43 44 45
build arm64:
  stage: build
  tags:
  - arm64
Tulir Asokan's avatar
Tulir Asokan committed
46
  script:
Tulir Asokan's avatar
Tulir Asokan committed
47
  - echo maubot/management/frontend >> .dockerignore
Tulir Asokan's avatar
Tulir Asokan committed
48
  - docker pull $CI_REGISTRY_IMAGE:latest || true
49
  - docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64 . -f Dockerfile.ci
Tulir Asokan's avatar
Tulir Asokan committed
50 51
  - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64
  - docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64
Tulir Asokan's avatar
Tulir Asokan committed
52

Tulir Asokan's avatar
Tulir Asokan committed
53 54 55 56 57
manifest:
  stage: manifest
  before_script:
  - "mkdir -p $HOME/.docker && echo '{\"experimental\": \"enabled\"}' > $HOME/.docker/config.json"
  - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
Tulir Asokan's avatar
Tulir Asokan committed
58
  script:
Tulir Asokan's avatar
Tulir Asokan committed
59 60 61 62 63 64
  - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
  - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64
  - if [ $CI_COMMIT_BRANCH == "master" ]; then docker manifest create $CI_REGISTRY_IMAGE:latest $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64 && docker manifest push $CI_REGISTRY_IMAGE:latest; fi
  - if [ $CI_COMMIT_BRANCH != "master" ]; then docker manifest create $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64 && docker manifest push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME; fi
  - docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64

65

Tulir Asokan's avatar
Tulir Asokan committed
66
build standalone amd64:
67
  stage: build
Tulir Asokan's avatar
Tulir Asokan committed
68 69
  tags:
  - amd64
70 71
  script:
    - docker pull $CI_REGISTRY_IMAGE:standalone || true
Tulir Asokan's avatar
Tulir Asokan committed
72
    - docker build --pull --cache-from $CI_REGISTRY_IMAGE:standalone --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-standalone . -f maubot/standalone/Dockerfile
Tulir Asokan's avatar
Tulir Asokan committed
73 74
    - if [ $CI_COMMIT_BRANCH == "master" ]; then docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-standalone $CI_REGISTRY_IMAGE:standalone && docker push $CI_REGISTRY_IMAGE:standalone; fi
    - if [ $CI_COMMIT_BRANCH != "master" ]; then docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-standalone $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME-standalone && docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME-standalone; fi