Prepare for fly.io

This commit is contained in:
2025-07-01 11:22:56 +02:00
committed by Jens Luedicke
parent de510baac1
commit 264144ebca
4 changed files with 101 additions and 1 deletions

36
.dockerignore Normal file
View File

@@ -0,0 +1,36 @@
.git
.gitignore
README.md
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.DS_Store
__pycache__
*.pyc
*.pyo
*.pyd
.Python
env
pip-log.txt
pip-delete-this-directory.txt
.tox
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.log
.venv
.mypy_cache
.pytest_cache
.hypothesis
fly.toml
timetrack.db
*.db-journal
tests/

36
Dockerfile Normal file
View File

@@ -0,0 +1,36 @@
FROM python:3.9-slim
# Set working directory
WORKDIR /app
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
FLASK_APP=app.py
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements file first for better caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application
COPY . .
# Create the SQLite database directory with proper permissions
RUN mkdir -p /app/instance && chmod 777 /app/instance
# Expose the port the app runs on
EXPOSE 5000
# Run database migrations on startup
RUN python -c "from app import app, db; app.app_context().push(); db.create_all()"
# Command to run the application
CMD ["flask", "run", "--host=0.0.0.0", "--port=5000"]

3
app.py
View File

@@ -1840,4 +1840,5 @@ def download_team_hours_export():
return redirect(url_for('team_hours'))
if __name__ == '__main__':
app.run(debug=True, port=5050)
port = int(os.environ.get('PORT', 5000))
app.run(debug=False, host='0.0.0.0', port=port)

27
fly.toml Normal file
View File

@@ -0,0 +1,27 @@
app = "timetrack"
primary_region = "iad"
[build]
[env]
FLASK_APP = "app.py"
FLASK_ENV = "production"
[http_service]
internal_port = 5000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
[[mounts]]
source = "timetrack_data"
destination = "/app/instance"
[processes]
app = "flask run --host=0.0.0.0"
[[vm]]
cpu_kind = "shared"
cpus = 1
memory_mb = 256