feat: make Docker image configurable #558
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.8", "3.10"] | |
name: Python ${{ matrix.python-version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
path: template | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.8" | |
- name: Scaffold Python package | |
run: | | |
pip install --no-input cruft | |
cruft create --no-input --extra-context '{"package_name": "My Package", "python_version": "3.8", "docker_image":"radixai/python-gpu:$PYTHON_VERSION-cuda11.8", "with_fastapi_api": "1", "with_typer_cli": "1"}' ./template/ | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install @devcontainers/cli | |
run: npm install --location=global @devcontainers/[email protected] | |
- name: Start Dev Container with Python ${{ matrix.python-version }} | |
env: | |
DOCKER_BUILDKIT: 1 | |
run: | | |
git config --global init.defaultBranch main | |
git init | |
git checkout -b test | |
git add . | |
PYTHON_VERSION=${{ matrix.python-version }} devcontainer up --workspace-folder . | |
working-directory: ./my-package/ | |
- name: Lint package | |
run: devcontainer exec --workspace-folder my-package poe lint | |
- name: Test package | |
run: devcontainer exec --workspace-folder my-package poe test | |
- name: Build ci Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: ./my-package/ | |
target: ci | |
- name: Build app Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
build-args: | | |
SOURCE_BRANCH=${{ env.GITHUB_REF }} | |
SOURCE_COMMIT=${{ env.GITHUB_SHA }} | |
context: ./my-package/ | |
target: app |