Skip to content

Conversation

@bomoko
Copy link
Contributor

@bomoko bomoko commented Aug 14, 2024

Currently, if one chooses to implement a base image solution -- that is, most of one's code being bundled in an upstream image shared by multiple projects/environments -- there is an issue with caching.

If the base image, say, container.reg/my/baseimage:latest, or indeed, anything that isn't injected explicitly into the build, the image is cached by the docker-host, and if you make changes to the upstream image, but container.reg/my/baseimage:latest is currently in the docker-host's cache, it's not going to pull the new upstream image.

This small change allows users to explicitly mark their services as using a base image, and specifying what the name of that image is via an optional label lagoon.base.image.

This leads to, for example, service definitions that look like so:

  cli: # cli container, will be used for executing composer and any local commands (drush, drupal, etc.)
    build:
      context: .
      dockerfile: lagoon/cli.dockerfile
    image: &cli-image ${COMPOSE_PROJECT_NAME:-drupal-base}-cli # this image will be reused as `CLI_IMAGE` in subsequent Docker builds
    labels:
      # Lagoon Labels
      lagoon.type: cli-persistent
      lagoon.persistent.name: nginx
      lagoon.persistent: /app/web/sites/default/files/ 
      lagoon.base.image: container.reg/my/baseimage:latest
      lando.type: php-cli-drupal
 <snip/>

On finding the label, the build-deploy-tool with attempt to pull the upstream image, which it will do if there have been updates.

@bomoko bomoko changed the title Fix - Adds --pull to docker build to support updating base images Feature - specify base images to refresh on deploy Aug 14, 2024
@bomoko bomoko marked this pull request as ready for review August 14, 2024 18:14
@bomoko bomoko requested a review from shreddedbacon August 15, 2024 17:13
@shreddedbacon shreddedbacon added this to the 2.21.0 milestone Aug 18, 2024
@shreddedbacon shreddedbacon force-pushed the fix/docker_pull_on_build branch from ad37826 to 9fc0c76 Compare August 19, 2024 01:02
@bomoko bomoko force-pushed the fix/docker_pull_on_build branch from 9fc0c76 to ad37826 Compare August 19, 2024 01:06
Copy link
Member

@shreddedbacon shreddedbacon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This solves the problem neatly, but also in a way that allows for expansion in the future if necessary.

@shreddedbacon shreddedbacon merged commit ad7dd3f into main Aug 20, 2024
@shreddedbacon shreddedbacon deleted the fix/docker_pull_on_build branch August 20, 2024 05:29
@shreddedbacon shreddedbacon changed the title Feature - specify base images to refresh on deploy feat: specify base images to refresh on deploy Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants