Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update Dockerfile #1

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ name: Docker Image Build

on:
push:
branches: [ "main" ]

branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

permissions:
Expand Down Expand Up @@ -34,11 +35,16 @@ jobs:

# BuildX is not supported and should not be installed or configured
# Features such as multistage builds and cache support are not available
- name: Docker build and push
- name: Docker Build
run: |
$version = ((Invoke-WebRequest -Uri https://api.github.com/repos/actions/runner/releases/latest).Content | ConvertFrom-Json).tag_name -replace 'v',''
echo "Building with runner version v${version}" >> ${env:GITHUB_STEP_SUMMARY}
docker build --build-arg RUNNER_VERSION=$version -f Dockerfile -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:"v${version}" .
$hooks_version = ((Invoke-WebRequest -Uri https://api.github.com/repos/actions/runner-container-hooks/releases/latest).Content | ConvertFrom-Json).tag_name -replace 'v',''
echo "Building with runner hooks version v${hooks_version}" >> ${env:GITHUB_STEP_SUMMARY}
docker build --build-arg RUNNER_CONTAINER_HOOKS_VERSION=$hooks_version --build-arg RUNNER_VERSION=$version -f Dockerfile -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:"v${version}" .
- name: Docker Push
if: github.event_name != 'pull_request'
run: |
docker push -a ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}


25 changes: 14 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,36 @@ FROM mcr.microsoft.com/windows/servercore:ltsc2022
ARG RUNNER_OS=win
ARG RUNNER_ARCH=x64
ARG RUNNER_VERSION
ARG RUNNER_CONTAINER_HOOKS_VERSION=0.4.0
ARG DOCKER_VERSION=24.0.6
ARG RUNNER_CONTAINER_HOOKS_VERSION=0.5.1

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';$ProgressPreference='silentlyContinue';"]

WORKDIR /home/runner


RUN `
###############################
##############################################################
# Install Actions Runner
###############################
##############################################################
Invoke-WebRequest -Uri https://github.com/actions/runner/releases/download/v${env:RUNNER_VERSION}/actions-runner-${env:RUNNER_OS}-${env:RUNNER_ARCH}-${env:RUNNER_VERSION}.zip -OutFile actions-runner.zip; `
Add-Type -AssemblyName System.IO.Compression.FileSystem; `
[System.IO.Compression.ZipFile]::ExtractToDirectory('actions-runner.zip', $PWD); `
Remove-Item -Path actions-runner.zip -Force; `
###############################
# Install Runner Container Hooks
###############################
##############################################################
# Install Runner Container Hooks -- Not required for Windows
##############################################################
Invoke-WebRequest -OutFile runner-container-hooks.zip -Uri https://github.com/actions/runner-container-hooks/releases/download/v${env:RUNNER_CONTAINER_HOOKS_VERSION}/actions-runner-hooks-k8s-${env:RUNNER_CONTAINER_HOOKS_VERSION}.zip;`
[System.IO.Compression.ZipFile]::ExtractToDirectory('runner-container-hooks.zip', (Join-Path -Path $PWD -ChildPath 'k8s')); `
Remove-Item -Path runner-container-hooks.zip -Force; `
###############################
##############################################################
# Install Git Using Choco
###############################
##############################################################
Set-ExecutionPolicy Bypass -Scope Process -Force; `
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; `
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')); `
choco install git.install --params "'/GitAndUnixToolsOnPath'" -y; `
choco feature enable -n allowGlobalConfirmation
choco feature enable -n allowGlobalConfirmation; `
##############################################################
# Install Docker CLI Using Choco
##############################################################
choco install docker-cli docker-compose -force;