Commit 06c62116 authored by Давид Ли's avatar Давид Ли

add ci cd

parent 56561978
stages:
- build
# - test
- deploy
services:
- postgres:13-alpine
variables:
POSTGRES_PASSWORD: postgres
before_script:
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY"
build:
stage: build
only:
- merge_requests
script:
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY"
- docker build -t "$CI_REGISTRY_IMAGE:$CI_PIPELINE_ID" -f ./docker/Dockerfile .
- docker push "$CI_REGISTRY_IMAGE:$CI_PIPELINE_ID"
image: docker
services:
- docker:dind
# test:
# stage: test
# only:
# - merge_requests
# script:
# - python3 manage.py test
deploy:
only:
- merge_requests
stage: deploy
image: docker/compose
variables:
DOCKER_HOST: "${SERVER_HOST}"
before_script:
- apk update && apk add openssh-client bash
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
script:
- docker-compose pull
- docker-compose up -d --remove-orphans
...@@ -19,30 +19,3 @@ services: ...@@ -19,30 +19,3 @@ services:
command: bash -c "python manage.py makemigrations --merge --noinput && command: bash -c "python manage.py makemigrations --merge --noinput &&
python manage.py migrate --noinput && python manage.py migrate --noinput &&
python manage.py runserver 0.0.0.0:8000" python manage.py runserver 0.0.0.0:8000"
redis:
image: redis
celery:
build:
dockerfile: docker/Dockerfile
command: celery -A core/celery.py worker -l info
volumes:
- .:/usr/src/app
depends_on:
- postgres
- redis
environment:
- TZ=Asia/Almaty
celery-beat:
build:
dockerfile: docker/Dockerfile
command: celery -A core/celery.py beat -l info
volumes:
- .:/usr/src/app
depends_on:
- postgres
- redis
environment:
- TZ=Asia/Almaty
Markdown is supported
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