Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Running within a Docker container

Andrew Williamson May 3, 2022

Hi all,

I've created a docker image with the Windows runner:

https://hub.docker.com/repository/docker/symtech/bitbucket-pipelines-runner

https://bitbucket.org/symtechnz/bitbucket-pipelines-runner-docker

This makes it easier to start a build farm, and makes it easier to reproduce the build environment. Ideally I would have liked to use NanoServer for a minimal image, but I found it difficult to install Git from command line so I used Chocolatey which is based on WindowsServerCore. I stuck with Chocolatey because it makes it convenient to install more SDKs onto the image.

I'd love it if this could be offered directly by Atlassian.

 

 

3 comments

Comment

Log in or Sign up to comment
Jonathan Martens May 8, 2022

Kudos! This might just be what I need for my builds. I will have a look at it more closely later.

Jonathan Martens May 12, 2022

It seems to work but a few remarks:

  • It does download a fixed version worker, not latest version. I think you can do this easily by dropping the version number from the URL
  • Your image can be leaner by installing choco-cleaner and concatenate it to the install line of the chocolately packages using `; choco-clean`, e.g.:
    `
    RUN choco install -y \
    git.install \
    openjdk \
    ; choco-cleaner

I took the liberty of using your start.ps1 powershells script and incorporate it into a .NET Framework 4.6.1 microsoft based image using Dockerfile with below content:

FROM mcr.microsoft.com/dotnet/framework/sdk:4.8

# Install Chocolatey
ADD install-choco.ps1 install-choco.ps1
RUN powershell c:\install-choco.ps1

# Install git and openjdk and choco-cleaner to minimize docker container layer(s)
RUN choco install -y \
choco-cleaner \
; choco-cleaner

RUN choco install -y \
git.install \
openjdk \
; choco-cleaner

ADD https://product-downloads.atlassian.com/software/bitbucket/pipelines/atlassian-bitbucket-pipelines-runner.zip bitbucket-pipelines-runner.zip
RUN powershell -Command Expand-Archive bitbucket-pipelines-runner.zip C:\bitbucket-pipelines-runner

#WORKDIR C:\bitbucket-pipelines-runner\bin
WORKDIR C:/bitbucket-pipelines-runner/bin

# Install start script modified to inculde environment variabeles
ADD start.ps1 start.ps1

RUN git config --system core.longpaths true

ENTRYPOINT ["powershell", "./start.ps1"]

Like Ocky Saktya likes this
Ocky Saktya
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 29, 2022

Newbie here, is there any example on how to use this runner in Bitbucket Pipeline?

TAGS
AUG Leaders

Atlassian Community Events