Added Gitlab CI
This commit is contained in:
parent
0da3e595f7
commit
db76f640da
1 changed files with 40 additions and 0 deletions
40
.gitlab-ci.yml
Normal file
40
.gitlab-ci.yml
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
stages:
|
||||||
|
- test
|
||||||
|
- build
|
||||||
|
|
||||||
|
run_tests:
|
||||||
|
stage: test
|
||||||
|
image: python:3.12
|
||||||
|
variables:
|
||||||
|
DJANGO_SECRET_KEY: 'random_secret_key_for_ci'
|
||||||
|
before_script:
|
||||||
|
- python -m pip install --upgrade pip
|
||||||
|
- pip install --no-cache-dir -r requirements/base.txt
|
||||||
|
script:
|
||||||
|
- python manage.py test --verbosity=2
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_BRANCH == "main"
|
||||||
|
|
||||||
|
build_and_push:
|
||||||
|
stage: build
|
||||||
|
image: docker:24.0.7
|
||||||
|
variables:
|
||||||
|
DOCKER_HOST: tcp://docker:2375
|
||||||
|
DOCKER_TLS_CERTDIR: ''
|
||||||
|
services:
|
||||||
|
- name: docker:24.0.7-dind
|
||||||
|
alias: docker
|
||||||
|
command: ['--tls=false', '--host=tcp://0.0.0.0:2375']
|
||||||
|
script:
|
||||||
|
- echo "Waiting for Docker daemon..."
|
||||||
|
- for i in $(seq 1 30); do docker info && break || sleep 1; done
|
||||||
|
- echo "Logging in to registry ${REGISTRY_URL}"
|
||||||
|
- echo "$REGISTRY_PASSWORD" | docker login -u "$REGISTRY_USERNAME" --password-stdin "$REGISTRY_URL"
|
||||||
|
- export IMAGE_NAME="${REGISTRY_URL}/${IMAGE_PATH}:${IMAGE_TAG}"
|
||||||
|
- echo "Building image ${IMAGE_NAME}"
|
||||||
|
- docker build -t "$IMAGE_NAME" -f ./compose/prod/python/Dockerfile --no-cache .
|
||||||
|
- echo "Pushing image ${IMAGE_NAME}"
|
||||||
|
- docker push "$IMAGE_NAME"
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG
|
||||||
|
when: always
|
||||||
Loading…
Reference in a new issue