How do I keep .env file in server safely and pass to cicd pipeline in build process in Gitlab CICD laravel dockerized application?

Viewed 21

I have a dockerize Laravel Application and when I want to buidl its image I get an error about .env. I dont know how should I pass it to container. I keep .env in server in another path. (/var/env/.env)

deploy-job:
  stage: deploy
  image: docker:latest
  only:
    - feature/cicd
  environment: production
  script:
    - echo "Deploying application..."
    - cp /var/env/.env .env
    - docker-compose -f docker-compose-prod.yml up -d
    - echo "Application successfully deployed."

I get this error: no such file or directory.. whats the best practice for this problem?

0 Answers
Related