Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create cicd pipeline #6

Open
buedaswag opened this issue Mar 19, 2022 · 0 comments
Open

create cicd pipeline #6

buedaswag opened this issue Mar 19, 2022 · 0 comments

Comments

@buedaswag
Copy link
Collaborator

we have this template, but it uses gitlab syntax, so we need to adapt it to whatever we chose to go with

image: "python:3.7-stretch"

variables:
    PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
    PYTHONPATH: $PYTHONPATH:.
    DOCKER_TAG: $CI_COMMIT_SHA
cache:
  paths:
    - .cache/pip
    - venv/

before_script:
  - python --version
  - apt-get update -qy
  - apt-get install -y python3-dev python3-pip
  - python3 -m venv venv
  - source venv/bin/activate
  - pip install -U pip
  - pip install -r server/requirements.txt
  - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'


stages:
  - lint
  - build
  - deploy

lint:
  stage: lint
  script:
    - pip install flake8
    - flake8 . --exclude venv

# Anchors (for reusability)
.job_template: &build_image
  # Boilerplate configuration of Docker
  services:
    - docker:19.03.13-dind
  variables:
    DOCKER_TLS_CERTDIR: "/certs"
  tags:
      - docker  # need to use a shared runner with the Docker tag

  image: docker:19.03.13
  before_script:
    - echo "Skipping global before_script"
  stage: build
  script:
    # Installing boto
    - apk add python3
    - apk add py-pip
    - pip install boto3

    # Building
    - cd infrastructure/deployment
    - chmod +x build_and_push.sh
    - ./build_and_push.sh


.job_template: &deploy_service
  stage: deploy
  before_script:
    # Overriding before_script with something more lightweight
    - python3 -m venv venv
    - source venv/bin/activate
    - pip install -U pip
    - pip install boto3
  script:
    # Deploying
    - cd infrastructure/deployment
    - >
      python deploy.py
      --cluster-name=$CLUSTER_NAME
      --service-name=$SERVICE_NAME
      --family=$TASK_FAMILY
      --image-url=$REPOSITORY_URL:$DOCKER_TAG
    - echo "Deployment successful"


# CD pipelines
build_image_staging:
  <<: *build_image
  environment:
    name: staging
  only:
    - staging


build_image_prod:
  <<: *build_image
  environment:
    name: production
  only:
    - master


deploy_service_staging:
  <<: *deploy_service
  environment:
    name: staging
  only:
    - staging

deploy_service_prod:
  <<: *deploy_service
  environment:
    name: production
  only:
    - master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant