I have been tring to setup gitlab ci/cd config for a django project which will be deployed as a container.
This is what i have tried: CI/CD -
image: creatiwww/docker-compose:latest
services:
- docker:dind
stages:
- lint
- build
- deploy
variables:
TAG_LATEST: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:latest
TAG_COMMIT: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA
lint:
stage: lint
image: python:3.8
before_script:
- pip install pipenv
- pipenv install --dev
script:
- pipenv run python -m flake8 --exclude=migrations,settings.py backend
allow_failure: false
build:
stage: build
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY_IMAGE
- echo "IMAGE_APP_TAG=$TAG_LATEST" >> .env
- docker-compose build
- docker-compose push
only:
- master
deploy-to-prod:
stage: deploy
script:
- eval $(ssh-agent -s)
- echo "${ID_RSA}" | tr -d '\r' | ssh-add - > /dev/null
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY_IMAGE
- echo "IMAGE_APP_TAG=$TAG_LATEST" >> .env
- echo "SECRET_KEY=$SECRET_KEY" >> .env
- docker-compose -H "ssh://$SERVER_USER@$SERVER_IP" down --remove-orphans
- docker-compose -H "ssh://$SERVER_USER@$SERVER_IP" pull
- docker-compose -H "ssh://$SERVER_USER@$SERVER_IP" up -d
only:
- master
when: manual
The pipeline succeds but while checking the log of container i get following output-
python: can't open file 'manage.py': [Errno 2] No such file or directory
also my image field in docker ps is empty.
Please help