Skip to content

Commit

Permalink
Create workflow for building and pushing docker images to GitHub regi…
Browse files Browse the repository at this point in the history
…stry (asreview#1341)

* Build docker images from the project folder directly

* Create Docker workflow to automatically push to Docker Hub

* Move Docker image to GitHub Container Registry (ghcr.io)
  • Loading branch information
abelsiqueira authored Apr 5, 2023
1 parent 5b925d0 commit 456369e
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 151 deletions.
29 changes: 29 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
__pycache__
asreview.egg-info
build
dist
docker
docs
env
images
tests

.coveragerc
.dockerignore
.gitattributes
.github
.gitignore
.gitmodules
.readthedocs.yaml
.vscode
.zenodo.json
app.json
asreview/webapp/node_modules
azuredeploy.json
azuredeploy.parameters.json
MANIFEST.in
*.md

!README.md

# .git is not ignored because we need the information for versioneer
59 changes: 59 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Docker deployment

on:
push:
branches:
- 'master'
tags:
- 'v*'
pull_request:
branches:
- 'master'

jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build the image for testing
uses: docker/build-push-action@v4
with:
context: .
load: true
tags: asreview/asreview:test
- name: Test the built image
run: |
docker run asreview/asreview:test -h
- name: Docker meta
id: meta
if: github.event_name != 'pull_request'
uses: docker/metadata-action@v4
with:
images: ghcr.io/asreview/asreview
- name: Login to GitHub registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and, if it is not a pull request, push to Docker Hub
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
24 changes: 9 additions & 15 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,16 @@ You can deploy ASReview LAB right now in one click on any of these clouds provid

### Docker

Creating a Docker release can't be done with a hook anymore (not for free). Find the manual instructions at
https://docs.docker.com/docker-hub/. Replace the version numbers below by the version you want to push.
A Docker image is created when a tag or a commit to `master` is pushed.
The workflow `docker.yml` builds images for platforms `linux/amd64` and `linux/arm64`.
If, for some reason, the image is not built, you can build manually with the commands below.
Find the manual instructions at <https://docs.docker.com/docker-hub/> and <https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry>.
Replace the version numbers below by the version you want to push.

ASReview LAB
```
docker build -t asreview/asreview docker/asreview-lab/.
docker build -t asreview/asreview:1.0 docker/asreview-lab/.
docker push asreview/asreview
docker push asreview/asreview:1.0
```


ASReview CLI
```
docker build -t asreview/asreview-cli docker/asreview-cli/.
docker build -t asreview/asreview-cli:1.0 docker/asreview-cli/.
docker push asreview/asreview-cli
docker push asreview/asreview-cli:1.0
docker build -t asreview/asreview .
docker build -t asreview/asreview:1.0 .
docker push ghcr.io/asreview/asreview
docker push ghcr.io/asreview/asreview:1.0
```
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# First stage
FROM python:3.8-slim AS builder
WORKDIR /app

# Copy and build asreview
# git is used by versioneer to define the project version
COPY . /app
RUN apt-get update \
&& apt-get install -y git npm \
&& pip3 install --upgrade pip setuptools \
&& python3 setup.py compile_assets \
&& pip3 install --user . \
&& pip3 install --user asreview-datatools asreview-insights asreview-makita asreview-wordcloud

# Second stage
FROM python:3.8-slim

COPY --from=builder /root/.local /root/.local

ENV ASREVIEW_HOST=0.0.0.0
ENV PATH=/root/.local/bin:$PATH
ENV ASREVIEW_PATH=project_folder
EXPOSE 5000

ENTRYPOINT ["asreview"]
5 changes: 4 additions & 1 deletion asreview/entry_points/lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
from asreview.entry_points.base import BaseEntryPoint
from asreview.entry_points.base import DeprecateAction
from asreview.entry_points.base import _base_parser
from asreview.webapp.run_model import main as main_run_model

HOST_NAME = "localhost"
HOST_NAME = os.getenv("ASREVIEW_HOST")
if HOST_NAME is None:
HOST_NAME = "localhost"
PORT_NUMBER = 5000


Expand Down
119 changes: 0 additions & 119 deletions docker/README.md

This file was deleted.

4 changes: 0 additions & 4 deletions docker/asreview-cli/Dockerfile

This file was deleted.

4 changes: 0 additions & 4 deletions docker/asreview-lab/Dockerfile

This file was deleted.

40 changes: 32 additions & 8 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Install the ASReview software with Pip by running the following command in the
pip install asreview
Start the application with the following command (in CMD.exe or Terminal):

.. code:: bash
asreview lab
Expand All @@ -33,7 +33,7 @@ ASReview LAB, see :doc:`start`.

For users with Apple M1 computers, if you experience problems, follow the
`instructions
<https://github.com/asreview/asreview/issues/738#issuecomment-919685562>`__.
<https://github.com/ghcr.io/asreview/asreview/issues/738#issuecomment-919685562>`__.


Upgrade ASReview
Expand Down Expand Up @@ -82,22 +82,22 @@ closed networks.
Install with Docker
-------------------

ASReview LAB is also available as a Docker container. Make sure you have
ASReview is also available as a Docker container. Make sure you have
Docker installed on your machine.

To install and start ASReview LAB at http://localhost:5000, run the following:

.. code:: bash
docker run -p 5000:5000 asreview/asreview:latest
docker run -p 5000:5000 ghcr.io/asreview/asreview:latest lab
More advanced command line options can be given
afterward, like this:

.. code:: bash
docker run -p 9000:9000 asreview/asreview --port 9000
docker run -p 9000:9000 ghcr.io/asreview/asreview lab --port 9000
.. tip::

Expand All @@ -116,9 +116,33 @@ access the same folder.

.. code:: bash
docker create --name asreview-lab -p 5000:5000 -v path-to-your-folder:/project_folder asreview/asreview
docker run -p 5000:5000 -v path-to-your-folder:/project_folder ghcr.io/asreview/asreview lab
Named container
~~~~~~~~~~~~~~~

To make the usage easier, you can create a named container like the following:

.. code:: bash
docker create --name asreview-lab -p 5000:5000 -v path-to-your-folder:/project_folder ghcr.io/asreview/asreview lab
To start asreview, enter:

.. code:: bash
docker start asreview
To stop it, just use `stop` instead of `start`.
You can also check which images are running with `docker ps`.

Build a local image
Customize the image
~~~~~~~~~~~~~~~~~~~

For more information, see `ASReview LAB GitHub <https://github.com/asreview/asreview/tree/master/docker>`__.
If you want to add more extensions, or build the Docker image yourself, check the file `Dockerfile <https://github.com/ghcr.io/asreview/asreview/tree/master/Dockerfiles>`.
Modify it as you see fit, and then build and run the image with:

.. code:: bash
docker build -t asreview/asreview:custom .
docker run -p 5000:5000 ghcr.io/asreview/asreview:custom lab

0 comments on commit 456369e

Please sign in to comment.