Skip to content

Commit

Permalink
support for making windows and linux docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
LiliDeng committed Dec 18, 2024
1 parent eb6b3c7 commit 8c7ace7
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 8 deletions.
56 changes: 50 additions & 6 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,70 @@ on:
- main

jobs:
build:
build-windows:
runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Log in to Azure Container Registry
run: |
echo ${{ secrets.ACR_PASSWORD }} | docker login ${{ secrets.ACR_LOGIN_SERVER }} -u ${{ secrets.ACR_USERNAME }} --password-stdin
- name: Build and Push Windows Docker Image
run: |
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/${{ secrets.ACR_INTERNAL_REPOSITORY }}:${{ github.event.release.tag_name }}-windows -f Dockerfile.windows .
docker push ${{ secrets.ACR_LOGIN_SERVER }}/${{ secrets.ACR_INTERNAL_REPOSITORY }}:${{ github.event.release.tag_name }}-windows
- name: Log out from ACR
run: docker logout ${{ secrets.ACR_LOGIN_SERVER }}

build-linux:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Log in to Azure Container Registry
run: |
echo ${{ secrets.ACR_PASSWORD }} | docker login ${{ secrets.ACR_LOGIN_SERVER }} -u ${{ secrets.ACR_USERNAME }} --password-stdin
- name: Build and Push Linux Docker Image
run: |
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/${{ secrets.ACR_INTERNAL_REPOSITORY }}:${{ github.event.release.tag_name }}-linux -f Dockerfile.linux .
docker push ${{ secrets.ACR_LOGIN_SERVER }}/${{ secrets.ACR_INTERNAL_REPOSITORY }}:${{ github.event.release.tag_name }}-linux
- name: Log out from ACR
run: |
docker logout ${{ secrets.ACR_LOGIN_SERVER }}
build-multi-platforms:
runs-on: ubuntu-latest
needs: [build-windows, build-linux]

steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Azure Container Registry
run: |
echo ${{ secrets.ACR_PASSWORD }} | docker login ${{ secrets.ACR_LOGIN_SERVER }} -u ${{ secrets.ACR_USERNAME }} --password-stdin
- name: Build and Push Docker Image
- name: Create Multi-Platforms Image
run: |
docker buildx imagetools create --tag ${{ secrets.ACR_LOGIN_SERVER }}/${{ secrets.ACR_REPOSITORY }}:${{ github.event.release.tag_name }} \
${{ secrets.ACR_LOGIN_SERVER }}/${{ secrets.ACR_INTERNAL_REPOSITORY }}:${{ github.event.release.tag_name }}-windows \
${{ secrets.ACR_LOGIN_SERVER }}/${{ secrets.ACR_INTERNAL_REPOSITORY }}:${{ github.event.release.tag_name }}-linux
docker buildx imagetools create --tag ${{ secrets.ACR_LOGIN_SERVER }}/${{ secrets.ACR_REPOSITORY }}:latest \
${{ secrets.ACR_LOGIN_SERVER }}/${{ secrets.ACR_INTERNAL_REPOSITORY }}:${{ github.event.release.tag_name }}-windows \
${{ secrets.ACR_LOGIN_SERVER }}/${{ secrets.ACR_INTERNAL_REPOSITORY }}:${{ github.event.release.tag_name }}-linux
- name: Delete Docker Tags
run: |
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/${{ secrets.ACR_REPOSITORY }}:${{ github.event.release.tag_name }} .
docker tag ${{ secrets.ACR_LOGIN_SERVER }}/${{ secrets.ACR_REPOSITORY }}:${{ github.event.release.tag_name }} ${{ secrets.ACR_LOGIN_SERVER }}/${{ secrets.ACR_REPOSITORY }}:latest
docker push ${{ secrets.ACR_LOGIN_SERVER }}/${{ secrets.ACR_REPOSITORY }}:${{ github.event.release.tag_name }}
docker push ${{ secrets.ACR_LOGIN_SERVER }}/${{ secrets.ACR_REPOSITORY }}:latest
curl -X DELETE -u "${{ secrets.ACR_USERNAME }}:${{ secrets.ACR_PASSWORD }}" https://${{ secrets.ACR_LOGIN_SERVER }}/acr/v1/${{ secrets.ACR_INTERNAL_REPOSITORY }}/_tags/${{ github.event.release.tag_name }}-windows
curl -X DELETE -u "${{ secrets.ACR_USERNAME }}:${{ secrets.ACR_PASSWORD }}" https://${{ secrets.ACR_LOGIN_SERVER }}/acr/v1/${{ secrets.ACR_INTERNAL_REPOSITORY }}/_tags/${{ github.event.release.tag_name }}-linux
- name: Log out from ACR
run: |
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile → Dockerfile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ RUN git clone --depth 1 --branch $(curl --silent "https://api.github.com/repos/m
WORKDIR /app/lisa

RUN python3 -m pip install --no-cache-dir --upgrade pip && \
python3 -m pip install --no-cache-dir --editable .[azure,libvirt,baremetal] --config-settings editable_mode=compat

python3 -m pip install --no-cache-dir --editable .[ado,azure,libvirt,baremetal] --config-settings editable_mode=compat
26 changes: 26 additions & 0 deletions Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM mcr.microsoft.com/windows/servercore:ltsc2022

SHELL ["powershell", "-Command"]

WORKDIR C:\\app\\

ENV PYTHON_VERSION=3.11.6

RUN Invoke-WebRequest -Uri "https://www.python.org/ftp/python/$Env:PYTHON_VERSION/python-$Env:PYTHON_VERSION-amd64.exe" -OutFile "C:\\python-installer.exe" -UseBasicParsing; \
$gitRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/git-for-windows/git/releases/latest" -Headers @{ 'User-Agent' = 'Docker Build' }; \
$gitInstallerUrl = $gitRelease.assets | Where-Object { $_.name -like '*64-bit.exe' } | Select-Object -ExpandProperty browser_download_url; \
Invoke-WebRequest -Uri $gitInstallerUrl -OutFile "C:\\git-installer.exe" -UseBasicParsing;

RUN Start-Process -FilePath "C:\\python-installer.exe" -ArgumentList '/quiet InstallAllUsers=1 PrependPath=1 TargetDir=C:\\Python' -Wait; \
Start-Process -FilePath "C:\\git-installer.exe" -ArgumentList '/VERYSILENT /NORESTART /SP-' -Wait; \
Remove-Item -Force "C:\\python-installer.exe", "C:\\git-installer.exe"; \
if (!(Test-Path 'C:\\Python')) { throw 'Python installation failed!' }; \
$env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine)

RUN $latestRelease = (Invoke-RestMethod -Uri "https://api.github.com/repos/microsoft/lisa/releases/latest").tag_name; \
git clone --depth 1 --branch $latestRelease https://github.com/microsoft/lisa.git C:\\app\\lisa

WORKDIR C:\\app\\lisa

RUN python -m pip install --no-cache-dir --upgrade pip; \
python -m pip install --no-cache-dir --editable .[ado,azure,libvirt,baremetal] --config-settings editable_mode=compat

0 comments on commit 8c7ace7

Please sign in to comment.