Skip to content

Commit 59b30ff

Browse files
authored
Merge pull request #6 from animikhaich/dev
PyTorch Support and GitHub Actions
2 parents af28f68 + 19037e7 commit 59b30ff

24 files changed

Lines changed: 2787 additions & 127 deletions

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.venv
2+
data

.github/workflows/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# GitHub Workflows
2+
3+
This directory contains GitHub Actions workflows for the No-Code Classification Toolkit.
4+
5+
## Docker Build and Push Workflow
6+
7+
**File:** `docker-build-push.yml`
8+
9+
### Purpose
10+
Automatically builds and pushes Docker images to GitHub Container Registry (ghcr.io) whenever code is pushed to the repository.
11+
12+
### Triggers
13+
The workflow runs on:
14+
- **Push to main branch**: Builds and pushes images with `latest` tag
15+
- **Push tags matching `v*`**: Builds and pushes versioned releases (e.g., `v1.0.0`)
16+
- **Pull requests to main**: Builds images for testing (does not push)
17+
- **Manual trigger**: Can be triggered manually via GitHub Actions UI
18+
19+
### Docker Image Tags
20+
The workflow creates multiple tags for each build:
21+
22+
- `latest` - Latest build from the main branch
23+
- `main` - Latest build from the main branch
24+
- `v1.2.3` - Semantic version tags (for tagged releases)
25+
- `v1.2` - Major.minor version tags
26+
- `v1` - Major version tags
27+
- `main-<sha>` - Branch name with commit SHA
28+
29+
### Docker Registry
30+
Images are pushed to GitHub Container Registry:
31+
```
32+
ghcr.io/animikhaich/no-code-classification-toolkit
33+
```
34+
35+
### Usage
36+
37+
#### Pull the latest image:
38+
```bash
39+
docker pull ghcr.io/animikhaich/no-code-classification-toolkit:latest
40+
```
41+
42+
#### Pull a specific version:
43+
```bash
44+
docker pull ghcr.io/animikhaich/no-code-classification-toolkit:v1.0.0
45+
```
46+
47+
#### Run the container:
48+
```bash
49+
docker run -it --runtime nvidia --net host -v /path/to/dataset:/data ghcr.io/animikhaich/no-code-classification-toolkit:latest
50+
```
51+
52+
### Permissions
53+
The workflow requires:
54+
- `contents: read` - To checkout the repository
55+
- `packages: write` - To push images to GitHub Container Registry
56+
57+
### Features
58+
- **Docker Buildx**: Uses BuildKit for efficient multi-platform builds
59+
- **Layer caching**: Leverages GitHub Actions cache for faster builds
60+
- **Metadata extraction**: Automatically generates Docker labels and tags
61+
- **Security**: Uses `GITHUB_TOKEN` for authentication (no manual secrets needed)
62+
63+
### Monitoring
64+
You can monitor workflow runs in the [Actions tab](https://github.com/animikhaich/No-Code-Classification-Toolkit/actions) of the repository.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Build and Push Docker Images
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "v*"
9+
pull_request:
10+
branches:
11+
- main
12+
workflow_dispatch:
13+
14+
env:
15+
REGISTRY: ghcr.io
16+
IMAGE_NAME: ${{ github.repository }}
17+
18+
jobs:
19+
build-and-push:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
packages: write
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
- name: Log in to GitHub Container Registry
33+
if: github.event_name != 'pull_request'
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ${{ env.REGISTRY }}
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
# TensorFlow image
41+
- name: Extract metadata (tensorflow)
42+
id: meta-tensorflow
43+
uses: docker/metadata-action@v5
44+
with:
45+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-tensorflow
46+
tags: |
47+
type=ref,event=branch
48+
type=ref,event=pr
49+
type=semver,pattern={{version}}
50+
type=semver,pattern={{major}}.{{minor}}
51+
type=semver,pattern={{major}}
52+
type=sha,prefix={{branch}}-
53+
type=raw,value=latest,enable={{is_default_branch}}
54+
55+
- name: Build and push TensorFlow image
56+
uses: docker/build-push-action@v5
57+
with:
58+
context: .
59+
file: Dockerfile.tensorflow
60+
push: ${{ github.event_name != 'pull_request' }}
61+
tags: ${{ steps.meta-tensorflow.outputs.tags }}
62+
labels: ${{ steps.meta-tensorflow.outputs.labels }}
63+
cache-from: type=gha
64+
cache-to: type=gha,mode=max
65+
66+
# PyTorch image
67+
- name: Extract metadata (pytorch)
68+
id: meta-pytorch
69+
uses: docker/metadata-action@v5
70+
with:
71+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-pytorch
72+
tags: |
73+
type=ref,event=branch
74+
type=ref,event=pr
75+
type=semver,pattern={{version}}
76+
type=semver,pattern={{major}}.{{minor}}
77+
type=semver,pattern={{major}}
78+
type=sha,prefix={{branch}}-
79+
type=raw,value=latest,enable={{is_default_branch}}
80+
81+
- name: Build and push PyTorch image
82+
uses: docker/build-push-action@v5
83+
with:
84+
context: .
85+
file: Dockerfile.pytorch
86+
push: ${{ github.event_name != 'pull_request' }}
87+
tags: ${{ steps.meta-pytorch.outputs.tags }}
88+
labels: ${{ steps.meta-pytorch.outputs.labels }}
89+
cache-from: type=gha
90+
cache-to: type=gha,mode=max

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,7 @@ dmypy.json
143143
model/
144144
logs*
145145
old_data/
146-
test*
146+
test*
147+
148+
149+
data

Dockerfile

Lines changed: 0 additions & 15 deletions
This file was deleted.

Dockerfile.both

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM astral/uv:python3.12-bookworm-slim
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
5+
# Install Python and necessary tools
6+
RUN apt-get update && apt-get install -y \
7+
parallel \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
# Create app directory
11+
RUN mkdir /app
12+
WORKDIR /app
13+
14+
# Copy requirements and install dependencies
15+
COPY ./requirements-tensorflow.txt /app
16+
COPY ./requirements-pytorch.txt /app
17+
RUN uv pip install --no-cache-dir -r requirements-tensorflow.txt --system
18+
RUN uv pip install --no-cache-dir -r requirements-pytorch.txt --system
19+
20+
# Copy application files
21+
COPY . /app
22+
23+
CMD ["sh", "launch.sh"]

Dockerfile.pytorch

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM astral/uv:python3.12-bookworm-slim
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
5+
RUN apt-get update
6+
RUN apt-get install -y parallel
7+
8+
RUN mkdir /app
9+
WORKDIR /app
10+
COPY ./requirements-pytorch.txt /app
11+
12+
RUN uv pip install -r requirements-pytorch.txt --system
13+
COPY . /app
14+
15+
CMD ["sh", "launch.sh"]

Dockerfile.tensorflow

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM astral/uv:python3.12-bookworm-slim
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
5+
RUN apt-get update
6+
RUN apt-get install -y parallel
7+
8+
RUN mkdir /app
9+
WORKDIR /app
10+
COPY ./requirements-tensorflow.txt /app
11+
12+
RUN uv pip install -r requirements-tensorflow.txt --system
13+
COPY . /app
14+
15+
CMD ["sh", "launch.sh"]

0 commit comments

Comments
 (0)