So I need to store somewhere .env files for docker-compose. One approach is to store their contents in masked variables in gitlab CI/CD but it seems not secure for me as hacking quite a lot of apps would only take someone to crack a gitlab account.
I would like to store .env files in a directory on server and copy them to new pulled repository path in the first job of CI/CD. I tried artifacts for that, but they are uploaded to gitlab and can be viewed there and I didn't manage to find them in the later jobs (ls in after_script didn't show them).
How could I copy .env files into all jobs and not upload them on gitlab?
.gitlab-ci.yml
before_script:
- docker info
- docker compose --version
copy_env_files:
script:
- cp /home/myuser/myapp/env.* .
rules:
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"
artifacts:
paths:
- env.*
build_image:
script:
- docker-compose -f docker-compose.yml up -d --build
rules:
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"
artifacts:
paths:
- env.*
collect_static_files:
script:
- docker-compose exec web python manage.py collectstatic --no-input
rules:
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"
artifacts:
paths:
- env.*
migrate_database:
script:
- docker-compose exec web python manage.py migrate --no-input
rules:
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"
artifacts:
paths:
- env.*
after_script:
- docker container ls
- pwd
- ls
