Skip to content
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

[ADD] Docker publish workflow #357

Merged
merged 3 commits into from
Dec 21, 2021
Merged
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
80 changes: 80 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Publish Docker image

on:
push:
# Push to `master` or `development`
branches:
- master
- development
- add_docker-publish
eddiebergman marked this conversation as resolved.
Show resolved Hide resolved
workflow_dispatch:

jobs:
push_to_registries:
name: Push Docker image to multiple registries
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch

- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: |
automlorg/autopytorch
ghcr.io/${{ github.repository }}

- name: Build and push Docker images
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.extract_branch.outputs.branch }}

- name: Docker Login
run: docker login ghcr.io -u $GITHUB_ACTOR -p $GITHUB_TOKEN
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Pull Docker image
run: docker pull ghcr.io/$GITHUB_REPOSITORY/autoPyTorch:$BRANCH
env:
BRANCH: ${{ steps.extract_branch.outputs.branch }}

- name: Run image
run: docker run -i -d --name unittester -v $GITHUB_WORKSPACE:/workspace -w /workspace ghcr.io/$GITHUB_REPOSITORY/autoPyTorch:$BRANCH
env:
BRANCH: ${{ steps.extract_branch.outputs.branch }}

- name: Auto-PyTorch loaded
run: docker exec -i unittester python3 -c 'import autoPyTorch; print(f"Auto-PyTorch imported from {autoPyTorch.__file__}")'

- name: Run unit testing
run: docker exec -i unittester python3 -m pytest -v test
30 changes: 28 additions & 2 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,31 @@ Installing Auto-Pytorch


Docker Image
=========================
TODO
============
A Docker image is also provided on dockerhub. To download from dockerhub,
use:

.. code:: bash

docker pull automlorg/autopytorch:master

You can also verify that the image was downloaded via:

.. code:: bash

docker images # Verify that the image was downloaded

This image can be used to start an interactive session as follows:

.. code:: bash

docker run -it automlorg/autopytorch:master

To start a Jupyter notebook, you could instead run e.g.:

.. code:: bash

docker run -it -v ${PWD}:/opt/nb -p 8888:8888 automlorg/autopytorch:master /bin/bash -c "mkdir -p /opt/nb && jupyter notebook --notebook-dir=/opt/nb --ip='0.0.0.0' --port=8888 --no-browser --allow-root"

Alternatively, it is possible to use the development version of autoPyTorch by replacing all
occurences of ``master`` by ``development``.