0

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?

Oleksandr Savchenko
  • 642
  • 3
  • 10
  • 35
  • `'8080:${PORT}'` This syntax hints that you want to expose the container on port 8080 on the host, but the internal app running in the container will have a variable port. Is that what you want? – yamenk Nov 28 '17 at 09:30

1 Answers1

1

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.

mlocher
  • 766
  • 5
  • 11
  • Sorry, I don't get the question. What is a feature of Codeship? Linked services are always able to communicate via the default ports, the external mapping is only required if you access the container from outside of that (Docker handled) network. – mlocher Nov 28 '17 at 09:43
  • feature that I can't pass env variable to configuration. When I'm trying to build container with `docker-compose build` I don't get this error – Oleksandr Savchenko Nov 28 '17 at 09:48
  • 1
    Codeship uses the compose file if you don't have a separate `codeship-services.yml` file available. But we don't support all of the features available via Compose. Plus we do support features not available via compose (like encrypted environment variables). Using environment variables within the services configuration is a feature we don't support. – mlocher Nov 28 '17 at 09:50
  • btw, with `jet` I can build images locally and use it for local deployment, am I right? – Oleksandr Savchenko Nov 28 '17 at 09:57
  • 1
    Yes, you can run your complete build via `jet` locally, including building the images and pushing them to remote registries or running any other deployment steps. See https://documentation.codeship.com/pro/builds-and-configuration/cli/#jet-steps for the docs on `jet steps`, which include links to pushing images, or running steps limited to specific branches. – mlocher Nov 28 '17 at 09:59