crazyfactory / docker-project-cli

MIT License
4 stars 1 forks source link

fix: allow files defined in environments to replace main file #53

Closed dacgray closed 5 years ago

dacgray commented 5 years ago

Relevance

With this pattern:

{
  "file": "./docker-compose.yml",
  "environments": {
    "production": {
      "file": [
        "./docker-compose.prod.yml"
      ]
    }
  },
"start:prod": {
      "service": "@host",
      "command": [
          "dopr --env production up -d %args%",
          "@composer install --no-dev --prefer-dist --no-scripts --optimize-autoloader",
          "dopr setup",
          "echo Done!"
      ]
    },

When running dopr start:prod on prod we get:

WARNING: The NGINX_PROXY_PORT variable is not set. Defaulting to a blank string.
WARNING: The XDEBUG_REMOTE_HOST variable is not set. Defaulting to a blank string.
WARNING: The ELASTIC_SEARCH_PROXY_PORT variable is not set. Defaulting to a blank string.
WARNING: The REDIS_PROXY_PORT variable is not set. Defaulting to a blank string.
WARNING: The MYSQL_PROXY_PORT variable is not set. Defaulting to a blank string.

dopr forces us to define the dev environment vars we only use in docker-compose.yml in production.

The workaround is therefore to use docker-compose -f ... instead of dopr -env production up -d

Proposal

Allow no file defined if we define environments:

{
 // no file defined
  "environments": {
      "dev": {
          "file": "./docker-compose.yml"
      },
      "prod": {
          "file": "./docker-compose.prod.yml"
      }
  },

Right now this pattern gives us:

at least one docker-compose file is required to exist

adhocore commented 5 years ago

hmm at least one docker-compose file is required to exist makes sense.

it actually solves the requirement of

"environments": {
      "dev": {
          "file": "./docker-compose.yml"
      },
      "prod": {
          "file": "./docker-compose.prod.yml"
      }
  },

because we can have docker-compose.local.yml to do what each environment specific file would do

dacgray commented 5 years ago

yep, I'll close this.

After discussion and an agreement of standards at https://github.com/crazyfactory/standards/blob/master/docker.md this is no longer a problem.