Skip to content

Commit

Permalink
Add docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Oct 2, 2023
1 parent 2e983a6 commit 0fcc6da
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 35 deletions.
109 changes: 82 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
env:
POETRY_VERSION: '1.5.1'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.10'
Expand All @@ -34,33 +34,88 @@ jobs:

- name: Install
run: poetry install --all-extras
- name: Publish
run: poetry publish --build --username='__token__' --password='${{ secrets.PYPI_API_TOKEN }}'
# - name: Publish
# run: poetry publish --build --username='__token__' --password='${{ secrets.PYPI_API_TOKEN }}'

- name: pdoc
# - name: pdoc
# run: |
# poetry install --with=doc
# poetry run pdoc \
# --logo '${{ env.logo }}' \
# --footer-text='Version ${{ github.ref_name }}' \
# --docformat numpy \
# aiochris -o pdoc
# - name: Deploy docs (version)
# uses: JamesIves/[email protected]
# with:
# branch: gh-pages
# folder: pdoc
# clean: true
# clean-exclude: 'v*.*.*/'
# target-folder: "${{ github.ref_name }}"
# - name: Deploy docs (latest)
# uses: JamesIves/[email protected]
# with:
# branch: gh-pages
# folder: pdoc
# clean: false
- name: Get version
id: info
run: echo "version=$(poetry version | awk '{print $2}')" >> "$GITHUB_OUTPUT"
- name: Create Dockerfile
run: |
poetry install --with=doc
poetry run pdoc \
--logo '${{ env.logo }}' \
--footer-text='Version ${{ github.ref_name }}' \
--docformat numpy \
aiochris -o pdoc
- name: Deploy docs (version)
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: pdoc
clean: true
clean-exclude: 'v*.*.*/'
target-folder: "${{ github.ref_name }}"
- name: Deploy docs (latest)
uses: JamesIves/[email protected]
set -ex
poetry build
cd dist
wheel=$(echo ./aiochris-${{ steps.info.outputs.version }}-py3-*.whl)
if ! [ -f "$wheel" ]; then
echo "::error ::Not a file: $wheel"
exit 1
fi
now=$(date --rfc-3339=seconds)
cat > Dockerfile << EOF
FROM docker.io/library/python:3.11.5-alpine
LABEL org.opencontainers.image.created="$now" \
org.opencontainers.image.authors="Jennings Zhang, FNNDSC <[email protected]>" \
org.opencontainers.image.url="${{ github.server_url }}/${{ github.repository }}" \
org.opencontainers.image.documentation="https://fnndsc.github.io/aiochris" \
org.opencontainers.image.source="${{ github.server_url }}/${{ github.repository }}" \
org.opencontainers.image.version="${{ steps.info.outputs.version }}" \
org.opencontainers.image.revision="${{ github.ref_name }}" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.title="aiochris Python package" \
org.opencontainers.image.description="Python async client library for ChRIS"
COPY $wheel /tmp/$wheel
RUN pip install --no-input --no-cache-dir --disable-pip-version-check '/tmp/$wheel' && rm -v '/tmp/$wheel'
EOF
cat Dockerfile
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
branch: gh-pages
folder: pdoc
clean: false
- name: Github Release
uses: softprops/action-gh-release@v1
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
draft: true
body: "https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ github.ref_name }}"
push: true
context: ./dist
tags: |
ghcr.io/fnndsc/aiochris:${{ steps.info.outputs.version }}
ghcr.io/fnndsc/aiochris:latest
platforms: linux/amd64,linux/ppc64le,linux/arm64
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

# - name: Draft Github Release
# uses: softprops/action-gh-release@v1
# with:
# draft: true
# body: "https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ github.ref_name }}"
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: test

on:
push:
branches: [ master ]
# push:
# branches: [ master ]
pull_request:

jobs:
Expand Down
7 changes: 1 addition & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@ repos:
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.10
- id: black
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ pip install aiochris
poetry add aiochris
```

For convenience, container images are also provided.

```shell
docker pull ghcr.io/fnndsc/aiochris:0.3.0
```

## Quick Example

```python
Expand Down

0 comments on commit 0fcc6da

Please sign in to comment.