I can not figure this out I am trying to deploy a project from git to circleci but any time I try sending a new pull request and send it will have an error
Could not find a version that satisfies the requirement pipenv==2021.5.29 (from versions: ) No matching distribution found for pipenv==2021.5.29
and ModuleNotFoundError: No module named ‘_lzma’
WARNING: The Python lzma extension was not compiled. Missing the lzma lib?
Installed Python-3.6.3 to /root/.pyenv/versions/3.6.3
- pyenv global 3.6.3
- pyenv rehash
it will give me this error in the build_docker_image:Build docker image and if I ignore it and try and deploy it to qa or production it will fail.
here is the config.yml file code:
version: 2.1
orbs:
aws-cli: circleci/aws-cli@2.0.6
aws-ecr: circleci/aws-ecr@7.3.0
# CircleCI needs variables:
# AWS_DEFAULT_REGION, AWS_ECR_ID, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,
# PROD_TARGET_GROUP, STAGING_TARGET_GROUP, QA_TARGET_GROUP, CIRCLECI_SG_ID
jobs:
build_docker_image:
machine:
image: ubuntu-2004:202111-02
steps:
- checkout
- aws-cli/install
- run:
name: install python 3.6.3
command: |
pyenv install 3.6.3
pyenv global 3.6.3
- run:
name: Installing dependencies
command: |
set -ex
sudo update-ca-certificates
sudo apt-get update
sudo apt-get install -y build-essential python-setuptools python-dev
sudo apt-get install -y libpq-dev libjpeg-dev libssl-dev libffi-dev
sudo apt-get update && sudo apt-get install ca-certificates
pip install --upgrade pip
sudo update-ca-certificates
pip install --index-url=https://pypi.org/simple/ pipenv==2021.5.29
pip install boto3
pipenv install --system
- run:
name: Pulling environment variables
command: |
if [ "$CIRCLE_BRANCH" == 'production' ]; then
export ENV=production
elif [ "$CIRCLE_BRANCH" == 'staging' ]; then
export ENV=staging
else
export ENV=qa
fi
bash ./deployment/circleci/pull-variables ${ENV}
echo "export ENV=$ENV" >> $BASH_ENV
- run:
name: Declaration environmnets
command: |
echo "export $(cat .env | grep -v '#' | awk '/=/ {print $1}')" >> $BASH_ENV
- run :
name: Add circleci IP to SG
command: |
export public_ip_address=$(wget -qO- http://checkip.amazonaws.com)
echo got ip $public_ip_address
aws ec2 authorize-security-group-ingress --region "${AWS_DEFAULT_REGION}" --group-id "${CIRCLECI_SG_ID}" --protocol tcp --port 5432 --cidr "$public_ip_address"/32 || exit 1
echo Added IP to SG
- run:
name: Building static files
command: |
sed -i "s@credentials_key_id@${AWS_ACCESS_KEY}@" .boto
sed -i "s@credentials_secret_key@${AWS_SECRET_ACCESS}@" .boto
if [ "$CIRCLE_BRANCH" == 'production' ]; then
export $(cat .env | grep -v '#' | awk '/=/ {print $1}') && export AWS_STATIC_STORAGE_BUCKET_NAME=production-blue-manor-education-static && python manage.py collectstatic --no-input && python manage.py compress --force
elif [ "$CIRCLE_BRANCH" == 'staging' ]; then
export $(cat .env | grep -v '#' | awk '/=/ {print $1}') && export AWS_STATIC_STORAGE_BUCKET_NAME=staging-blue-manor-education-static && python manage.py collectstatic --no-input && python manage.py compress --force
elif [ "$CIRCLE_BRANCH" == 'qa' ]; then
export $(cat .env | grep -v '#' | awk '/=/ {print $1}') && export AWS_STATIC_STORAGE_BUCKET_NAME=qa-blue-manor-education-static && python manage.py collectstatic --no-input && python manage.py compress --force
else
echo 'This script is for production, staging, qa branches only'
fi
- run :
name: Delete circleci IP from SG
when: always
command: |
export public_ip_address=$(wget -qO- http://checkip.amazonaws.com)
aws ec2 revoke-security-group-ingress --region "${AWS_DEFAULT_REGION}" --group-id "${CIRCLECI_SG_ID}" --protocol tcp --port 5432 --cidr "$public_ip_address"/32
echo IP removed
- aws-ecr/build-and-push-image:
checkout: false
attach-workspace: true
account-url: AWS_ECR_ID
dockerfile: deployment/circleci/Dockerfile
path: .
repo: "${ENV}-blue-manor-education"
region: AWS_DEFAULT_REGION
tag: "backend-${CIRCLE_SHA1:0:7}"
- aws-ecr/build-and-push-image:
checkout: false
attach-workspace: true
account-url: AWS_ECR_ID
dockerfile: Dockerfile-nginx
path: deployment/circleci
repo: "${ENV}-blue-manor-education"
region: AWS_DEFAULT_REGION
tag: "nginx-${CIRCLE_SHA1:0:7}"
- persist_to_workspace:
root: ./
paths:
- ./
unit_tests:
docker:
- image: cimg/python:3.6
steps:
- checkout
- aws-cli/install
- setup_remote_docker
- attach_workspace:
at: ./
- run:
name: Declaration environmnets
command: |
echo "export $(cat .env | grep -v '#' | awk '/=/ {print $1}')" >> $BASH_ENV
- run:
name: Run unit-tests
no_output_timeout: 30m
command: |
sed -i "s@TAG@${CIRCLE_SHA1:0:7}@" deployment/circleci/testing/docker-compose.yml
sed -i "s@AWS_ECR_ID@${AWS_ECR_ID}@" deployment/circleci/testing/docker-compose.yml
sed -i "s@ENV@${ENVIRONMENT}@" deployment/circleci/testing/docker-compose.yml
cd deployment/circleci/testing && bash run-tests $ENVIRONMENT $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY
delete_docker_images:
machine:
enabled: true
steps:
- checkout
- aws-cli/install
- run:
name: Deleting the docker image
command: |
if !([ "$CIRCLE_BRANCH" == "production" ] || [ "$CIRCLE_BRANCH" == "qa" ] || [ "$CIRCLE_BRANCH" == "staging" ])
then
echo 'Deleting images for test branches'
aws ecr batch-delete-image --repository-name "qa-blue-manor-education" --image-ids imageTag=backend-${CIRCLE_SHA1:0:7} --region $AWS_DEFAULT_REGION
aws ecr batch-delete-image --repository-name "qa-blue-manor-education" --image-ids imageTag=nginx-${CIRCLE_SHA1:0:7} --region $AWS_DEFAULT_REGION
fi
database_migrations:
docker:
- image: cimg/python:3.6
steps:
- checkout
- aws-cli/install
- setup_remote_docker
- attach_workspace:
at: ./
- run:
name: Declaration environmnets
command: |
echo "export $(cat .env | grep -v '#' | awk '/=/ {print $1}')" >> $BASH_ENV
- run:
name: Running database migrations
no_output_timeout: 30m
command: |
sed -i "s@TAG@${CIRCLE_SHA1:0:7}@" deployment/circleci/migrations/docker-compose.yml
sed -i "s@PROJECT_NAME@blue-manor-education@" deployment/circleci/migrations/docker-compose.yml
sed -i "s@AWS_ECR_ID@${AWS_ECR_ID}@" deployment/circleci/migrations/docker-compose.yml
sed -i "s@ENV@${ENVIRONMENT}@" deployment/circleci/migrations/docker-compose.yml
cd deployment/circleci/migrations && bash migration_master $ENVIRONMENT $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY
deploy:
docker:
- image: cimg/python:3.6
steps:
- checkout
- attach_workspace:
at: ./
- run:
name: Declaration environmnets
command: |
echo "export $(cat .env | grep -v '#' | awk '/=/ {print $1}')" >> $BASH_ENV
- run:
name: Running deploy process
no_output_timeout: 30m
command: |
sed -i "s@TAG@${CIRCLE_SHA1:0:7}@" deployment/circleci/docker-compose.yml
sed -i "s@ENV@${ENVIRONMENT}@" deployment/circleci/docker-compose.yml
sed -i "s@AWS_ECR_ID@${AWS_ECR_ID}@" deployment/circleci/docker-compose.yml
curl -o ./ecs-cli https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-linux-amd64-latest
chmod +x ./ecs-cli
./ecs-cli configure profile --access-key $AWS_ACCESS_KEY_ID --secret-key $AWS_SECRET_ACCESS_KEY --profile-name default
./ecs-cli configure --cluster $ENVIRONMENT-blue-manor-education --region $AWS_DEFAULT_REGION --default-launch-type EC2
./ecs-cli compose -f deployment/circleci/docker-compose.yml --ecs-params deployment/circleci/ecs-params.yml --project-name "$ENVIRONMENT-blue-manor-education" \
service up --cluster-config default --target-group-arn ${TARGET_GROUP_ARN} --container-name nginx --container-port 8080 \
--role ecsServiceRole --force-deployment --timeout 30
workflows:
ci_cd:
jobs:
- build_docker_image
- unit_tests:
requires:
- build_docker_image
- delete_docker_images:
requires:
- unit_tests
- database_migrations:
requires:
- delete_docker_images
filters:
branches:
only:
- qa
- staging
- production
- deploy:
requires:
- database_migrations
filters:
branches:
only:
- qa
- staging
- production
I tried changing piping version and just getting rid of it and I asked chatgpt to see if it can do it and they all failed!.