Skip to content

Commit e3aeb55

Browse files
committed
[ADD] Docker publish workflow (#357)
* Add workflow for publishing docker image to github packages and dockerhub * add docker installation to docs * add workflow dispatch
1 parent 62e9764 commit e3aeb55

File tree

2 files changed

+108
-2
lines changed

2 files changed

+108
-2
lines changed

.github/workflows/docker-publish.yml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
name: Publish Docker image
7+
8+
on:
9+
push:
10+
# Push to `master` or `development`
11+
branches:
12+
- master
13+
- development
14+
- add_docker-publish
15+
workflow_dispatch:
16+
17+
jobs:
18+
push_to_registries:
19+
name: Push Docker image to multiple registries
20+
runs-on: ubuntu-latest
21+
permissions:
22+
packages: write
23+
contents: read
24+
steps:
25+
- name: Check out the repo
26+
uses: actions/checkout@v2
27+
28+
- name: Extract branch name
29+
shell: bash
30+
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
31+
id: extract_branch
32+
33+
- name: Log in to Docker Hub
34+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
35+
with:
36+
username: ${{ secrets.DOCKER_USERNAME }}
37+
password: ${{ secrets.DOCKER_PASSWORD }}
38+
39+
- name: Log in to the Container registry
40+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
41+
with:
42+
registry: ghcr.io
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Extract metadata (tags, labels) for Docker
47+
id: meta
48+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
49+
with:
50+
images: |
51+
automlorg/autopytorch
52+
ghcr.io/${{ github.repository }}
53+
54+
- name: Build and push Docker images
55+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
56+
with:
57+
context: .
58+
push: true
59+
tags: ${{ steps.extract_branch.outputs.branch }}
60+
61+
- name: Docker Login
62+
run: docker login ghcr.io -u $GITHUB_ACTOR -p $GITHUB_TOKEN
63+
env:
64+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
65+
66+
- name: Pull Docker image
67+
run: docker pull ghcr.io/$GITHUB_REPOSITORY/autoPyTorch:$BRANCH
68+
env:
69+
BRANCH: ${{ steps.extract_branch.outputs.branch }}
70+
71+
- name: Run image
72+
run: docker run -i -d --name unittester -v $GITHUB_WORKSPACE:/workspace -w /workspace ghcr.io/$GITHUB_REPOSITORY/autoPyTorch:$BRANCH
73+
env:
74+
BRANCH: ${{ steps.extract_branch.outputs.branch }}
75+
76+
- name: Auto-PyTorch loaded
77+
run: docker exec -i unittester python3 -c 'import autoPyTorch; print(f"Auto-PyTorch imported from {autoPyTorch.__file__}")'
78+
79+
- name: Run unit testing
80+
run: docker exec -i unittester python3 -m pytest -v test

docs/installation.rst

+28-2
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,31 @@ Manual Installation
4646
4747
4848
Docker Image
49-
=========================
50-
TODO
49+
============
50+
A Docker image is also provided on dockerhub. To download from dockerhub,
51+
use:
52+
53+
.. code:: bash
54+
55+
docker pull automlorg/autopytorch:master
56+
57+
You can also verify that the image was downloaded via:
58+
59+
.. code:: bash
60+
61+
docker images # Verify that the image was downloaded
62+
63+
This image can be used to start an interactive session as follows:
64+
65+
.. code:: bash
66+
67+
docker run -it automlorg/autopytorch:master
68+
69+
To start a Jupyter notebook, you could instead run e.g.:
70+
71+
.. code:: bash
72+
73+
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"
74+
75+
Alternatively, it is possible to use the development version of autoPyTorch by replacing all
76+
occurences of ``master`` by ``development``.

0 commit comments

Comments
 (0)