forge icon indicating copy to clipboard operation
forge copied to clipboard

Using docker image namespace with incremental build

Open dlaidlaw opened this issue 7 years ago • 0 comments

If you set an image name in the service.yaml that contains a namespace, then incremental builds fail because the incremental build attempts to run the generated image using a name that is created from the image name with namespace. The image name with namespace will have a '/' character in the name, which is invalid as a docker container name.

For example:

name: demo-user   # Demo user service

containers:
  - dockerfile: Dockerfile
    name: dma/demo-user
    rebuild:
      # Where our code lives inside the container.
      root: /app
      # The command used to rebuild our code inside the container.
      command: ./gradlew build
      # A list of input sources that get synced into the container prior to builds.
      sources:
      - build.gradle
      - settings.gradle
      - src

profiles:
  default:
    maxMemory: '320Mi'
    maxCpu: '0.5'
    memory: '256Mi'
    cpu: '0.2'

branch:
  '*': default

In the code above, the image name is set to dma/demo-user, where dma is the image namespace. Using the incremental build, forge attempts to run the generated image using: docker run --rm --name forge_dma/demo-user_bigshastringhere. The slash (/) is invalid in a container name.

Forge should replace the slashes in the name with underscores or dashes or dots (_, -, .) which are legal characters in the name.

dlaidlaw avatar Nov 15 '18 19:11 dlaidlaw