diff --git a/.github/workflows/windows-registry-build.yml b/.github/workflows/windows-registry-build.yml new file mode 100644 index 000000000..af3b28b31 --- /dev/null +++ b/.github/workflows/windows-registry-build.yml @@ -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 + diff --git a/hack/windows-registry/Dockerfile b/hack/windows-registry/Dockerfile new file mode 100644 index 000000000..b720454a3 --- /dev/null +++ b/hack/windows-registry/Dockerfile @@ -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"] diff --git a/hack/windows-registry/build.ps1 b/hack/windows-registry/build.ps1 new file mode 100644 index 000000000..4c06d0790 --- /dev/null +++ b/hack/windows-registry/build.ps1 @@ -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 diff --git a/hack/windows-registry/config.yml b/hack/windows-registry/config.yml new file mode 100644 index 000000000..38baf32c7 --- /dev/null +++ b/hack/windows-registry/config.yml @@ -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 diff --git a/hack/windows-registry/push.ps1 b/hack/windows-registry/push.ps1 new file mode 100644 index 000000000..749cc9597 --- /dev/null +++ b/hack/windows-registry/push.ps1 @@ -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