Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gitlab ci cannot build windows container

I am trying to build windows container using https://gitlab.com, but I didnot find if this is supported or not.

I made a test with a really simple Dockerfile:

FROM mcr.microsoft.com/windows/servercore:ltsc2019
CMD echo "Hello World from Windows"

Using .gitlab-ci.yml

image: docker
services:
- docker:dind

variables:
  DOCKER_HOST: tcp://docker:2375
  DOCKER_DRIVER: overlay2

before_script:
  - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY

windows:
  stage: build
  script:
  - docker build -t ${CI_REGISTRY}/${CI_PROJECT_PATH}:${CI_COMMIT_REF_SLUG} . 
  - docker push ${CI_REGISTRY}/${CI_PROJECT_PATH}:${CI_COMMIT_REF_SLUG}

It fails with :

image operating system "windows" cannot be used on this platform
ERROR: Job failed: exit code 1

Looking for the documentation of gitlab-runner, it seems supported https://docs.gitlab.com/runner/executors/#selecting-the-executor.

Is there a way to build a windows container from the online service ?

like image 678
mpromonet Avatar asked Jan 27 '23 20:01

mpromonet


1 Answers

Since January 2020 it is possible to build a windows container using online service using the Windows Shared Runners (beta).

Today, we are happy to announce that Windows Shared Runners hosted by GitLab is available in beta. As we are starting to roll out this important service to our community, we invite you to help shape the direction of CI/CD tooling for the Windows ecosystem on GitLab.com

For instance, using the following .gitlab-ci.yml

windows:
  stage: build
  tags:
  - shared-windows
  - windows
  - windows-1809
  script:
  - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
  - docker build -t ${CI_REGISTRY}/${CI_PROJECT_PATH}:${CI_COMMIT_REF_SLUG} . 
  - docker push ${CI_REGISTRY}/${CI_PROJECT_PATH}:${CI_COMMIT_REF_SLUG}

With a simple Dockerfile

FROM mcr.microsoft.com/windows/servercore:ltsc2019
CMD echo "Hello World from Windows"

The pipeline execution result enter image description here

like image 72
mpromonet Avatar answered Jan 31 '23 09:01

mpromonet