Skip to content

Commit 00e2b96

Browse files
authored
[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 57a490a commit 00e2b96

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
@@ -37,5 +37,31 @@ Installing Auto-Pytorch
3737
3838
3939
Docker Image
40-
=========================
41-
TODO
40+
============
41+
A Docker image is also provided on dockerhub. To download from dockerhub,
42+
use:
43+
44+
.. code:: bash
45+
46+
docker pull automlorg/autopytorch:master
47+
48+
You can also verify that the image was downloaded via:
49+
50+
.. code:: bash
51+
52+
docker images # Verify that the image was downloaded
53+
54+
This image can be used to start an interactive session as follows:
55+
56+
.. code:: bash
57+
58+
docker run -it automlorg/autopytorch:master
59+
60+
To start a Jupyter notebook, you could instead run e.g.:
61+
62+
.. code:: bash
63+
64+
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"
65+
66+
Alternatively, it is possible to use the development version of autoPyTorch by replacing all
67+
occurences of ``master`` by ``development``.

0 commit comments

Comments
 (0)