Create new Docker publishing workflow. (#282)

* Create new Docker publishing workflow.

* Build on wrong branch temporarily to help test.

* Fix ${} syntax.

* Fix FROM line in Dockerfile.

* Also push to latest image.

* Updated container and binder definitions.

* More human readable image names.

* Try pushing to different registry.

* Fix syntax for remote registry name.

* Fix docker login step.

* Login with az acr instead.

* Fix tag names.

* Updated docker repo for binder and devcontainer.

* Fix to Binder config.

* Only prebuild on master.

* Addressing feedback from @anpaz-msft.

* Inject SHA sum into Binder-specific branch.

* Use GITHUB_ACTOR when updating Binder config.

* Use existing action to push.

* Fix inputs to push action.

* Only trigger from master.
This commit is contained in:
Chris Granade 2019-12-18 13:05:02 -08:00 коммит произвёл GitHub
Родитель d0063a3728
Коммит eb5d9a0af3
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 122 добавлений и 41 удалений

Просмотреть файл

@ -1,5 +1,12 @@
{
"dockerFile": "../Dockerfile",
// Use the latest Docker image built from the master branch of this repo.
// You may also prefer to use the Dockerfile for that image directly if you
// would like to make and test local changes to that image. To do so,
// the "image" property with:
//
// "dockerFile": "../Build/images/samples/Dockerfile",
"image": "mcr.microsoft.com/quantum/samples:latest",
"extensions": [
"quantum.quantum-devkit-vscode",
"ms-vscode.csharp",

64
.github/workflows/main.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,64 @@
name: Prebuild Docker image
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Azure login
uses: Azure/login@v1
with:
creds: ${{ secrets.ACR_CREDENTIALS }}
- name: Docker Login
run: az acr login -n msquantum
- name: Build and push Docker image
run: |
$Now = [DateTime]::Now;
$ImageTag = "${{ github.sha }}"
$RepoName = "public/quantum/samples"
$LocalTag = "${RepoName}:${ImageTag}"
$RemoteRepo = "${{ secrets.ACR_REGISTRY }}/${RepoName}"
docker build Build/images/samples --tag $LocalTag
docker tag $LocalTag "${RemoteRepo}:${ImageTag}"
docker push "${RemoteRepo}:${ImageTag}"
docker tag $LocalTag "${RemoteRepo}:latest"
docker push "${RemoteRepo}:latest"
shell: pwsh
- name: Update Binder configuration
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
$ThisCommit = "${{ github.sha }}"
git checkout ⭐binder
git reset --hard $ThisCommit
$Dockerfile = Get-Content ./Dockerfile;
$Dockerfile `
| ForEach-Object {
if ($_.StartsWith("FROM ")) {
"FROM mcr.microsoft.com/quantum/samples:$ThisCommit" | Write-Output;
} else {
$_ | Write-Output;
}
} `
| Set-Content ./Dockerfile
git add Dockerfile
git commit -m "Updated Binder to use $ThisCommit."
shell: pwsh
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true
branch: ⭐binder

Просмотреть файл

@ -0,0 +1,45 @@
# Start from the IQ# base image. The definition for this image can be found at
# https://github.com/microsoft/iqsharp/blob/master/images/iqsharp-base/Dockerfile.
# As per Binder documentation, we choose to use an SHA sum here instead of a
# tag.
FROM mcr.microsoft.com/quantum/iqsharp-base:0.10.1912.0501
# Mark that this Dockerfile is used with the samples repository.
ENV IQSHARP_HOSTING_ENV=SAMPLES_DOCKERFILE
# We need to do a few additional things as root here.
USER root
# Install additional system packages from apt.
RUN apt-get -y update && \
apt-get -y install \
# For the chemistry samples, we'll need PowerShell to be
# installed.
powershell \
# For the Python interoperability sample, we require QuTiP,
# which in turn requires gcc's C++ support.
g++ \
# The version of Matplotlib we use also needs a couple header
# packages.
pkg-config \
libfreetype6-dev \
libpng-dev && \
apt-get clean && rm -rf /var/lib/apt/lists/
# Install additional Python dependencies for the PythonInterop sample.
# Note that QuTiP has as a hard requirement that its dependencies must be
# installed first, so we separate into two pip install steps.
RUN pip install cython \
numpy \
scipy && \
pip install qutip
# We install the rest of our Python dependencies as a separate layer since
# building QuTiP can take a few moments. This makes it easier if we want to add
# other Python packages later.
RUN pip install "matplotlib<=2.1.2" \
"ipyparallel" \
"mpltools" \
"qinfer"
# Finish by dropping back to the notebook user.
USER ${USER}

Просмотреть файл

@ -1,48 +1,13 @@
# Start from the IQ# base image. The definition for this image can be found at
# https://github.com/microsoft/iqsharp/blob/master/images/iqsharp-base/Dockerfile.
# As per Binder documentation, we choose to use an SHA sum here instead of a
# tag.
FROM mcr.microsoft.com/quantum/iqsharp-base:0.10.1912.501
# This uses the latest Docker image built from the samples repository,
# defined by the Dockerfile in Build/images/samples.
FROM mcr.microsoft.com/quantum/samples:latest
# Mark that this Dockerfile is used with the samples repository.
ENV IQSHARP_HOSTING_ENV=SAMPLES_DOCKERFILE
# We need to do a few additional things as root here.
USER root
# Install additional system packages from apt.
RUN apt-get -y update && \
apt-get -y install \
# For the chemistry samples, we'll need PowerShell to be
# installed.
powershell \
# For the Python interoperability sample, we require QuTiP,
# which in turn requires gcc's C++ support.
g++ \
# The version of Matplotlib we use also needs a couple header
# packages.
pkg-config \
libfreetype6-dev \
libpng-dev && \
apt-get clean && rm -rf /var/lib/apt/lists/
# Install additional Python dependencies for the PythonInterop sample.
# Note that QuTiP has as a hard requirement that its dependencies must be
# installed first, so we separate into two pip install steps.
RUN pip install cython \
numpy \
scipy && \
pip install qutip
# We install the rest of our Python dependencies as a separate layer since
# building QuTiP can take a few moments. This makes it easier if we want to add
# other Python packages later.
RUN pip install "matplotlib<=2.1.2" \
"ipyparallel" \
"mpltools" \
"qinfer"
ENV IQSHARP_HOSTING_ENV=SAMPLES_HOSTED
# Make sure the contents of our repo are in ${HOME}.
# These steps are required for use on mybinder.org.
USER root
COPY . ${HOME}
RUN chown -R ${USER} ${HOME}