AymDev
AymDev

Reputation: 7539

Swarm stack is deployed before the new images are pushed

I use CircleCI and the pipeline is as follows:

I just pushed my develop branch to my repository and faced a "Symfony4 new Controller page" on the development server after a successful message from CircleCI.

I logged via SSH in it and executed (with output for the application service):

docker stack ps my-development-stack  --format "{{.Name}} {{.Image}} {{.CurrentState}}"

my-stack_app.1    gitlab-image:latest-develop    Running 33 minutes ago


On my GitLab repository's registry, the application image has been "Last Updated" 41 minutes ago. The service's image has apparently been refreshed before with the last version.

Upvotes: 0

Views: 87

Answers (2)

AymDev
AymDev

Reputation: 7539

I found a workaround using a CircleCI scheduled workflow triggered by a CRON. I scheduled a nightly build workflow which will run every day at midnight.

Sample of my config.yml file

# Beginning of the config.yml
# ...

workflows:
    version: 2

    # Push workflow
    # ...

    # Nightly build workflow
    nightly-dev-deploy:
        triggers:
            - schedule:
                  cron: "0 0 * * *"
                  filters:
                      branches:
                          only:
                              - develop
        jobs:
            - build
            - test:
                requires:
                    - build
            - deploy-dev:
                requires:
                    - test

Read more about scheduled workflow with a nightly build example in the CircleCI official documentation


Looks more like a workaround to me. I'd be glad to hear how do you avoid this issue, which could lead to a better answer to the question.

Upvotes: 0

Soumen Mukherjee
Soumen Mukherjee

Reputation: 3262

Perhaps it is best ( though not ideal ) to introduce a delay between build and deploy , you can refer to this example here CircelCI Delay Between Jobs

Upvotes: 0

Related Questions