-
Notifications
You must be signed in to change notification settings - Fork 11
Refactor ORM Layer and Improve Docker Configuration #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c216e2f
refactor(database): replace py_tools dependencies with native SQLAlch…
akaBoyLovesToCode f687109
chore: remove requirements.txt that is replaced by pyproject.toml and…
akaBoyLovesToCode d5fbac1
fix(docker): update base image from alpine to slim for better compati…
akaBoyLovesToCode 3f29da1
feat(docker): improve container build with proper Python dependency s…
akaBoyLovesToCode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,36 +1,52 @@ | ||
| # 用于构建和设置变量 | ||
| FROM python:3.12-alpine AS builder | ||
| # Single-stage build for Python application | ||
| FROM python:3.12-slim | ||
|
|
||
| # 设置时区为Asia/Shanghai, DOCKER_MODE为1 | ||
| # Set environment variables | ||
| ENV TZ=Asia/Shanghai \ | ||
| DOCKER_MODE=1 \ | ||
| PUID=0 \ | ||
| PGID=0 \ | ||
| UMASK=000 \ | ||
| PYTHONWARNINGS="ignore:semaphore_tracker:UserWarning" \ | ||
| WORKDIR="/app" | ||
|
|
||
| # 设置默认工作目录 | ||
| DOCKER_MODE=1 \ | ||
| PUID=0 \ | ||
| PGID=0 \ | ||
| UMASK=000 \ | ||
| PYTHONWARNINGS="ignore:semaphore_tracker:UserWarning" \ | ||
| WORKDIR="/app" \ | ||
| PATH="/root/.local/bin:${PATH}" | ||
|
|
||
| # Set working directory | ||
| WORKDIR ${WORKDIR} | ||
|
|
||
| #复制uv lockfile到工作目录中 | ||
| COPY uv.lock ${WORKDIR} | ||
|
|
||
| # 安装必要的环境 | ||
| RUN apk add --no-cache --virtual .build-deps gcc git musl-dev \ | ||
| && wget -qO- https://astral.sh/uv/install.sh | sh \ | ||
| && source /root/.local/bin/env \ | ||
| && uv sync \ | ||
| && uv cache clean \ | ||
| && apk del --purge .build-deps \ | ||
| && rm -rf /tmp/* /root/.cache /var/cache/apk/* | ||
|
|
||
| # 将从构建上下文目录中的文件和目录复制到新的一层的镜像内的工作目录中 | ||
| # Copy requirements files first for better caching | ||
| COPY pyproject.toml uv.lock .python-version ./ | ||
|
|
||
| # Install uv and application dependencies | ||
| # Use bash explicitly to support 'source' command | ||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends \ | ||
| gcc \ | ||
| git \ | ||
| wget \ | ||
| ca-certificates \ | ||
| bash \ | ||
| libc6-dev \ | ||
| python3-dev && \ | ||
| # Log Python version from .python-version file | ||
| echo "Target Python version from .python-version: $(cat .python-version)" && \ | ||
| # Install uv | ||
| wget -qO- https://astral.sh/uv/install.sh | bash && \ | ||
| # Make uv available without source | ||
| bash -c 'export PATH="/root/.local/bin:$PATH" && \ | ||
| # Install project dependencies from pyproject.toml | ||
| /root/.local/bin/uv sync' && \ | ||
| # Clean up build dependencies | ||
| apt-get purge -y --auto-remove gcc git wget && \ | ||
| apt-get clean && \ | ||
| rm -rf /var/lib/apt/lists/* /tmp/* /root/.cache | ||
|
|
||
| # Copy the rest of the application | ||
| COPY . . | ||
|
|
||
| # 将应用日志输出到stdout | ||
| # Redirect logs to stdout | ||
| RUN ln -sf /dev/stdout /app/default.log | ||
|
|
||
| # 定义容器启动时执行的默认命令 | ||
| ENTRYPOINT ["/root/.local/bin/uv","run","app.py"] | ||
| # Define entrypoint using uv | ||
| ENTRYPOINT ["/root/.local/bin/uv", "run", "app.py"] | ||
|
|
This file contains hidden or 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
This file contains hidden or 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,3 +0,0 @@ | ||
| from .user_model import User | ||
| from .config_model import Config | ||
| from .invite_code_model import InviteCode | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Duplicate invite code repository methods in ConfigRepository.
ConfigRepository is intended to manage Config objects only. It contains methods for creating and updating invite codes, which are also implemented in InviteCodeRepository. Consolidating all invite code operations in InviteCodeRepository would reduce duplication and ease maintenance.