Untitled

mail@pastecode.io avatar
unknown
yaml
a month ago
1.5 kB
14
Indexable
Never
image: docker:latest

services:
  - docker:dind
  - selenium/standalone-chrome

variables:
  CI_REGISTRY_IMAGE: $CI_REGISTRY/group-five3/note-taking-app
  COMPOSE_PROJECT_NAME: nta-$CI_COMMIT_SHORT_SHA
  DOCKER_HOST: tcp://docker:2375
  DOCKER_DRIVER: overlay2

stages:
  - build
  - test
  - deploy

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

build:
  stage: build
  script:
    - docker compose build
    - docker compose push

test:
  stage: test
  before_script:
    - apk add --no-cache python3 py3-pip chromium-chromedriver chromium
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
  script:
    - docker compose pull
    - docker compose up -d
    - sleep 10
    - docker compose logs
    - python3 -m venv /venv
    - source /venv/bin/activate
    - pip install pytest selenium
    - pytest -v test_addingaHellonote.py
  after_script:
    - docker compose down

deploy:
  stage: deploy
  script:
    - docker compose pull
    - docker tag ${CI_REGISTRY_IMAGE}/backend:dev-${CI_COMMIT_SHORT_SHA} mekukun/note-backend:latest
    - docker tag ${CI_REGISTRY_IMAGE}/frontend:dev-${CI_COMMIT_SHORT_SHA} mekukun/note-frontend:latest
    - docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD
    - docker push mekukun/note-backend:latest
    - docker push mekukun/note-frontend:latest
    - echo "Deployed!"
  only:
    - main
Leave a Comment