Skip to content

Build multi-platform image #16

New issue

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

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

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
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
94 changes: 94 additions & 0 deletions pipelines/images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
trigger:
- master

jobs:
- job: Linux
displayName: 'Build linux images'
pool:
vmImage: 'ubuntu-latest'
workspace:
clean: all
variables:
workingDirectory: '$(Build.SourcesDirectory)/linux/'
steps:
- script: |
cd $(workingDirectory)
chmod 777 *.sh
./build.sh
displayName: 'Build images'
workingDirectory: $(workingDirectory)

- task: Docker@2
displayName: 'Docker Login'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
containerRegistry: 'czon Docker Hub'
command: 'login'
addPipelineData: false

- script: |
cd $(workingDirectory)
./push.sh
displayName: 'Push images'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
workingDirectory: $(workingDirectory)

- job: Windows
displayName: 'Build windows images'
pool:
vmImage: 'windows-latest'
workspace:
clean: all
variables:
workingDirectory: '$(Build.SourcesDirectory)/windows/'
steps:
- script: .\build.ps1
displayName: 'Build images'
workingDirectory: $(workingDirectory)

- task: Docker@2
displayName: 'Docker Login'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
containerRegistry: 'czon Docker Hub'
command: 'login'
addPipelineData: false

- script: .\push.sh
displayName: 'Push images'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
workingDirectory: $(workingDirectory)

- job: Manifest
displayName: 'Build Multi-Platform manifest'
dependsOn:
- Linux
- Windows
pool:
vmImage: 'ubuntu-latest'
workspace:
clean: all
variables:
workingDirectory: '$(Build.SourcesDirectory)/xplat/'
steps:
- script: |
cd $(workingDirectory)
chmod 777 *.sh
./build.sh
displayName: 'Build images'
workingDirectory: $(workingDirectory)

- task: Docker@2
displayName: 'Docker Login'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
containerRegistry: 'czon Docker Hub'
command: 'login'
addPipelineData: false

- script: |
cd $(workingDirectory)
./push.sh
displayName: 'Push images'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
workingDirectory: $(workingDirectory)
35 changes: 0 additions & 35 deletions pipelines/linux.yaml

This file was deleted.

54 changes: 54 additions & 0 deletions xplat/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
set -e

# Initialize all the option variables.
# This ensures we are not contaminated by variables from the environment.

registry=czon
name=azdo-agent

POSITIONAL=()
while [[ $# -gt 0 ]]; do
key="$1"

case $key in
-r|--registry)
if [ "$2" ]; then
registry=$2
echo "Registry: '$registry'"
shift
else
die 'ERROR: "--registry" requires a non-empty option argument.'
fi
;;
-n|--name)
if [ "$2" ]; then
name=$2
echo "Name: '$name'"
shift
else
die 'ERROR: "--name" requires a non-empty option argument.'
fi
;;
--) # End of all options.
shift
break
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac

shift
done
set -- "${POSITIONAL[@]}" # restore positional parameters

cd "$(dirname "$0")"
tag=$( tail -n 1 ../latest-agent-version )
ubuntu=$( tail -n 1 ../linux/ubuntu/versions )
windowscore=$( tail -n 1 ../windows/core/versions )

docker manifest create "$registry/$name:$tag" \
"$registry/$name:windows-core-$windowscore-$tag" \
"$registry/$name:ubuntu-$ubuntu-$tag"
52 changes: 52 additions & 0 deletions xplat/push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
set -e

# Initialize all the option variables.
# This ensures we are not contaminated by variables from the environment.

registry=czon
name=azdo-agent

POSITIONAL=()
while [[ $# -gt 0 ]]; do
key="$1"

case $key in
-r|--registry)
if [ "$2" ]; then
registry=$2
echo "Registry: '$registry'"
shift
else
die 'ERROR: "--registry" requires a non-empty option argument.'
fi
;;
-n|--name)
if [ "$2" ]; then
name=$2
echo "Name: '$name'"
shift
else
die 'ERROR: "--name" requires a non-empty option argument.'
fi
;;
--) # End of all options.
shift
break
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac

shift
done
set -- "${POSITIONAL[@]}" # restore positional parameters

cd "$(dirname "$0")"
tag=$( tail -n 1 ../latest-agent-version )
ubuntu=$( tail -n 1 ../linux/ubuntu/versions )
windowscore=$( tail -n 1 ../windows/core/versions )

docker manifest push "$registry/$name:$tag"