Force Rebuild of Image From CI file

Here’s what we’re experiencing.

First time I run the CI Pipeline - everything works fine. On subsequent builds - the original image is left in place and new ones are generated - while in deploy it continues to call the original (oldest) image.

We can resolve the issue by going in and manually deleting the image prior to re-running the pipeline…but I think we’re missing something in the CI file so that the pipeline replaces the image on each build with the newest version.

Can you see anything we’re missing in this? (I’m just putting in the build and deploy sections - because I think the problem is in build) Thanks in advance!

build:develop:
stage: build
script:
- docker build -f docker/drupal/Dockerfile --no-cache --rm -t hub.mycompany.io/mycompany/mycompanysite:development .
- docker login --username="$HUB_USER" --password="$HUB_PASSWORD" hub.mycompany.io
- docker push hub.mycompany.io/mycompany/mycompanysite:development
tags:
- build-dev.mycompany
only:
- development

deploy:develop:
stage: deploy
environment: development
variables:
DOCKER_HOST: $CI_DOCKER_HOST
DOCKER_TLS_VERIFY: 1
script:
- docker pull hub.mycompany.io/mycompany/mycompanysite:development;
- >-
docker service create
–label interlock.hostname="$ENV_HOSTNAME"
–label interlock.domain="$ENV_DOMAIN"
–label “traefik.docker.network”=“frontend”
–label “traefik.docker.port”=“80”
–label “traefik.docker.protocol”=“http”
–label “traefik.enable”=“true”
–label “traefik.frontend.passHostHeader”=“true”
–label “traefik.frontend.rule”=“Host:mycompanysite.dev.mycompany.io”
–name=“mycompanysite-dev”
–network frontend
hub.mycompany.io/mycompany/mycompanysite:development
||
docker service update mycompanysite-dev
tags:
- dev.mycompany
only:
- development