6

I have created jobs for build and deploy.

The jobs are running perfectly without no errors and the project is deployed successfully.

The problem is though the repository is changed the build is not showing up the changes when tested in the browser although the workspace is successfully pulling the latest code with changes.

Few tried solutions

  1. Made the docker image build not use the cache

  2. Made the workspace clear before starting the build

Nothing seems working. Where might have things gone wrong?

My project structure:

Project directory: Which will have all the laravel project

Dockerfile: to build the image

docker-compose.yml: To deploy the service in docker stack

I am running the service in docker stack using docker stack deploy command

I tried to delete the previously build docker stack .By naming the docker stack unique with buildID and re-create a new stack but it didn't solve either.

On trying to remove the stack and generate that again. I get these issues.

Failed to remove network 7bkf0kka11s08k3vnpfac94q8: Error response from daemon: rpc error: code = FailedPrecondition desc = network 7bkf0kka11s08k3vnpfac94q8 is in use by task lz2798yiviziufc5otzjv5y0gFailed to remove some resources from stack: smstake43
  1. Why is the docker stack not taking the updated image looks like it's due to the digest issue. How can it be solved if it is? Though the changes are pushed to Btbucket code repo the deployment is not showing changes due to it. If I completely do all the setup then only it fetches the latest codes.

This is bash scripts for build in jenkins jobs

#!/bin/sh
 
docker build -t smstake:latest .
docker stack deploy -c docker-compose.yml smstake
ycr
  • 12,828
  • 2
  • 25
  • 45
Tara Prasad Gurung
  • 3,422
  • 6
  • 38
  • 76
  • did you have pipeline of jobs? cause you mentioned `build` and `deploy` jobs you have configured. Suggestion from my end is you are may be forgetting to build your code using docker build. – SV Madhava Reddy Mar 26 '18 at 09:06
  • `docker build -t .` like this in your build step after pulling the latest code. You may be deploying the same image again and again. – SV Madhava Reddy Mar 26 '18 at 09:07
  • @SVMadhavaReddy I have build the image and have also added the remove command before building it to ensure if there exist one already. But that didn't help either. – Tara Prasad Gurung Mar 26 '18 at 17:46
  • You should be push the image also to a docker registry if you have multiple nodes. Are you using a local+single manager+node? – Tarun Lalwani Mar 29 '18 at 03:49
  • yes was doing kind of that previously but I also have insecure registries created and the images is pushed and pulled from there. Checking the jenkins build jobs shows latest project but in container its passing older image. @TarunLalwani – Tara Prasad Gurung Mar 29 '18 at 04:35
  • See if the utility mentioned in this https://github.com/moby/moby/issues/31068 helps? – Tarun Lalwani Mar 29 '18 at 04:37
  • Here is one solution i have found. Pushing and pulling from private repository than removing the stack before deploying `docker stack rm ` This is working but the build fails and than pass consecutively. This is the error I am getting on fail jobs.`Removing service smstake_app Removing service smstake_db Removing service smstake_phpmyadmin Removing network smstake_smstake Creating service smstake_db failed to create service smstake_db: Error response from daemon: network smstake_smstake not found Build step 'Execute shell' marked build as failure Finished: FAILURE` – Tara Prasad Gurung Mar 29 '18 at 04:59
  • Did you try to build the dockerimage with a unique tag rather than the default _latest_ ? – db80 Apr 03 '18 at 20:49
  • 1
    I have solved it by using `sed` to pass the value to the image field in the docker-compose.yml. by using some keys there based on which replace will occur. It was not accepting the variable so did so. – Tara Prasad Gurung Apr 04 '18 at 03:24

0 Answers0