woodpecker-ci / woodpecker

Woodpecker is a simple, yet powerful CI/CD engine with great extensibility.
https://woodpecker-ci.org
Apache License 2.0
4.31k stars 372 forks source link

Docker Backend: fully support windows container #4381

Open 6543 opened 1 week ago

6543 commented 1 week ago

close #4286 address one bug described in https://github.com/woodpecker-ci/woodpecker/issues/4274

TODO: actuall testing of:

codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 90.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 27.64%. Comparing base (5c22047) to head (35c7fe9). Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
pipeline/backend/docker/convert_win.go 88.46% 2 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #4381 +/- ## ========================================== + Coverage 27.58% 27.64% +0.06% ========================================== Files 382 383 +1 Lines 27922 27950 +28 ========================================== + Hits 7703 7728 +25 - Misses 19532 19534 +2 - Partials 687 688 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.


🚨 Try these New Features:

6543 commented 5 days ago

image

 ./dist/woodpecker-agent.exe --backend-engine docker --backend-docker-host "npipe:////./pipe/docker_engine"
6543 commented 5 days ago

image

look's like it works :)

the only thing is i had to modify the clone plugin:

--- a/plugins/plugin-git/Dockerfile.Windows
+++ b/plugins/plugin-git/Dockerfile.Windows
@@ -1,7 +1,7 @@
 # syntax = docker/dockerfile:1
 # escape=`

-FROM mcr.microsoft.com/windows/servercore:ltsc2022
+FROM mcr.microsoft.com/windows/servercore:1809

 # Busybox Unicode https://github.com/rmyorston/busybox-w32
6543 commented 5 days ago

so yes woodpecker itselve wont support windows container fully ... ... mostly depending on:

6543 commented 5 days ago

PS: I still have no idea why some things work and some are incompatible :/

image

6543 commented 5 days ago

my test config: .woodpecker/check.yaml:

labels:
  backend: docker
  platform: windows/amd64

skip_clone: true

depends_on:
    - echo

steps:
    check_echo:
        image: mcr.microsoft.com/windows/servercore:1809
        commands:
            - echo some checks
            - sleep 2s

.woodpecker/echo.yaml:

labels:
  backend: docker
  platform: windows/amd64

when:
  - event: pull_request
  - event: [push, deployment]
    branch:
      - ${CI_REPO_DEFAULT_BRANCH}

clone:
  clone:
    image: woodpecker-windows-git

steps:
    createFile:
        image: mcr.microsoft.com/windows/servercore:1809
        commands:
            - echo FROM alpine:edge >> Dockerfile
            - echo RUN apk update >> Dockerfile

    echo:
        image: mcr.microsoft.com/windows/servercore:1809
        commands:
            - echo buildZ
            - sleep 10s
            - ls
    depl:
        image: bash
        commands: echo deploy
        when:
            - event: deployment
              branch: ${CI_REPO_DEFAULT_BRANCH}
6543 commented 5 days ago

image

6543 commented 5 days ago

@cduchenoy :point_up: ...?

cduchenoy commented 4 days ago

Hi,

It's excellent!

On Windows, we must take the tag which corresponds to the kernel version

see https://hub.docker.com/r/microsoft/windows-servercore

So I think I should check :)

did you also test the agent build?

https://github.com/GECO-IT/woodpecker-windows/blob/main/agent/backend-docker/Dockerfile.Windows

cduchenoy commented 4 days ago

For test a service image, you can use as a base: https://github.com/GECO-IT/woodpecker-windows/blob/main/base/windows-base/Dockerfile.base-chocolatey.Windows

Base image are in docker-hub: https://hub.docker.com/r/gecoit84/woodpecker-windows-base-chocolatey

and add:

choco install mysql

I haven't tried so I don't know if it launches the service correctly

6543 commented 4 days ago

did you also test the agent build?

no as I only wana test if the engine works ... so the deployment of the agent should not alter the test ...

6543 commented 4 days ago

For test a service

ah nice ... will do so

6543 commented 4 days ago

image image

labels:
  backend: docker
  platform: windows/amd64

skip_clone: true

steps:
    create:
        image: mcr.microsoft.com/windows/servercore:1809
        commands:
            - echo some checks > NEW
            - sleep 2s

    curl:
        image: a6543/woodpecker-windows-base-chocolatey:latest
        commands:
            - choco install -y curl
            - curl.exe -I http://caddy:80
            - curl.exe http://caddy:80/NEW

services:
    caddy:
        image: a6543/woodpecker-windows-caddy-static:latest
        ports:
            - 80

services work just fine ...