-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced health check endpoints for application monitoring. - Enhanced video upload process with organized folders for each member and video. - Implemented image service to generate images in multiple formats. - **Enhancements** - Optimized Docker build process with a separate builder stage and non-root user setup. - Restructured project functionality to better facilitate video uploads. - Improved error handling and content type validation for image uploads. - **Refactor** - Updated folder structure creation for members and videos. - Refined symlink handling across services. - **Documentation** - Added comprehensive docstrings to model classes. - Updated README to reflect shift in project functionality. - **Tests** - Modified video model tests to support list of URLs. - **Chores** - Enhanced CI/CD pipeline with new jobs for linting, testing, and Docker image publishing. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
21 changed files
with
1,882 additions
and
447 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,79 @@ | ||
version: 2.1 | ||
orbs: | ||
python: circleci/[email protected] | ||
docker: circleci/[email protected] | ||
github-cli: circleci/[email protected] | ||
executors: | ||
python: | ||
docker: | ||
- image: cimg/python:3.12.2 | ||
defaults: | ||
docker_publish: &docker_publish | ||
image: bsstudio/bss-web-file-api | ||
registry: ghcr.io | ||
executor: docker/docker | ||
remote-docker-version: default | ||
use-remote-docker: true | ||
remote-docker-dlc: true | ||
use-buildkit: true | ||
tag_only: &tag_only | ||
filters: | ||
branches: | ||
ignore: /.*/ | ||
tags: | ||
only: /.*/ | ||
jobs: | ||
lint: | ||
docker: | ||
- image: cimg/python:3.12.1 | ||
executor: python | ||
steps: | ||
- checkout | ||
- python/install-packages: | ||
pkg-manager: poetry | ||
- run: poetry run isort . --check | ||
- run: poetry run black --check . | ||
- run: poetry run black . --check | ||
- run: poetry run mypy -p src.bss_web_file_server | ||
verify-requirements: | ||
executor: python | ||
steps: | ||
- checkout | ||
- python/install-packages: | ||
pkg-manager: poetry | ||
- run: poetry export -o requirements.txt | ||
- run: git diff --exit-code | ||
github_release: | ||
docker: | ||
- image: cimg/base:stable | ||
steps: | ||
- checkout | ||
- github-cli/install: | ||
version: 2.43.1 | ||
- github-cli/setup: | ||
version: 2.43.1 | ||
- run: gh release create << pipeline.git.tag >> -t << pipeline.git.tag >> --generate-notes | ||
workflows: | ||
app: | ||
Build: | ||
jobs: | ||
- lint | ||
- lint: | ||
name: Lint | ||
- verify-requirements: | ||
name: Verify requirements.txt | ||
- python/test: | ||
name: Unit tests | ||
pkg-manager: poetry | ||
test-tool: pytest | ||
version: 3.12.1 | ||
version: 3.12.2 | ||
- docker/hadolint: | ||
name: Lint Dockerfile | ||
- docker/publish: | ||
name: Build docker image | ||
<<: *docker_publish | ||
deploy: false | ||
Release: | ||
jobs: | ||
- docker/publish: | ||
name: Publish image | ||
<<: [*docker_publish, *tag_only] | ||
tag: latest,<< pipeline.git.tag >> | ||
- github_release: | ||
name: Create release | ||
<<: *tag_only |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
### Python template | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# poetry | ||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
# This is especially recommended for binary packages to ensure reproducibility, and is more | ||
# commonly ignored for libraries. | ||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
#poetry.lock | ||
|
||
# pdm | ||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. | ||
#pdm.lock | ||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it | ||
# in version control. | ||
# https://pdm.fming.dev/#use-with-ide | ||
.pdm.toml | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# PyCharm | ||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
.idea/ | ||
|
||
.git |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,42 @@ | ||
FROM python:3.12.2 as poetry | ||
RUN pip install poetry==1.7.1 | ||
FROM python:3.12 as builder | ||
|
||
FROM poetry | ||
WORKDIR /app | ||
|
||
COPY pyproject.toml poetry.lock ./ | ||
RUN poetry install --no-root --no-directory | ||
# python | ||
ENV PYTHONUNBUFFERED=1 \ | ||
# prevents python creating .pyc files | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
\ | ||
# pip | ||
PIP_NO_CACHE_DIR=off \ | ||
PIP_DISABLE_PIP_VERSION_CHECK=on | ||
|
||
COPY ./src/ ./src | ||
COPY ./README.md ./ | ||
RUN poetry install --only=main | ||
COPY ./requirements.txt ./ | ||
|
||
RUN mkdir -p /data/{m,member,v,video} | ||
ENV SERVER_BASE_PATH="/data" | ||
RUN pip wheel --no-cache-dir --no-deps --wheel-dir ./wheels -r requirements.txt | ||
|
||
FROM python:3.12-slim AS app | ||
|
||
# use non-root user | ||
RUN adduser --system --group --home /home/abc abc | ||
USER abc:abc | ||
WORKDIR /home/abc | ||
|
||
# python | ||
ENV PYTHONUNBUFFERED=1 \ | ||
# prevents python creating .pyc files | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
\ | ||
# pip | ||
PIP_NO_CACHE_DIR=off \ | ||
PIP_DISABLE_PIP_VERSION_CHECK=on | ||
|
||
COPY --from=builder /app/wheels ./wheels | ||
COPY --from=builder /app/requirements.txt ./ | ||
|
||
RUN pip install --no-cache-dir ./wheels/* | ||
|
||
COPY ./src ./src | ||
|
||
EXPOSE 80 | ||
CMD ["uvicorn", "src.bss_web_file_server.main:app", "--host", "0.0.0.0", "--port", "80"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,48 @@ | ||
# BSS Web File Server | ||
Manage symlinks and image uploads | ||
|
||
This project aims to help the video upload process. | ||
It will create folders for each member and video | ||
based on their uuid. | ||
|
||
## Run server | ||
|
||
```shell | ||
uvicorn src.bss_web_file_server.main:app | ||
``` | ||
|
||
## Development | ||
|
||
```shell | ||
uvicorn src.bss_web_file_server.main:app --reload | ||
``` | ||
|
||
## Lint | ||
|
||
```shell | ||
poetry run isort . --check | ||
poetry run black . --check | ||
poetry run mypy -p src.bss_web_file_server | ||
``` | ||
|
||
Apply lint | ||
|
||
```shell | ||
poetry run isort . | ||
poetry run black . | ||
``` | ||
|
||
## Test | ||
|
||
```shell | ||
poetry run pytest | ||
``` | ||
|
||
## Build docker image | ||
```shell | ||
docker build -t bss_web_file_server . | ||
``` | ||
|
||
## Run docker compose | ||
```shell | ||
docker-compose up | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: "3.9" | ||
services: | ||
app: | ||
build: | ||
context: . | ||
ports: | ||
- "80:80" | ||
environment: | ||
SERVER_BASE_PATH: /assets | ||
healthcheck: | ||
test: "wget --tries=1 --no-verbose -qO- http://localhost:80/health | grep -q UP" | ||
start_period: 5s | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
volumes: | ||
- ./assets:/assets |
Oops, something went wrong.