-
Notifications
You must be signed in to change notification settings - Fork 43
Prepare the project for selfhost #202
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,6 @@ | ||
| # Stage 1: Build frontend assets | ||
| FROM node:22-slim AS builder | ||
| RUN corepack enable | ||
| WORKDIR /app | ||
| COPY package.json pnpm-lock.yaml ./ | ||
| RUN pnpm install --frozen-lockfile | ||
| COPY . . | ||
| RUN pnpm build | ||
|
|
||
| # Stage 2: Production image | ||
| FROM python:3.12-slim | ||
| WORKDIR /app | ||
| COPY requirements.txt . | ||
| RUN pip install --no-cache-dir -r requirements.txt | ||
| COPY --from=builder /app/webapp ./webapp | ||
| COPY data ./data | ||
| COPY . . | ||
| CMD ["gunicorn", "--chdir", "webapp", "-b", "0.0.0.0:8000", "app:app"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,9 @@ | |
| url_for, | ||
| request, | ||
| ) | ||
|
|
||
| from werkzeug.middleware.proxy_fix import ProxyFix | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check werkzeug version in requirements.txt
echo "=== Checking werkzeug version ==="
grep -i werkzeug requirements.txt || echo "⚠ werkzeug not found in requirements.txt"Repository: Hugo0/wordle Length of output: 131 🏁 Script executed: # Check if webapp/app.py exists and what's on line 10
if [ -f "webapp/app.py" ]; then
echo "=== webapp/app.py line 10 ==="
sed -n '10p' webapp/app.py
else
echo "⚠ webapp/app.py not found"
fi
# Search for werkzeug in all common dependency files
echo ""
echo "=== Searching for werkzeug in all dependency files ==="
find . -maxdepth 2 -type f \( -name "setup.py" -o -name "pyproject.toml" -o -name "setup.cfg" -o -name "Pipfile" -o -name "poetry.lock" -o -name "requirements*.txt" \) -exec grep -l "werkzeug" {} \; 2>/dev/null || echo "werkzeug not found in any dependency file"
# Also check the actual content if found
echo ""
echo "=== Content of dependency files with werkzeug ==="
find . -maxdepth 2 -type f \( -name "setup.py" -o -name "pyproject.toml" -o -name "setup.cfg" -o -name "Pipfile" -o -name "poetry.lock" \) -exec sh -c 'grep -H "werkzeug" "$1" 2>/dev/null' _ {} \;Repository: Hugo0/wordle Length of output: 244 Add
🤖 Prompt for AI Agents |
||
|
|
||
| import json | ||
|
|
||
| import datetime | ||
|
|
@@ -17,6 +20,8 @@ | |
|
|
||
| app = Flask(__name__) | ||
|
|
||
| app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make ProxyFix configuration conditional or document reverse proxy requirement. Enabling ProxyFix unconditionally means the app will trust
🔒 Proposed fix: Make ProxyFix conditional on environment+import os
+
app = Flask(__name__)
-app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
+# Only enable ProxyFix when behind a reverse proxy
+if os.environ.get('BEHIND_PROXY', 'false').lower() == 'true':
+ app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)Then set 🤖 Prompt for AI Agents |
||
|
|
||
| ############################################################################### | ||
| # DATA | ||
| ############################################################################### | ||
|
|
||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: Hugo0/wordle
Length of output: 331
🏁 Script executed:
Repository: Hugo0/wordle
Length of output: 1256
Dockerfile requires
data/directory to be present for the app to start.The
requirements.txtis correctly configured with all necessary runtime dependencies (Flask, gunicorn, etc.). However,app.pyattempts to load data files fromdata/during startup (line 39 and beyond), and this directory is missing. The application will crash with aFileNotFoundErrorat runtime. Either add thedata/directory to the Docker image or copy it from the repository during the build.🤖 Prompt for AI Agents