Skip to content

Commit 6656e0e

Browse files
committed
fix: correct Docker configuration for Rye best practices
- Remove incorrect 'rye install' usage in containers - Use requirements.lock + pip install approach (Rye recommended) - Add comprehensive .dockerignore file - Simplify Dockerfiles for faster, smaller builds - Update migration guide with correct Docker usage The previous Docker setup was using 'rye install' which is incorrect for containers. Now following official Rye documentation for containerization.
1 parent a78bd5b commit 6656e0e

File tree

5 files changed

+102
-57
lines changed

5 files changed

+102
-57
lines changed

.dockerignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Rye
2+
.venv/
3+
.python-version
4+
.rye/
5+
6+
# Development files
7+
*.egg-info/
8+
build/
9+
dist/
10+
__pycache__/
11+
*.pyc
12+
*.pyo
13+
14+
# IDE
15+
.vscode/
16+
.idea/
17+
18+
# OS
19+
.DS_Store
20+
Thumbs.db
21+
22+
# Git
23+
.git/
24+
.gitignore
25+
26+
# Documentation
27+
*.md
28+
docs/
29+
30+
# Testing
31+
.coverage
32+
.pytest_cache/
33+
.ruff_cache/
34+
.mypy_cache/
35+
36+
# Scratch/development
37+
scratch/
38+
llm_context.txt
39+
40+
# CI/CD
41+
.github/

Dockerfile

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@ FROM python:3.11-slim
22

33
WORKDIR /app
44

5-
# Install Rye
6-
RUN pip install rye
5+
# Copy requirements lock file and install dependencies
6+
COPY requirements.lock ./
7+
RUN pip install --no-cache-dir -r requirements.lock
78

8-
# Copy project configuration files
9-
COPY pyproject.toml ./
10-
11-
# Configure Rye to not create a virtual environment inside the container
12-
ENV RYE_NO_AUTO_INSTALL=1
13-
ENV RYE_USE_UV=1
14-
15-
# Install dependencies
16-
RUN rye sync --no-dev
17-
18-
# Copy the rest of the application
9+
# Copy source code
1910
COPY . .
2011

21-
# Install the application
22-
RUN rye install
12+
# Install the application using pip
13+
RUN pip install --no-cache-dir .
2314

2415
# Create a non-root user
25-
RUN useradd -m appuser
16+
ARG UID=10001
17+
RUN adduser \
18+
--disabled-password \
19+
--gecos "" \
20+
--home "/nonexistent" \
21+
--shell "/sbin/nologin" \
22+
--no-create-home \
23+
--uid "${UID}" \
24+
appuser
25+
2626
USER appuser
2727

2828
# Set the entrypoint

Dockerfile.full

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@ FROM python:3.11-slim
22

33
WORKDIR /app
44

5-
# Install Rye
6-
RUN pip install rye
5+
# Copy requirements lock file and install all dependencies
6+
COPY requirements.lock ./
7+
RUN pip install --no-cache-dir -r requirements.lock
78

8-
# Copy project configuration files
9-
COPY pyproject.toml ./
10-
11-
# Configure Rye to not create a virtual environment inside the container
12-
ENV RYE_NO_AUTO_INSTALL=1
13-
ENV RYE_USE_UV=1
14-
15-
# Install dependencies with all extras
16-
RUN rye sync --no-dev --features all
17-
18-
# Copy the rest of the application
9+
# Copy source code
1910
COPY . .
2011

21-
# Install the application
22-
RUN rye install
12+
# Install the application with all extras using pip
13+
RUN pip install --no-cache-dir .[all]
2314

2415
# Create a non-root user
25-
RUN useradd -m appuser
16+
ARG UID=10001
17+
RUN adduser \
18+
--disabled-password \
19+
--gecos "" \
20+
--home "/nonexistent" \
21+
--shell "/sbin/nologin" \
22+
--no-create-home \
23+
--uid "${UID}" \
24+
appuser
25+
2626
USER appuser
2727

2828
# Set the entrypoint

Dockerfile.tensorflow

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@ FROM python:3.11-slim
22

33
WORKDIR /app
44

5-
# Install Rye
6-
RUN pip install rye
5+
# Copy requirements lock file and install dependencies
6+
COPY requirements.lock ./
7+
RUN pip install --no-cache-dir -r requirements.lock
78

8-
# Copy project configuration files
9-
COPY pyproject.toml ./
10-
11-
# Configure Rye to not create a virtual environment inside the container
12-
ENV RYE_NO_AUTO_INSTALL=1
13-
ENV RYE_USE_UV=1
14-
15-
# Install dependencies with TensorFlow extras
16-
RUN rye sync --no-dev --features tensorflow
17-
18-
# Copy the rest of the application
9+
# Copy source code
1910
COPY . .
2011

21-
# Install the application
22-
RUN rye install
12+
# Install the application with TensorFlow extras using pip
13+
RUN pip install --no-cache-dir .[tensorflow]
2314

2415
# Create a non-root user
25-
RUN useradd -m appuser
16+
ARG UID=10001
17+
RUN adduser \
18+
--disabled-password \
19+
--gecos "" \
20+
--home "/nonexistent" \
21+
--shell "/sbin/nologin" \
22+
--no-create-home \
23+
--uid "${UID}" \
24+
appuser
25+
2626
USER appuser
2727

2828
# Set the entrypoint

MIGRATION_GUIDE.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,24 @@ The GitHub Actions workflow has been updated to use Rye:
141141
142142
### Docker
143143
144-
All Dockerfiles have been updated:
144+
All Dockerfiles have been updated to follow **Rye best practices**:
145145
146146
```dockerfile
147-
# Install Rye
148-
RUN pip install rye
149-
150-
# Configure Rye for containers
151-
ENV RYE_NO_AUTO_INSTALL=1
152-
ENV RYE_USE_UV=1
147+
# Copy requirements lock file and install dependencies
148+
COPY requirements.lock ./
149+
RUN pip install --no-cache-dir -r requirements.lock
153150

154-
# Install dependencies
155-
RUN rye sync --no-dev --features all
151+
# Copy source code and install application
152+
COPY . .
153+
RUN pip install --no-cache-dir .[all]
156154
```
157155

156+
**Key changes:**
157+
- **No Rye installation** in containers (following official recommendations)
158+
- Use `requirements.lock` + `pip install` for faster, smaller builds
159+
- Added comprehensive `.dockerignore` file
160+
- Simpler, more reliable container builds
161+
158162
## Compatibility
159163

160164
### What Stays the Same

0 commit comments

Comments
 (0)