indigo-dc / jenkins-pipeline-library

Jenkins pipeline library with common functionalities for CI/CD environments, mainly targeted for the implementation of the SQA baseline requirements from https://indigo-dc.github.io/sqa-baseline/
Apache License 2.0
11 stars 6 forks source link

docker-compose up don't respect pull policy #177

Open samuelbernardolip opened 2 years ago

samuelbernardolip commented 2 years ago

Version 2 releases are only running docker-compose up that only pull images on the first deployment. If an image changes it ignores the pull policy. To solve this issue is required that docker-compose pull runs before docker-compose up. An example of this solution to solve this issue: https://github.com/stephanlindauer/docker-compose-updater/blob/master/run.sh

Beside this, is also important in docker-compose.yml file to define the pull_policy property:

# Since 2020-05-07, the docker-compose spec also defines the "pull_policy" property for a service:
version: '3.7'

services:
  my-service:
    image: someimage/somewhere
    pull_policy: always

A reference of this detail would be also important in the documentation. Possible values are defined in docker-compose spec.

samuelbernardolip commented 2 years ago

For CI environment, the best approach to force all base images pull again and force build image with native docker, requires the following sequence of commands:

docker-compose rm -f -v -s
docker-compose pull 
docker-compose build --no-cache
docker-compose up -d

and also set

pull_policy: always

in service configuration.