Skip to content

Commit

Permalink
Migrate to rye
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Jul 27, 2024
1 parent 6987889 commit ea353a6
Show file tree
Hide file tree
Showing 55 changed files with 350 additions and 2,022 deletions.
135 changes: 70 additions & 65 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build
name: Build

on:
push:
Expand All @@ -9,68 +9,73 @@ on:
branches: [ master ]

jobs:
publish:
runs-on: ubuntu-22.04

build:
name: Build
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Decide image tags
id: info
shell: python
run: |
import os
import itertools
registries = ['docker.io', 'ghcr.io']
repos = ['${{ github.repository }}'.lower()]
if '${{ github.ref_type }}' == 'branch':
tags = ['latest']
elif '${{ github.ref_type }}' == 'tag':
version = '${{ github.ref_name }}'[1:]
tags = ['latest', version]
else:
tags = []
def join_tag(t):
registry, repo, tag = t
return f'{registry}/{repo}:{tag}'
product = itertools.product(registries, repos, tags)
tags_csv = ','.join(map(join_tag, product))
push = 'true' if tags_csv else 'false'
with open(os.environ['GITHUB_OUTPUT'], 'a') as out:
out.write(f'tags={tags_csv}\n')
out.write(f'push={push}\n')
- uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: github.event_name == 'push' || github.event_name == 'release'
id: dockerhub_login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
if: github.event_name == 'push' || github.event_name == 'release'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/ppc64le,linux/arm64
tags: ${{ steps.info.outputs.tags }}
push: ${{ steps.info.outputs.push }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Update DockerHub description
uses: peter-evans/dockerhub-description@v3
if: ${{ steps.info.outputs.push }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
short-description: ${{ github.event.repository.description }}
- uses: actions/checkout@v4
- name: Install rye
uses: eifinger/setup-rye@d4c3ac7b15d8bf2e0b45e2d257c6b5cdbebc3643 # v4.2.1
with:
version: '0.36.0'
enable-cache: true
cache-prefix: ${{ github.workflow }}
- name: Decide image tags
id: info
shell: python
run: |
import os
import itertools
registries = ['docker.io', 'ghcr.io']
repos = ['${{ github.repository }}'.lower()]
if '${{ github.ref_type }}' == 'branch':
tags = ['latest']
elif '${{ github.ref_type }}' == 'tag':
version = '${{ github.ref_name }}'[1:]
tags = ['latest', version]
else:
tags = []
def join_tag(t):
registry, repo, tag = t
return f'{registry}/{repo}:{tag}'

product = itertools.product(registries, repos, tags)
tags_csv = ','.join(map(join_tag, product))
push = 'true' if tags_csv else 'false'

with open(os.environ['GITHUB_OUTPUT'], 'a') as out:
out.write(f'tags={tags_csv}\n')
out.write(f'push={push}\n')
- name: Build Python wheel
run: rye build --wheel --clean
- uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: github.event_name == 'push' || github.event_name == 'release'
id: dockerhub_login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
if: github.event_name == 'push' || github.event_name == 'release'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/ppc64le,linux/arm64
tags: ${{ steps.info.outputs.tags }}
push: ${{ steps.info.outputs.push }}
- name: Update DockerHub description
uses: peter-evans/dockerhub-description@v4
if: ${{ steps.info.outputs.push }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
short-description: ${{ github.event.repository.description }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.venv/
__pycache__/
*.egg-info/
dist/
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

5 changes: 0 additions & 5 deletions .pre-commit-config.yaml

This file was deleted.

1 change: 0 additions & 1 deletion .prospector.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.3
12 changes: 5 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM docker.io/fnndsc/python-poetry:1.5.1
# Build instructions: see https://rye.astral.sh/guide/docker/

FROM python:3.12.3-alpine

RUN --mount=source=dist,target=/dist PYTHONDONTWRITEBYTECODE=1 pip install --no-cache-dir /dist/*.whl

LABEL org.opencontainers.image.authors="Jennings Zhang <[email protected]>, FNNDSC <[email protected]>" \
org.opencontainers.image.title="ChRISomatic" \
Expand All @@ -7,11 +11,5 @@ LABEL org.opencontainers.image.authors="Jennings Zhang <Jennings.Zhang@childrens
org.opencontainers.image.source="https://github.com/FNNDSC/chrisomatic" \
org.opencontainers.image.licenses="MIT"

WORKDIR /usr/local/src/chrisomatic
COPY . .
RUN poetry install --no-dev

WORKDIR /
# needs to write to docker daemon
USER root
CMD ["chrisomatic"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-2023 FNNDSC / BCH
Copyright (c) 2021-2024 FNNDSC / BCH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[![Version](https://img.shields.io/docker/v/fnndsc/chrisomatic?sort=semver)](https://hub.docker.com/r/fnndsc/chrisomatic)
[![MIT License](https://img.shields.io/github/license/fnndsc/chrisomatic)](https://github.com/FNNDSC/chrisomatic/blob/master/LICENSE)
[![Build](https://github.com/FNNDSC/chrisomatic/actions/workflows/build.yml/badge.svg)](https://github.com/FNNDSC/chrisomatic/actions)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

`chrisomatic` is a tool for automatic administration of _ChRIS_ backends.
It is particularly useful for the recreation of setups for testing or development,
Expand Down
9 changes: 9 additions & 0 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.12.3-alpine

WORKDIR /app
COPY requirements-dev.lock requirements-dev.lock
RUN --mount=type=cache,sharing=locked,target=/root/.cache/pip \
sed -i' ' -e '/-e file:\./d' requirements-dev.lock \
&& env PYTHONDONTWRITEBYTECODE=1 pip install -r requirements-dev.lock

CMD ["pytest"]
26 changes: 26 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
services:
dev:
build:
context: .
dockerfile: dev.Dockerfile
command: pytest --color=yes --code-highlight=yes
networks:
minichris:
userns_mode: host
user: root
working_dir: /app
volumes:
- "wd:/app:rw"
- "./src/chrisomatic:/app/chrisomatic:ro"
- "./tests:/app/tests:ro"
- "./scripts:/app/scripts:ro"
- "./pytest.ini:/app/pytest.ini:ro"
- "/var/run/docker.sock:/var/run/docker.sock:rw"

networks:
minichris:
external: true
name: minichris-local

volumes:
wd:
34 changes: 0 additions & 34 deletions justfile

This file was deleted.

Loading

0 comments on commit ea353a6

Please sign in to comment.