Search code examples
dockerconfigurationdocker-composecodeship

Codeship Jet: pass env variables to docker-compose file


I have docker-compose.yml with such content:

version: '3'
services:
  some_service:
    build:
      dockerfile: Dockerfile
    ports:
     - '8080:${PORT}'

And I have my codeship-steps.yml with:

- type: parallel
  steps:
    - service: some_service
      command: printenv

Also, I have .env file with:

PORT=8080

And when I'm trying to run locally jet steps I getting an error:

strconv.ParseInt: parsing "${PORT}": invalid syntax

I'm trying to pass this env variable in different ways, but I have no success. Is it possible at all or .env variables with Codeship are only for application inside docker and not for configuration?


Solution

  • Environment variables are not available inside the configuration files.

    That said, in most cases you also don't need to explicitly specify the external port for an exposed service. Especially in combination with parallel steps this can cause issues with multiple services trying to bind to the same port. Additionally, linked services will always be able to access the some_service service on port 8080.