Skip to content

Commit ec63432

Browse files
authored
Merge pull request #833 from Yacht-sh/develop
Develop
2 parents fbc961c + 37303b5 commit ec63432

9 files changed

Lines changed: 755 additions & 777 deletions

File tree

.github/workflows/build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,15 @@ jobs:
219219
uses: docker/login-action@v4
220220
with:
221221
registry: ghcr.io
222-
username: ${{ github.actor }}
223-
password: ${{ secrets.GITHUB_TOKEN }}
222+
username: ${{ secrets.GHCR_USERNAME != '' && secrets.GHCR_USERNAME || github.actor }}
223+
password: ${{ secrets.GHCR_TOKEN != '' && secrets.GHCR_TOKEN || secrets.GITHUB_TOKEN }}
224224

225225
- name: Build and push main image
226226
uses: docker/build-push-action@v6
227227
with:
228228
context: .
229229
file: ./Dockerfile
230-
platforms: linux/amd64,linux/arm64,linux/arm/v7
230+
platforms: linux/amd64,linux/arm64
231231
push: true
232232
build-args: |
233233
VUE_APP_VERSION=${{ steps.prep.outputs.app_version }}
@@ -295,8 +295,8 @@ jobs:
295295
uses: docker/login-action@v4
296296
with:
297297
registry: ghcr.io
298-
username: ${{ github.actor }}
299-
password: ${{ secrets.GITHUB_TOKEN }}
298+
username: ${{ secrets.GHCR_USERNAME != '' && secrets.GHCR_USERNAME || github.actor }}
299+
password: ${{ secrets.GHCR_TOKEN != '' && secrets.GHCR_TOKEN || secrets.GITHUB_TOKEN }}
300300

301301
- name: Build and push agent image
302302
uses: docker/build-push-action@v6

backend/api/utils/compose.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
from ..settings import Settings
22
from fastapi import HTTPException
33
import os
4-
import fnmatch
54
import pathlib
65
import re
76

87
settings = Settings()
98
PROJECT_NAME_PATTERN = re.compile(r"^[A-Za-z0-9._-]+$")
9+
COMPOSE_FILE_PATTERNS = (
10+
"compose.yml",
11+
"compose.yaml",
12+
"docker-compose.yml",
13+
"docker-compose.yaml",
14+
)
1015

1116

1217
def get_compose_base_dir():
@@ -33,6 +38,12 @@ def _ensure_within_compose_base(path, must_exist=False):
3338
return resolved
3439

3540

41+
def _resolve_compose_descendant(*path_parts, must_exist=False):
42+
base_dir = get_compose_base_path().resolve()
43+
candidate = base_dir.joinpath(*path_parts)
44+
return _ensure_within_compose_base(candidate, must_exist=must_exist)
45+
46+
3647
def _validated_project_name(project_name):
3748
if not isinstance(project_name, str):
3849
raise HTTPException(400, "Invalid project name.")
@@ -53,18 +64,13 @@ def resolve_compose_project_path(project_name):
5364
Resolve a compose project directory from a project name.
5465
"""
5566
validated_name = _validated_project_name(project_name)
56-
project_dir = _ensure_within_compose_base(
57-
get_compose_base_path() / validated_name
58-
)
67+
project_dir = _resolve_compose_descendant(validated_name)
5968
return os.fspath(project_dir)
6069

6170

6271
def resolve_compose_project_dir(project_name, must_exist=False):
6372
validated_name = _validated_project_name(project_name)
64-
return _ensure_within_compose_base(
65-
get_compose_base_path() / validated_name,
66-
must_exist=must_exist,
67-
)
73+
return _resolve_compose_descendant(validated_name, must_exist=must_exist)
6874

6975

7076
def resolve_compose_file(project_name, filename="docker-compose.yml", must_exist=False):
@@ -76,7 +82,7 @@ def resolve_compose_file(project_name, filename="docker-compose.yml", must_exist
7682
return compose_file
7783

7884

79-
def _collect_yml_files(root_dir):
85+
def _compose_file_matches(root_dir):
8086
"""
8187
Find docker compose files inside a validated compose directory.
8288
"""
@@ -85,16 +91,9 @@ def _collect_yml_files(root_dir):
8591
return {}
8692

8793
matches = {}
88-
for root, _, filenames in os.walk(os.fspath(safe_root), followlinks=False):
89-
for _ in set().union(
90-
fnmatch.filter(filenames, "compose.yml"),
91-
fnmatch.filter(filenames, "compose.yaml"),
92-
fnmatch.filter(filenames, "docker-compose.yml"),
93-
fnmatch.filter(filenames, "docker-compose.yaml"),
94-
):
95-
candidate = _ensure_within_compose_base(
96-
pathlib.Path(root) / _, must_exist=True
97-
)
94+
for pattern in COMPOSE_FILE_PATTERNS:
95+
for candidate in safe_root.rglob(pattern):
96+
candidate = _ensure_within_compose_base(candidate, must_exist=True)
9897
key = candidate.parent.name
9998
matches[key] = os.fspath(candidate)
10099
return matches
@@ -104,14 +103,15 @@ def find_yml_files():
104103
"""
105104
Find docker compose files under the compose base directory.
106105
"""
107-
return _collect_yml_files(get_compose_base_path())
106+
return _compose_file_matches(get_compose_base_path())
108107

109108

110109
def find_project_yml_files(project_name):
111110
"""
112111
Find docker compose files for a single validated project.
113112
"""
114-
return _collect_yml_files(get_compose_base_path() / _validated_project_name(project_name))
113+
project_dir = resolve_compose_project_dir(project_name)
114+
return _compose_file_matches(project_dir)
115115

116116

117117
def resolve_project_compose_manifest(project_name):

backend/requirements.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
aiodocker==0.21.0
2-
aiostream==0.4.4
2+
aiostream==0.7.1
33
alembic==1.10.4
44
bcrypt==4.0.1
55
certifi==2024.7.4
66
cffi==2.0.0
77
chardet==4.0.0
88
click==8.1.6
9-
cryptography==46.0.5
9+
cryptography==46.0.6
1010
docker==6.1.2
1111
# docker-compose==2.20.0 (wrong version cant deploy)
12-
# fastapi 0.103.1 was pinned due to compatibility issues
12+
# fastapi is pinned for pydantic v1 compatibility
1313
fastapi==0.120.4
1414
# maintained fork of fastapi-jwt-auth with PyJWT 2.x support
1515
libre-fastapi-jwt==0.20.5
1616
gunicorn==23.0.0
1717
h11==0.16.0
1818
httptools==0.7.1
19-
idna==3.7
20-
makefun==1.15.0
19+
idna==3.11
20+
makefun==1.16.0
2121
# optional relational database drivers
2222
mysqlclient==2.2.0
2323
passlib==1.7.4
2424
# passlib==1.8.1 (wrong version cant deploy)
2525
psycopg2-binary==2.9.7
26-
pycparser==2.21
26+
pycparser==3.0
2727
pydantic==1.10.22
2828
# PyJWT==2.7.0
2929
PyJWT==2.12.1

0 commit comments

Comments
 (0)