Skip to content

Commit

Permalink
feat: support dockerfile with multi openssl version
Browse files Browse the repository at this point in the history
  • Loading branch information
cavivie committed Mar 28, 2024
1 parent 25918c3 commit 3589566
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 35 deletions.
52 changes: 52 additions & 0 deletions .github/actions/docker-build-push/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: 'Docker image build and push'
description: 'Docker image build and push'
inputs:
push:
description: 'Docker push after build'
default: true
registry:
description: 'Docker image registry'
default: 'ghcr.io'
image:
description: 'Docker image name'
# github.repository as <account>/<repo>
default: '${{ github.repository }}'
tag:
description: 'Docker image tag'
required: true
context:
description: 'Docker build context'
default: '.'
file:
description: 'Dockerfile in context'
default: 'Dockerfile'
shell:
description: 'Shell to execute command'
default: 'bash'
runs:
using: "composite"
steps:
# Export required GitHub Actions envrionment variables,
# vcpkg will now upload or restore packages from the actions cache.
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
# Build docker image with vcpkg cache options: (x-gha: github-cache-token).
- name: Build docker image ${{ inputs.registry }}/${{ inputs.image }}:${{ inputs.tag }}
run: |
docker build \
--build-arg VCPKG_BINARY_SOURCES="clear;x-gha,readwrite" \
--build-arg ACTIONS_CACHE_URL="${{ env.ACTIONS_CACHE_URL }}" \
--build-arg ACTIONS_CACHE_URL="${{ env.ACTIONS_RUNTIME_TOKEN }}" \
-t "${{ inputs.registry }}/${{ inputs.image }}:${{ inputs.tag }}" ${{ inputs.context }}
shell: ${{ inputs.shell }}

# Push docker image to registry if the current github event is not pull request.
- name: Push docker image ${{ inputs.registry }}/${{ inputs.image }}:${{ inputs.tag }}
if: ${{ inputs.push }}
run: docker push "${{ inputs.registry }}/${{ inputs.image }}:${{ inputs.tag }}"
shell: ${{ inputs.shell }}
49 changes: 36 additions & 13 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ on:
pull_request:
branches: [ "main" ]

env:
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


jobs:
build:
runs-on: windows-2022
Expand All @@ -35,7 +29,7 @@ jobs:
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 # v3.1.1
with:
cosign-release: 'v2.1.1'

Expand All @@ -55,10 +49,39 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- run: docker build -t "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:chocolatey" chocolatey
- run: docker build -t "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:rust-windows" rust-windows
- run: docker build -t "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:rsxe-windows" rsxe-windows
- run: docker push "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:rsxe-windows"
- run: docker push "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:rust-windows"
- run: docker push "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:chocolatey"
# Export required GitHub Actions envrionment variables,
# vcpkg will now upload or restore packages from the actions cache.
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Build and push docker image for win-dev-base
uses: ./.github/actions/docker-build-push
with:
push: github.event_name != 'pull_request'
tag: win-dev-base
context: win-dev-base

- name: Build and push docker image for win-dev-rust
uses: ./.github/actions/docker-build-push
with:
push: github.event_name != 'pull_request'
tag: win-dev-rust
context: win-dev-rust

- name: Build and push docker image for alrd-windows
uses: ./.github/actions/docker-build-push
with:
push: github.event_name != 'pull_request'
tag: alrd-windows
context: win-alrd-rsxe

- name: Build and push docker image for rsxe-windows
uses: ./.github/actions/docker-build-push
with:
push: github.event_name != 'pull_request'
tag: rsxe-windows
context: win-alrd-rsxe
4 changes: 0 additions & 4 deletions chocolatey/Dockerfile

This file was deleted.

14 changes: 0 additions & 14 deletions rsxe-windows/Dockerfile

This file was deleted.

4 changes: 0 additions & 4 deletions rust-windows/Dockerfile

This file was deleted.

17 changes: 17 additions & 0 deletions win-alrd-rsxe/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM ghcr.io/automesh-network/dockerfiles:win-dev-rust

RUN vcpkg install openssl:x64-windows openssl:x64-windows-static openssl:x64-windows-static-md
RUN vcpkg install openssl:x86-windows openssl:x86-windows-static openssl:x86-windows-static-md
RUN vcpkg install openssl:arm64-windows openssl:arm64-windows-static openssl:arm64-windows-static-md

RUN choco install git strawberryperl just -y

ARG RUST_STABLE_VERSION=1.76
ARG RUST_NIGHTLY_VERSION=2024-02-08
RUN rustup install $env:RUST_STABLE_VERSION
RUN rustup default $env:RUST_STABLE_VERSION
RUN rustup install nightly-$env:RUST_NIGHTLY_VERSION

ADD https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.ps1 /install-from-binstall-release.ps1
RUN C:\install-from-binstall-release.ps1
RUN cargo binstall --secure --no-confirm cargo-tarpaulin cargo-audit cargo-nextest
18 changes: 18 additions & 0 deletions win-dev-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM mcr.microsoft.com/windows/servercore:ltsc2022

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue'; $verbosePreference='Continue';"]
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

RUN choco install visualstudio2022buildtools -y --package-parameters '--quiet --wait --norestart --add Microsoft.Component.MSBuild --add Microsoft.VisualStudio.Component.Windows11SDK.22621 --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.VC.Tools.ARM64'
RUN choco install git -y

ARG VCPKG_BINARY_SOURCES=
ARG ACTIONS_CACHE_URL=
ARG ACTIONS_RUNTIME_TOKEN=
ARG VCPKG_ROOT="C:\\vcpkg"
ARG VCPKG_VERSION=2024.03.25
RUN git clone https://github.com/microsoft/vcpkg.git $env:VCPKG_ROOT
RUN git -C $env:VCPKG_ROOT checkout $env:VCPKG_VERSION
RUN & "$env:VCPKG_ROOT\bootstrap-vcpkg.bat -disableMetrics"
RUN [Environment]::SetEnvironmentVariable('VCPKG_ROOT', $env:VCPKG_ROOT, [EnvironmentVariableTarget]::Machine)
RUN [Environment]::SetEnvironmentVariable('PATH', $env:PATH + ';' + $env:VCPKG_ROOT, [EnvironmentVariableTarget]::Machine)
3 changes: 3 additions & 0 deletions win-dev-rust/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM ghcr.io/automesh-network/dockerfiles:win-dev-base

RUN choco install rustup.install -y

0 comments on commit 3589566

Please sign in to comment.