Commit 5a96ffc8 authored by Andreas Jensen Jonassen's avatar Andreas Jensen Jonassen
Browse files

Merge branch 'feature/ci-cd' into 'master'

Basic CI/CD implementation

See merge request !1
parents d9704ef3 62dbd958
Pipeline #111988 passed with stages
in 1 minute and 56 seconds
image: docker
services:
- docker:dind
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/reference/pip_install/#caching
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
paths:
- .cache/pip
stages:
- build
- test
- deploy
.python_version_template:
image: python:3.7
.build_install: &build_install |
cd backend/secfit
pip install -r requirements.txt
build:
stage: build
extends: .python_version_template
script:
- *build_install
test:
stage: test
extends: .python_version_template
script:
- *build_install
- python manage.py test
deploy-prod:
stage: deploy
only:
- master
before_script:
#- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
#- mkdir -p ~/.ssh
#- eval $(ssh-agent -s)
#- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- echo "This runs some script before deploying something from the $CI_COMMIT_BRANCH branch."
script:
## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
## We're using tr to fix line endings which makes ed25519 keys work
## without extra base64 encoding.
## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
##
##
## Create the SSH directory and give it the right permissions
##
## Download all the required programs and set up the docker container
#- ssh-add <(echo "$SSH_PRIVATE_KEY")
#- ssh -o StrictHostKeyChecking=no root@51.15.210.221 'date'
#- ssh -o StrictHostKeyChecking=no root@51.15.210.221 "apt-get update"
#- ssh -o StrictHostKeyChecking=no root@51.15.210.221 "apt-get install -y python-pip"
#- scp -o stricthostkeychecking=no -r * root@51.15.210.221:/root
#- ssh -o StrictHostKeyChecking=no root@51.15.210.221 "cd /root"
#- ssh -o StrictHostKeyChecking=no root@51.15.210.221 "apt install apt-transport-https ca-certificates curl software-properties-common -y"
#- ssh -o StrictHostKeyChecking=no root@51.15.210.221 "curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -"
#- ssh -o StrictHostKeyChecking=no root@51.15.210.221 'add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" -y'
#- ssh -o StrictHostKeyChecking=no root@51.15.210.221 "apt update"
#- ssh -o StrictHostKeyChecking=no root@51.15.210.221 "apt install docker-ce -y"
#- ssh -o StrictHostKeyChecking=no root@51.15.210.221 "docker image prune -f"
#- ssh -o StrictHostKeyChecking=no root@51.15.210.221 "curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose"
#- ssh -o StrictHostKeyChecking=no root@51.15.210.221 "chmod +x /usr/local/bin/docker-compose"
#- ssh -o StrictHostKeyChecking=no root@51.15.210.221 "docker-compose build --no-cache"
#- ssh -o StrictHostKeyChecking=no root@51.15.210.221 "docker-compose up -d"
- echo "This job deploys something from the $CI_COMMIT_BRANCH branch."
environment: production
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment