Docker Community Forums

Share and learn in the Docker community.

Docker build in gitlab ci


(User1989) #1

My gitlab-ci.yml file contains the build script and path to build tools to use such as curl.exe, jfrog etc. The build generates artifacts.The artifact contains libraries/binaries and .exe application in ZIP format. These artifacts are delivered to artifactory. How can I dockerize this build? Can I create images for the build tools? I am using gitlab ci/cd and windows server 2012. the build tools are installed manually on this windows server. The gitlab runner uses shell as executor. How can I generate artifacts using docker build?


(Agowa338) #2

gitlab-runner currently don’t support docker executor on windows, so you can only do one of these:
- Update your windows server 2012 to either windows server 2016, 1809 or 1903 and install docker.
- Install another server/vm with windows server 2016/1809/1903/… (1809, 1903 are the half-annual version of windows server, these have the newest features, but are not supported by microsoft, 2016 is the lts version of windows server) And run docker build --no-cache --pull . inside there. Also you need to tag your runners to use multiple ones inside a single gitlab-ci.yml file.
- Wait until gitlab-runner supports docker executor on windows for using the same steps for building a windows container as on linux (by pulling the docker in docker container and building inside there)
- Sync your repository by using the gitlab-ee mirror feature to github and add it at dockerhub as an automated repository. Than enable webhooks and call the hook from gitlab after every push. So your image is build directly at dockerhub (also everyone can see your Dockerfile there).


(User1989) #3

Okay Thank you. I have installed docker toolbox on windows server 2012 R2. I can try to build/run docker image locally without using gitlab-runner to test the builds locally?


(Agowa338) #4

If you have installed docker toolbox, you can run “docker build .”? (Haven’t used docker on 2012R2)
If so, you just have to put docker build . into you gitlab-ci.yml for execution on that runner. So what’s exactly the problem?
Are you trying to build a container by utilizing these artifacts? Or
Are you trying to build a container for your “build chain”?


(User1989) #5


(Agowa338) #6

You missed the dot at the end.
Your command is gitlab-runner.exe exec shell docker build and not gitlab-runner.exe exec shell docker build .


(User1989) #7

Okay thank you so much will try it now. If I mention the build path or “build context” (i.e. current directory ‘.’) is enough right? should i change the executor to “docker” in runner config.toml file ?


(Agowa338) #8

You cannot change the executor to docker right now. This is unsuported for windows hosts (also there is currently no gitlab-runner-helper container for windows).
You have to deal with the shell executor for now.

And I wrote the wrong commands before. It should actually be:
gitlab-runner.exe exec shell build


(User1989) #9

Okay Thank you so much once again.