0

I'm trying to deploy symfony project in my localhost using docker. my env file :

# Environment for old Zend projects, must be one of: 'development', 'preproduction' or 'production'
APPLICATION_ENV=development
# Database password for prod environment (optional)
PROD_DB_PASSWORD=
# Database password for preprod environment (optional)
PREPROD_DB_PASSWORD=postgres
# Username on prod and preprod servers for dump.sh, eg: 'jimmy_bailleux', 'vincent_robic' (optional)
DUMPSH_SSH_LOG=

I have a script in deploy.sh file :

.......
# Récuperation des variables de style
source ./shell/style.sh
source ./shell/function.sh
trap_error() {
    err_report $(caller) 

    # @TODO: Peut être vérifier que l'instance deploy_$project_name exist
    if [ "${APPLICATION_ENV}" == "production" ] || [ "${APPLICATION_ENV}" == "preproduction" ]; then
        if [ -n "$project_name" ]; then
            docker exec -i deploy_$project_name curl -X POST -H 'Content-type: application/json' --data '{"text":"Une erreur est survenu lors de la mise à jour du projet *_`'$project_name'`_* `'$APPLICATION_ENV'`"}' $slack_webhook
        fi
    fi

    docker rm -f deploy_$project_name
}
..... // 

The deploy launch script using the env variable : dev, preprod, prod .. I launched ./deploysh and i selected the number of my project. I got an error :

Variable APPLICATION_ENV invalide

enter image description here

Khaled Boussoffara
  • 1,567
  • 2
  • 25
  • 53
  • Guessing you would need to load the `.env` file explicitly.by adding `source ./.env` as demonstrated in the [DotEnv Usage](https://symfony.com/doc/current/components/dotenv.html#usage) or `export $(grep -v '^#' ./.env | xargs)` to your deploy.sh script. See: [Set environment variables from file of key/value pairs](https://stackoverflow.com/q/19331497/1144627) – Will B. Mar 17 '20 at 21:24
  • Does this answer your question? [Set environment variables from file of key/value pairs](https://stackoverflow.com/questions/19331497/set-environment-variables-from-file-of-key-value-pairs) – Will B. Mar 17 '20 at 21:29

2 Answers2

1

Take care to your shell script EOL. It must be LF. also for your .env. :D

Rekwian
  • 152
  • 1
  • 9
0

I fixed the problem by converting all sh files format to LF to resolve shll script ELO problem compatibility from MAC OS to Windows 10 and i put my DAMP folder to :

c:\Users\current_user
Khaled Boussoffara
  • 1,567
  • 2
  • 25
  • 53