sixeyed / diamol

Code samples for the book "Learn Docker in a Month of Lunches"
https://www.manning.com/books/learn-docker-in-a-month-of-lunches
Creative Commons Attribution Share Alike 4.0 International
496 stars 259 forks source link

Ch11 exercise diamol/jenkins image out of date #54

Open brian4ko opened 1 year ago

brian4ko commented 1 year ago

Exercise Section 11.2 the infrastructure containers for jenkins (and probably GOGs)

Problem The jenkins containers is out of date with a lot of dependency errors so the default diamol job is never created. Gogs could also be out of date as well

Docker version PS C:\WINDOWS\system32> docker version Client: Cloud integration: v1.0.29 Version: 20.10.21 API version: 1.41 Go version: go1.18.7 Git commit: baeda1f Built: Tue Oct 25 18:08:16 2022 OS/Arch: windows/amd64 Context: default Experimental: true

Server: Docker Desktop 4.15.0 (93002) Engine: Version: 20.10.21 API version: 1.41 (minimum version 1.12) Go version: go1.18.7 Git commit: 3056208 Built: Tue Oct 25 18:00:19 2022 OS/Arch: linux/amd64 Experimental: true containerd: Version: 1.6.10 GitCommit: 770bd0108c32f3fb5c73ae1264f7e503fe7b2661 runc: Version: 1.1.4 GitCommit: v1.1.4-0-g5fd4c4d docker-init: Version: 0.19.0 GitCommit: de40ad0

Code version Please run git log -n 1 and paste the output. Administrator@GALVATRON MINGW64 /c/docker/diamol (master) $ git log -n 1 commit c8fd9a888d1a0b3d606af1b01dbe265de1cd4a02 (HEAD -> master, origin/master) Author: Brian XXXX brian@example.com Date: Sat Jan 7 13:03:47 2023 -0500

Brian's custom additions

Additional context I realize keeping the current images up-to-date is probably not a long term solution. So instead i am trying to rebuild your example with the jenkins/jenkins and gogs/gogs official images. I was able to get the jenkins container to see the GOGs git repo. However i have two issues:

  1. On the jenkins page, i cannot use the http://localhost:3000/diamol/diamol.git. I have to use the real IP address of Gogs repo. (How do the containers know how to translate localhost to my win10 IP address? i did edit my host file on my host and made the docker engine edit).

  2. More significant, I created a jenkins pipeline script from SCM pointing to Gogs repo (by IP address), but launching the first verify.bat script keeps returning "docker: not found error". Suggestions on google keep saying install "docker in your jenkins container" or ensure you have the PATH variable set with your shell path (which if im suppose to use my host doesn't make sense to me). I also have the docker plugins installed. Puzzled why it won't use my win10 powershell to launch the first verify script.

Hoping you can provide some high level manual steps to help me build your example and get it going using the jenkins and gogs images and what i could be missing.

Thanks very much for your time. Brian

Krokos11 commented 1 year ago

I have similar problem.

jeffrey-scannell commented 1 year ago

Ok so I think I was able to fix this. After you login to Jenkins and go to the notifications bell on the upper right it will show you that the plugins failed to load due to running an old version of Jenkins. It lists each plugin that fails and tells you the minimum version of Jenkins to run. I went through each plugin and the highest version was 2.319.1, so I did the following:

  1. Open diamol\images\jenkins\linux\Dockerfile and changed ARG JENKINS_VERSION="2.263.4" to ARG JENKINS_VERSION="2.319.1".
  2. Built a new image of Jenkins. docker image build --tag jeff-jenkins . (I probably could have called it diamol/jenkins:v2)
  3. Updated diamol\ch11\exercises\infrastructure\docker-compose.yml to use my image of jenkins. image: jeff-jenkins .
  4. Start the app docker-compose -f docker-compose.yml -f docker-compose-linux.yml up -d

Now when I login to jenkins the job is there. Hope this helps.

brian4ko commented 1 year ago

wow i had no idea that images folder was even there. Is that folder there just for reference placed by the author? Because when you run the docker-compose.yml file, i assume it's pulling the image from the internet since you see the progress bar (and i don't see how any of the docker-compose files know that folder even exists)

i tried out your suggestion and built a new image locally with that change, and it works! Thanks for sharing @Jeffrey!

I also just figured out an alternative workaround solution using the official jenkins and gogs docker hub images:

This took a long time to figure out but it seems to work as well...also the latest jenkins 2.385 is a lot nicer. It shows you a graphical table of the pipeline jobs as they are running...and you can click each stage to see the status and console output of each stage which is pretty nice. Hope this helps if anyone finds it useful.

jeffrey-scannell commented 1 year ago

Glad to help. I think I will try your solution for all the features you mentioned. Thanks for sharing the steps and research, @brian4ko!

alsdud154 commented 10 months ago

As @JeffreyScannell said, I checked the operation on Intel Mac after Jenkins change version. As of the date of writing the comment (2023-09-01), Jenkins version used 2.346.1. However, it did not work properly on the m1 Mac. Please refer to it.

mariachung commented 8 months ago

@alsdud154 I change Jenkins version to 2.361.1

You need to change code about OpenJDK that diamol used is deprecated. You can check it at https://github.com/docker-library/openjdk

So I edit code about jdk using https://github.com/corretto/corretto-docker/blob/137b6ef028776de9f49e638a072a9e478fc60257/11/jdk/alpine/3.15/Dockerfile

After that docker image build --tag alsdud-jenkins . And use alsdud-jenkins image instead diamol/jenkins

You can check Dockerfile in pr https://github.com/sixeyed/diamol/pull/64