wip
This commit is contained in:
parent
3036042416
commit
da0a156ada
5 changed files with 159 additions and 13 deletions
|
@ -1,3 +1,86 @@
|
||||||
.gitignore
|
tests/__pycache__/conftest.cpython-313-pytest-8.3.5.pyc
|
||||||
.git
|
scripts/__pycache__/check_routes.cpython-313-pytest-8.3.5.pyc
|
||||||
__pycache__
|
|
||||||
|
# Python bytecode
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
*.egg-info/
|
||||||
|
|
||||||
|
# Virtual environments
|
||||||
|
venv/
|
||||||
|
env/
|
||||||
|
ENV/
|
||||||
|
.env/
|
||||||
|
.venv/
|
||||||
|
|
||||||
|
# Flask stuff
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
flask_session/
|
||||||
|
|
||||||
|
# SQLite database files
|
||||||
|
*.sqlite
|
||||||
|
*.sqlite3
|
||||||
|
*.db
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# VS Code
|
||||||
|
.vscode/
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
|
# PyCharm
|
||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
|
*.iws
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
# Environment variables
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
.env.development
|
||||||
|
.env.test
|
||||||
|
.env.production
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs/
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
|
||||||
|
# System files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
ehthumbs.db
|
||||||
|
Desktop.ini
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
|
||||||
|
# Local development settings
|
||||||
|
local_settings.py
|
||||||
|
|
||||||
|
# Media and static files (if collected locally)
|
||||||
|
/media/
|
||||||
|
/static/collected/
|
||||||
|
|
54
.src/build.sh
Executable file
54
.src/build.sh
Executable file
|
@ -0,0 +1,54 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
IMAGE_NAME=homedocs
|
||||||
|
TAG=latest
|
||||||
|
|
||||||
|
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
||||||
|
command_exists() {
|
||||||
|
command -v "$@" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# ─< ANSI color codes >───────────────────────────────────────────────────────────────────
|
||||||
|
RED='\033[0;31m'
|
||||||
|
CYAN='\033[0;36m'
|
||||||
|
YELLOW='\033[0;33m'
|
||||||
|
LIGHT_GREEN='\033[0;92m'
|
||||||
|
BOLD='\033[1m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
echo_error() {
|
||||||
|
printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_info() {
|
||||||
|
printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_warning() {
|
||||||
|
printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_note() {
|
||||||
|
printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
checks() {
|
||||||
|
if ! command_exists docker; then
|
||||||
|
echo_error "Docker command does not exist! Please install docker to continue building!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -e ./Dockerfile ]]; then
|
||||||
|
echo_error "There is no Dockerfile in the current directory.."
|
||||||
|
echo_error "Be sure to execute the script in the project path like: ./src/build.sh"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
docker build -t "${IMAGE_NAME}:${TAG}" .
|
||||||
|
}
|
||||||
|
|
||||||
|
if checks; then
|
||||||
|
build
|
||||||
|
fi
|
26
Dockerfile
26
Dockerfile
|
@ -9,17 +9,25 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install Python dependencies
|
# Copy requirements first for better caching
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
|
||||||
RUN pip install gunicorn psycopg2-binary redis
|
|
||||||
|
|
||||||
# Copy application code
|
# Upgrade pip and install dependencies
|
||||||
|
RUN pip install --upgrade pip && \
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
|
# Copy the rest of the application
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Set environment variables
|
# Create a non-root user to run the app
|
||||||
ENV PYTHONUNBUFFERED=1
|
RUN useradd -m appuser && \
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1
|
chown -R appuser:appuser /app
|
||||||
|
|
||||||
# Run the application
|
USER appuser
|
||||||
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:8000", "wsgi:app"]
|
|
||||||
|
# Set environment variables
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||||
|
PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
# Run gunicorn
|
||||||
|
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "4", "wsgi:app"]
|
||||||
|
|
|
@ -5,7 +5,7 @@ services:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
image: homedocs:latest
|
# image: homedocs:latest
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
volumes:
|
volumes:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# Flask and core extensions
|
# Flask and core extensions
|
||||||
Flask==2.3.3
|
Flask==2.3.3
|
||||||
flask-sqlalchemy==3.1.1
|
flask-sqlalchemy==3.1.1
|
||||||
|
flask-migrate==4.0.5
|
||||||
flask-login==0.6.3
|
flask-login==0.6.3
|
||||||
flask-limiter==3.5.0
|
flask-limiter==3.5.0
|
||||||
flask-bcrypt==1.0.1
|
flask-bcrypt==1.0.1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue