Skip to content

Latest commit

 

History

History
179 lines (132 loc) · 5.23 KB

File metadata and controls

179 lines (132 loc) · 5.23 KB

Woodpecker Windows Agent - Backend Docker

Tested environment

  • Windows Server 2019 core installation
  • Windows Server 2022 core installation
  • Docker >= 20.10
  • Woodpecker Agent v1.05 to v2.6.0 (version >= 2.6.1 KO)

Install Docker

Windows Features

Enable the Containers feature, and disable Windows Defender to stop it burning CPU cycles...

PS C:\> Install-WindowsFeature -Name Containers
PS C:\> Uninstall-WindowsFeature Windows-Defender
PS C:\> Restart-Computer -Force

Docker daemon

PS C:\> Invoke-WebRequest -UseBasicParsing -o install-docker-ce.ps1 `
  "https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1"

PS C:\> .\install-docker-ce.ps1 -DockerVersion "20.10.24"
PS C:\> Remove-Item -Path ".\install-docker-ce.ps1" -Force

Install Docker Plugins

  • Docker Compose
C:\> mkdir C:\ProgramData\docker\cli-plugins

C:\> curl -fSsLo C:\Windows\System32\docker-compose.exe ^
          https://github.com/docker/compose/releases/download/v2.24.4/docker-compose-windows-x86_64.exe

C:\> mklink C:\ProgramData\docker\cli-plugins\docker-compose.exe C:\Windows\System32\docker-compose.exe
  • Docker Buildx
C:\> curl -fSsLo C:\Windows\System32\docker-buildx.exe ^
          https://github.com/docker/buildx/releases/download/v0.17.1/buildx-v0.17.1.windows-amd64.exe

C:\> mklink C:\ProgramData\docker\cli-plugins\docker-buildx.exe C:\Windows\System32\docker-buildx.exe

Pull Windows Base Images

Any Docker containers you run on Windows Server will be based on Windows Server Core or Nano Server. View https://mcr.microsoft.com/en-us/product/windows/servercore/about

  • Windows 2019 Based
C:\> docker image pull mcr.microsoft.com/windows/servercore:ltsc2019
C:\> docker image pull mcr.microsoft.com/windows/nanoserver:ltsc2019
# optional: docker pull mcr.microsoft.com/windows/server:ltsc2019
  • Windows 2022 Based
C:\> docker image pull mcr.microsoft.com/windows/servercore:ltsc2022
C:\> docker image pull mcr.microsoft.com/windows/nanoserver:ltsc2022
# optional: docker pull mcr.microsoft.com/windows/server:ltsc2022

Build your own containers

Follow documentation or you can use images at https://hub.docker.com/search?q=gecoit84

C:\> docker pull gecoit84/woodpecker-agent:2.6.0
C:\> docker pull gecoit84/woodpecker-windows-base:latest
C:\> docker pull gecoit84/woodpecker-git-plugin:2.6.0

# retag for git trusted plugin
C:\> docker image tag gecoit84/woodpecker-git-plugin:2.6.0 ^
                      woodpeckerci/plugin-git:latest

Install Woodpecker Agent

Configuration

  • Copy directory agent\backend-docker to C:\ProgramData\woodpecker-docker

  • Get your SSL public cert file and copy to .\volumes\ssl (optional)

  • Copy and edit .env.sample to .env

  • Copy and edit .env.woodpecker-agent.sample to .env.woodpecker-agent

...
WOODPECKER_SERVER="woodpecker.xxx"
WOODPECKER_GRPC_SECURE="true"
WOODPECKER_GRPC_VERIFY="true"
WOODPECKER_MAX_WORKFLOWS="1"
WOODPECKER_AGENT_SECRET="xxx"
WOODPECKER_HOSTNAME="wp-windows-agent1"
  • Edit docker-compose.yml
  • Start your Woodpecker agent
PS C:\> cd C:\ProgramData\woodpecker-docker
PS C:\ProgramData\woodpecker-docker> docker compose up -d
[+] Running 1/1
 ✔ Container woodpecker-docker-agent-1  Started

PS C:\ProgramData\woodpecker-docker> docker compose logs agent
...
agent-1  |... starting Woodpecker agent with version '2.6.0' and backend
'docker' using platform 'windows/amd64' running up to 2 pipelines in parallel ...

Autostart at bootup

C:\> SCHTASKS /CREATE /SC ONSTART /TN "Geco-iT\Docker Woodpecker startup" ^
                  /TR "C:\ProgramData\woodpecker-docker\startup.cmd" /RU system

Create Clean Task Schedule

# Clean @eachday @02:00
C:\> SCHTASKS /CREATE /SC DAILY /TN "Geco-iT\Woodpecker Cleaner" /ST 02:00 /RU system ^
        /TR "C:\ProgramData\woodpecker-docker\geco-docker-woodpecker-prune.crond.cmd"

Pipeline Usage

---
labels:
  platform: windows/amd64
  backend: docker

workspace:
  base: C:\src

clone:
  git:
    # $ docker image tag \
    #        <REPO_URL>/woodpecker/woodpecker-git-plugin:latest \
    #        woodpeckerci/plugin-git:latest
    image: woodpeckerci/plugin-git
    pull: false

steps:
...