Skip to content

Commit

Permalink
Add workflow to create docker image with windows registry
Browse files Browse the repository at this point in the history
Signed-off-by: Joao Pereira <joaod@vmware.com>
  • Loading branch information
joaopapereira committed Feb 14, 2022
1 parent d903607 commit 1ff5946
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/windows-registry-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Registry in Windows container build

on:
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
goreleaser:
runs-on: windows-2022
permissions:
contents: read
packages: write
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Building image
shell: pwsh
run: |
cd hack\windows-registry
.\build.ps1
.\push.ps1
24 changes: 24 additions & 0 deletions hack/windows-registry/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM golang:1.17-windowsservercore-ltsc2022 as build

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

ENV DOCKER_BUILDTAGS include_oss include_gcs
ENV DISTRIBUTION_VERSION v2.8.0
ENV GO111MODULE off

RUN mkdir src\github.com\docker ; \
cd src\github.com\docker ; \
git clone -q https://github.com/docker/distribution ; \
cd distribution ; \
git checkout -q $env:DISTRIBUTION_VERSION ; \
go build -o registry.exe cmd/registry/main.go

FROM mcr.microsoft.com/windows/nanoserver:ltsc2022

COPY --from=build /go/src/github.com/docker/distribution/registry.exe /registry.exe
COPY config.yml /config/config.yml

EXPOSE 5000

ENTRYPOINT ["\\registry.exe"]
CMD ["serve", "/config/config.yml"]
4 changes: 4 additions & 0 deletions hack/windows-registry/build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Write-Host Building registry binary and image
$version=$(select-string -Path Dockerfile -Pattern "ENV DISTRIBUTION_VERSION").ToString().split()[-1].SubString(1)
docker build -t ghcr.io/tanzu-vmware/vmware-tanzu/carvel-imgpkg/registry-windows .
docker tag ghcr.io/tanzu-vmware/vmware-tanzu/carvel-imgpkg/registry-windows:latest ghcr.io/tanzu-vmware/vmware-tanzu/carvel-imgpkg/registry-windows:$version
18 changes: 18 additions & 0 deletions hack/windows-registry/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 0.1
log:
fields:
service: registry
storage:
cache:
blobdescriptor: inmemory
filesystem:
rootdirectory: /registry
http:
addr: :5000
headers:
X-Content-Type-Options: [nosniff]
health:
storagedriver:
enabled: true
interval: 10s
threshold: 3
3 changes: 3 additions & 0 deletions hack/windows-registry/push.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$version=$(select-string -Path Dockerfile -Pattern "ENV DISTRIBUTION_VERSION").ToString().split()[-1].SubString(1)
docker tag ghcr.io/tanzu-vmware/vmware-tanzu/carvel-imgpkg/registry-windows:$version ghcr.io/tanzu-vmware/vmware-tanzu/carvel-imgpkg/registry-windows:$version-2022
docker push ghcr.io/tanzu-vmware/vmware-tanzu/carvel-imgpkg/registry-windows:$version-2022

0 comments on commit 1ff5946

Please sign in to comment.