Skip to content

Regression fix: allow multiple docker projects of the same govcms project at the same time #126

@silverham

Description

@silverham

See quick fix solution PR [#125 ]

Due to the container_name in the docker-compose.yml for the service cli not being dynamic (or absent which infers it being dynamic automatically), if i run two two of the same govcms projects with the same name, I get a naming conflict.

Preferred solution: use additional_contexts to container depending locally on each other.
@see https://docs.docker.com/compose/how-tos/dependent-images/#use-another-services-image-as-the-base-image

Quick fix solution (this PR):
-> Remove container_name (so its dynamic)
-> Set image name to be dynamic so other dependancies so the new image name built. (not preferred because docker compose build --pull breaks.


Fixes regression caused by: #91

Workaround in docker.compose.override.yml:
(make sure to replace MYPROJECT with your project name).

# This value intentionally matches the project name on Lagoon.
# It is used to name the CLI_IMAGE to use as a build arg locally.
x-lagoon-project: &lagoon-project
  ${COMPOSE_PROJECT_NAME:-MYPROJECT}

services:
  cli:
    # Set new name for image name, and override in images below, as govcms does
    # not use additional_contexts, so our created image matches in dependant
    # docker images.
    # https://docs.docker.com/compose/how-tos/dependent-images/#use-another-services-image-as-the-base-image
    # Also we can't use `--pull` in `docker compose build --no-cache --pull`,
    # for dependant images as the docker file does not know it's built locally,
    # so it fails pull and so cancels the opteration fails completely.
    # https://github.com/moby/moby/issues/46280#issuecomment-1686762697
    image: *lagoon-project
    # Reset value to null, so we can have multiple different docker containers
    # without name conflict.
    # @see https://github.com/compose-spec/compose-spec/pull/340
    container_name: !reset
  test:
    build:
      args:
        CLI_IMAGE: *lagoon-project
  nginx:
    build:
      args:
        CLI_IMAGE: *lagoon-project
  php:
    build:
      args:
        CLI_IMAGE: *lagoon-project

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions