runtm-worker 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- runtm_worker-0.1.0/.gitignore +84 -0
- runtm_worker-0.1.0/LICENSE +37 -0
- runtm_worker-0.1.0/PKG-INFO +105 -0
- runtm_worker-0.1.0/README.md +67 -0
- runtm_worker-0.1.0/pyproject.toml +57 -0
- runtm_worker-0.1.0/runtm_worker/__init__.py +3 -0
- runtm_worker-0.1.0/runtm_worker/builder/__init__.py +5 -0
- runtm_worker-0.1.0/runtm_worker/builder/docker.py +636 -0
- runtm_worker-0.1.0/runtm_worker/jobs/__init__.py +5 -0
- runtm_worker-0.1.0/runtm_worker/jobs/deploy.py +937 -0
- runtm_worker-0.1.0/runtm_worker/logs/__init__.py +5 -0
- runtm_worker-0.1.0/runtm_worker/logs/capture.py +185 -0
- runtm_worker-0.1.0/runtm_worker/main.py +126 -0
- runtm_worker-0.1.0/runtm_worker/providers/__init__.py +23 -0
- runtm_worker-0.1.0/runtm_worker/providers/base.py +196 -0
- runtm_worker-0.1.0/runtm_worker/providers/fly.py +1422 -0
- runtm_worker-0.1.0/runtm_worker/providers/fly_secrets.py +256 -0
- runtm_worker-0.1.0/runtm_worker/providers/secrets_base.py +148 -0
- runtm_worker-0.1.0/runtm_worker/storage/__init__.py +14 -0
- runtm_worker-0.1.0/runtm_worker/telemetry.py +212 -0
- runtm_worker-0.1.0/tests/__init__.py +1 -0
- runtm_worker-0.1.0/tests/test_storage.py +24 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
/build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
*.egg-info/
|
|
24
|
+
.installed.cfg
|
|
25
|
+
*.egg
|
|
26
|
+
|
|
27
|
+
# PyInstaller
|
|
28
|
+
*.manifest
|
|
29
|
+
*.spec
|
|
30
|
+
|
|
31
|
+
# Installer logs
|
|
32
|
+
pip-log.txt
|
|
33
|
+
pip-delete-this-directory.txt
|
|
34
|
+
|
|
35
|
+
# Unit test / coverage reports
|
|
36
|
+
htmlcov/
|
|
37
|
+
.tox/
|
|
38
|
+
.nox/
|
|
39
|
+
.coverage
|
|
40
|
+
.coverage.*
|
|
41
|
+
.cache
|
|
42
|
+
nosetests.xml
|
|
43
|
+
coverage.xml
|
|
44
|
+
*.cover
|
|
45
|
+
*.py,cover
|
|
46
|
+
.hypothesis/
|
|
47
|
+
.pytest_cache/
|
|
48
|
+
|
|
49
|
+
# Translations
|
|
50
|
+
*.mo
|
|
51
|
+
*.pot
|
|
52
|
+
|
|
53
|
+
# Environments
|
|
54
|
+
.env
|
|
55
|
+
.env.local
|
|
56
|
+
.env.*
|
|
57
|
+
.venv
|
|
58
|
+
env/
|
|
59
|
+
venv/
|
|
60
|
+
ENV/
|
|
61
|
+
env.bak/
|
|
62
|
+
venv.bak/
|
|
63
|
+
|
|
64
|
+
# IDE
|
|
65
|
+
.idea/
|
|
66
|
+
*.swp
|
|
67
|
+
*.swo
|
|
68
|
+
*~
|
|
69
|
+
.cursor/
|
|
70
|
+
.cursor/rules/
|
|
71
|
+
|
|
72
|
+
# macOS
|
|
73
|
+
.DS_Store
|
|
74
|
+
|
|
75
|
+
# Project specific
|
|
76
|
+
/artifacts/
|
|
77
|
+
*.log
|
|
78
|
+
|
|
79
|
+
# Internal planning docs
|
|
80
|
+
.plans/
|
|
81
|
+
|
|
82
|
+
# Alembic
|
|
83
|
+
packages/api/alembic/versions/*.pyc
|
|
84
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# AGPL-3.0-or-later
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Runtm
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU Affero General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Full License Text
|
|
21
|
+
|
|
22
|
+
The full text of the GNU Affero General Public License v3.0 is available at:
|
|
23
|
+
https://www.gnu.org/licenses/agpl-3.0.txt
|
|
24
|
+
|
|
25
|
+
### Summary
|
|
26
|
+
|
|
27
|
+
The AGPL-3.0 license requires that:
|
|
28
|
+
|
|
29
|
+
1. **Source Code Access**: If you run a modified version of this software as a network service, you must make the complete source code available to users of that service.
|
|
30
|
+
|
|
31
|
+
2. **Copyleft**: Any modifications must also be licensed under AGPL-3.0.
|
|
32
|
+
|
|
33
|
+
3. **Attribution**: You must retain copyright notices and license information.
|
|
34
|
+
|
|
35
|
+
4. **State Changes**: You must document any changes made to the source code.
|
|
36
|
+
|
|
37
|
+
This license ensures that improvements to hosted versions of Runtm remain open source and benefit the community.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: runtm-worker
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Build and deploy worker for Runtm
|
|
5
|
+
Project-URL: Homepage, https://runtm.com
|
|
6
|
+
Project-URL: Documentation, https://docs.runtm.com
|
|
7
|
+
Project-URL: Repository, https://github.com/runtm-ai/runtm
|
|
8
|
+
Project-URL: Issues, https://github.com/runtm-ai/runtm/issues
|
|
9
|
+
Author-email: Gustavo Trigos <gus@runtm.com>
|
|
10
|
+
Maintainer-email: Gustavo Trigos <gus@runtm.com>
|
|
11
|
+
License: AGPL-3.0-or-later
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: build,deployment,docker,fly.io,worker
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: System :: Software Distribution
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Requires-Dist: docker<8.0,>=6.0
|
|
26
|
+
Requires-Dist: httpx<1.0,>=0.24
|
|
27
|
+
Requires-Dist: psycopg2-binary<3.0,>=2.9
|
|
28
|
+
Requires-Dist: redis<6.0,>=4.5
|
|
29
|
+
Requires-Dist: rq<3.0,>=2.3.2
|
|
30
|
+
Requires-Dist: runtm-shared>=0.1.0
|
|
31
|
+
Requires-Dist: sqlalchemy<3.0,>=2.0
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: mypy<2.0,>=1.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest-cov<6.0,>=4.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest<9.0,>=7.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
|
|
39
|
+
# runtm-worker
|
|
40
|
+
|
|
41
|
+
Build and deploy worker for Runtm. See the [self-hosting docs](https://docs.runtm.com/self-hosting/overview) for deployment setup.
|
|
42
|
+
|
|
43
|
+
## Pipeline
|
|
44
|
+
|
|
45
|
+
### Remote Builder (Default, Recommended)
|
|
46
|
+
|
|
47
|
+
1. Unzip artifact from storage
|
|
48
|
+
2. Validate manifest against schema
|
|
49
|
+
3. Create Fly app and allocate IPs
|
|
50
|
+
4. Run `flyctl deploy` (builds AND deploys in one step)
|
|
51
|
+
- Auto-generates `fly.toml` with optimized health checks
|
|
52
|
+
- Builds on Fly's remote builders (fast, no local Docker)
|
|
53
|
+
- Deploys to Fly Machine with health check verification
|
|
54
|
+
5. Save provider resource and verify health
|
|
55
|
+
6. Update deployment status + URL in DB
|
|
56
|
+
7. Persist logs
|
|
57
|
+
|
|
58
|
+
### Local Build (Fallback)
|
|
59
|
+
|
|
60
|
+
1. Unzip artifact from storage
|
|
61
|
+
2. Validate manifest against schema
|
|
62
|
+
3. Build Docker container locally with BuildKit
|
|
63
|
+
4. Push to Fly.io registry
|
|
64
|
+
5. Create/update Fly Machine via Machines API
|
|
65
|
+
6. Poll for health check
|
|
66
|
+
7. Update deployment status + URL in DB
|
|
67
|
+
8. Persist logs
|
|
68
|
+
|
|
69
|
+
## Development
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Install dependencies
|
|
73
|
+
pip install -e ".[dev]"
|
|
74
|
+
|
|
75
|
+
# Run worker
|
|
76
|
+
python -m runtm_worker.main
|
|
77
|
+
|
|
78
|
+
# Run tests
|
|
79
|
+
pytest
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Environment Variables
|
|
83
|
+
|
|
84
|
+
| Variable | Description | Default |
|
|
85
|
+
|----------|-------------|---------|
|
|
86
|
+
| `DATABASE_URL` | PostgreSQL connection string | Required |
|
|
87
|
+
| `REDIS_URL` | Redis connection string | Required |
|
|
88
|
+
| `FLY_API_TOKEN` | Fly.io API token | Required |
|
|
89
|
+
| `ARTIFACT_STORAGE_PATH` | Local artifact storage path | `/artifacts` |
|
|
90
|
+
| `ARTIFACT_STORAGE_BACKEND` | Storage backend: `local` or `s3` | `local` |
|
|
91
|
+
| `BUCKET_NAME` | S3/Tigris bucket name (when backend=s3) | - |
|
|
92
|
+
| `AWS_ENDPOINT_URL_S3` | S3 endpoint URL (e.g. `https://fly.storage.tigris.dev`) | - |
|
|
93
|
+
| `USE_REMOTE_BUILDER` | Use Fly's remote builder (faster) | `true` |
|
|
94
|
+
|
|
95
|
+
## Providers
|
|
96
|
+
|
|
97
|
+
The worker uses a provider interface to support multiple deployment backends:
|
|
98
|
+
|
|
99
|
+
- `FlyProvider` - Fly.io Machines (default)
|
|
100
|
+
- Future: Cloud Run, etc.
|
|
101
|
+
|
|
102
|
+
Note: When using the remote builder (default), most deployment is handled by
|
|
103
|
+
`flyctl deploy`. The FlyProvider is still used for app creation, IP allocation,
|
|
104
|
+
machine listing, health verification, and custom domain management.
|
|
105
|
+
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# runtm-worker
|
|
2
|
+
|
|
3
|
+
Build and deploy worker for Runtm. See the [self-hosting docs](https://docs.runtm.com/self-hosting/overview) for deployment setup.
|
|
4
|
+
|
|
5
|
+
## Pipeline
|
|
6
|
+
|
|
7
|
+
### Remote Builder (Default, Recommended)
|
|
8
|
+
|
|
9
|
+
1. Unzip artifact from storage
|
|
10
|
+
2. Validate manifest against schema
|
|
11
|
+
3. Create Fly app and allocate IPs
|
|
12
|
+
4. Run `flyctl deploy` (builds AND deploys in one step)
|
|
13
|
+
- Auto-generates `fly.toml` with optimized health checks
|
|
14
|
+
- Builds on Fly's remote builders (fast, no local Docker)
|
|
15
|
+
- Deploys to Fly Machine with health check verification
|
|
16
|
+
5. Save provider resource and verify health
|
|
17
|
+
6. Update deployment status + URL in DB
|
|
18
|
+
7. Persist logs
|
|
19
|
+
|
|
20
|
+
### Local Build (Fallback)
|
|
21
|
+
|
|
22
|
+
1. Unzip artifact from storage
|
|
23
|
+
2. Validate manifest against schema
|
|
24
|
+
3. Build Docker container locally with BuildKit
|
|
25
|
+
4. Push to Fly.io registry
|
|
26
|
+
5. Create/update Fly Machine via Machines API
|
|
27
|
+
6. Poll for health check
|
|
28
|
+
7. Update deployment status + URL in DB
|
|
29
|
+
8. Persist logs
|
|
30
|
+
|
|
31
|
+
## Development
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Install dependencies
|
|
35
|
+
pip install -e ".[dev]"
|
|
36
|
+
|
|
37
|
+
# Run worker
|
|
38
|
+
python -m runtm_worker.main
|
|
39
|
+
|
|
40
|
+
# Run tests
|
|
41
|
+
pytest
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Environment Variables
|
|
45
|
+
|
|
46
|
+
| Variable | Description | Default |
|
|
47
|
+
|----------|-------------|---------|
|
|
48
|
+
| `DATABASE_URL` | PostgreSQL connection string | Required |
|
|
49
|
+
| `REDIS_URL` | Redis connection string | Required |
|
|
50
|
+
| `FLY_API_TOKEN` | Fly.io API token | Required |
|
|
51
|
+
| `ARTIFACT_STORAGE_PATH` | Local artifact storage path | `/artifacts` |
|
|
52
|
+
| `ARTIFACT_STORAGE_BACKEND` | Storage backend: `local` or `s3` | `local` |
|
|
53
|
+
| `BUCKET_NAME` | S3/Tigris bucket name (when backend=s3) | - |
|
|
54
|
+
| `AWS_ENDPOINT_URL_S3` | S3 endpoint URL (e.g. `https://fly.storage.tigris.dev`) | - |
|
|
55
|
+
| `USE_REMOTE_BUILDER` | Use Fly's remote builder (faster) | `true` |
|
|
56
|
+
|
|
57
|
+
## Providers
|
|
58
|
+
|
|
59
|
+
The worker uses a provider interface to support multiple deployment backends:
|
|
60
|
+
|
|
61
|
+
- `FlyProvider` - Fly.io Machines (default)
|
|
62
|
+
- Future: Cloud Run, etc.
|
|
63
|
+
|
|
64
|
+
Note: When using the remote builder (default), most deployment is handled by
|
|
65
|
+
`flyctl deploy`. The FlyProvider is still used for app creation, IP allocation,
|
|
66
|
+
machine listing, health verification, and custom domain management.
|
|
67
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "runtm-worker"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Build and deploy worker for Runtm"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = { text = "AGPL-3.0-or-later" }
|
|
7
|
+
requires-python = ">=3.9"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Gustavo Trigos", email = "gus@runtm.com" },
|
|
10
|
+
]
|
|
11
|
+
maintainers = [
|
|
12
|
+
{ name = "Gustavo Trigos", email = "gus@runtm.com" },
|
|
13
|
+
]
|
|
14
|
+
keywords = ["worker", "deployment", "docker", "fly.io", "build"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Topic :: System :: Software Distribution",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"runtm-shared>=0.1.0",
|
|
29
|
+
"sqlalchemy>=2.0,<3.0",
|
|
30
|
+
"psycopg2-binary>=2.9,<3.0",
|
|
31
|
+
"redis>=4.5,<6.0",
|
|
32
|
+
"rq>=2.3.2,<3.0",
|
|
33
|
+
"httpx>=0.24,<1.0",
|
|
34
|
+
"docker>=6.0,<8.0",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
dev = [
|
|
39
|
+
"pytest>=7.0,<9.0",
|
|
40
|
+
"pytest-cov>=4.0,<6.0",
|
|
41
|
+
"ruff>=0.1.0",
|
|
42
|
+
"mypy>=1.0,<2.0",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[project.urls]
|
|
46
|
+
Homepage = "https://runtm.com"
|
|
47
|
+
Documentation = "https://docs.runtm.com"
|
|
48
|
+
Repository = "https://github.com/runtm-ai/runtm"
|
|
49
|
+
Issues = "https://github.com/runtm-ai/runtm/issues"
|
|
50
|
+
|
|
51
|
+
[build-system]
|
|
52
|
+
requires = ["hatchling"]
|
|
53
|
+
build-backend = "hatchling.build"
|
|
54
|
+
|
|
55
|
+
[tool.hatch.build.targets.wheel]
|
|
56
|
+
packages = ["runtm_worker"]
|
|
57
|
+
|