add docker files
This commit is contained in:
13
.env
Normal file
13
.env
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Public hosts for routing via nginx-proxy
|
||||||
|
SOLARDB_API_HOST=db.northdanubesoft.eu
|
||||||
|
SOLARDB_UI_HOST=db.northdanubesoft.eu
|
||||||
|
|
||||||
|
LETSENCRYPT_EMAIL=macamete.robert@gmail.com
|
||||||
|
|
||||||
|
# Flask
|
||||||
|
FLASK_ENV=production
|
||||||
|
|
||||||
|
# (Optional) If your Flet main file differs:
|
||||||
|
# FLET_ENTRY=client/main.py
|
||||||
|
|
||||||
|
# For your UI to call the API from the browser, ensure CORS is allowed on API or they share the same parent domain.
|
||||||
31
client/Dockerfile
Normal file
31
client/Dockerfile
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# Dockerfile.ui
|
||||||
|
FROM python:3.13-slim
|
||||||
|
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||||
|
PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends curl \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install all deps from unified requirements.txt
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
# Copy UI code + assets
|
||||||
|
COPY client/ ./client/
|
||||||
|
COPY assets/ ./assets/
|
||||||
|
COPY uploads/ ./uploads/
|
||||||
|
|
||||||
|
RUN mkdir -p /app/uploads
|
||||||
|
|
||||||
|
ENV FLET_ENTRY=client/main.py \
|
||||||
|
APP_PORT=5000 \
|
||||||
|
API_BASE_URL=https://api.example.com
|
||||||
|
|
||||||
|
EXPOSE 5000
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD curl -fsS http://localhost:5000/ || exit 1
|
||||||
|
|
||||||
|
CMD ["python", "client/main.py"]
|
||||||
70
docker-compose.yml
Normal file
70
docker-compose.yml
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
version: "3.9"
|
||||||
|
|
||||||
|
services:
|
||||||
|
solardb-api:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.api
|
||||||
|
image: solardb-api:latest
|
||||||
|
container_name: solardb-api
|
||||||
|
restart: unless-stopped
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
environment:
|
||||||
|
# nginx-proxy labels (env) for routing + certs
|
||||||
|
VIRTUAL_HOST: ${SOLARDB_API_HOST}
|
||||||
|
LETSENCRYPT_HOST: ${SOLARDB_API_HOST}
|
||||||
|
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
|
||||||
|
# Flask/TinyDB
|
||||||
|
FLASK_ENV: ${FLASK_ENV:-production}
|
||||||
|
DB_PATH: /data/db.json
|
||||||
|
volumes:
|
||||||
|
- solardb_data:/data
|
||||||
|
expose:
|
||||||
|
- "5001"
|
||||||
|
networks:
|
||||||
|
- reverse-proxy_default
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-fsS", "http://localhost:5001/healthz"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
|
||||||
|
solardb-ui:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.ui
|
||||||
|
image: solardb-ui:latest
|
||||||
|
container_name: solardb-ui
|
||||||
|
restart: unless-stopped
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
environment:
|
||||||
|
VIRTUAL_HOST: ${SOLARDB_UI_HOST}
|
||||||
|
LETSENCRYPT_HOST: ${SOLARDB_UI_HOST}
|
||||||
|
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
|
||||||
|
# Point your UI to the API public URL (https)
|
||||||
|
API_BASE_URL: https://${SOLARDB_API_HOST}
|
||||||
|
# If your entry file differs, uncomment and set it:
|
||||||
|
# FLET_ENTRY: client/main.py
|
||||||
|
volumes:
|
||||||
|
- solardb_uploads:/app/uploads
|
||||||
|
expose:
|
||||||
|
- "5000"
|
||||||
|
depends_on:
|
||||||
|
- solardb-api
|
||||||
|
networks:
|
||||||
|
- reverse-proxy_default
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-fsS", "http://localhost:5000/"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
solardb_data:
|
||||||
|
solardb_uploads:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
reverse-proxy_default:
|
||||||
|
external: true
|
||||||
6
requirements.txt
Normal file
6
requirements.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
flask==3.0.3
|
||||||
|
tinydb==4.8.2
|
||||||
|
gunicorn==22.0.0
|
||||||
|
flet==0.23.2
|
||||||
|
requests==2.32.3
|
||||||
|
flask-cors==4.0.1
|
||||||
32
solarDb/Dockerfile
Normal file
32
solarDb/Dockerfile
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Dockerfile.api
|
||||||
|
FROM python:3.13-slim
|
||||||
|
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||||
|
PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends curl \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install all deps from unified requirements.txt
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
# Copy API code
|
||||||
|
COPY solarDb/ ./solarDb/
|
||||||
|
COPY wsgi.py ./wsgi.py
|
||||||
|
|
||||||
|
# Data dir for TinyDB
|
||||||
|
RUN mkdir -p /data && chown -R 1000:1000 /data
|
||||||
|
VOLUME ["/data"]
|
||||||
|
|
||||||
|
ENV FLASK_ENV=production \
|
||||||
|
APP_PORT=5001 \
|
||||||
|
DB_PATH=/data/db.json
|
||||||
|
|
||||||
|
EXPOSE 5001
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD curl -fsS http://localhost:5001/healthz || exit 1
|
||||||
|
|
||||||
|
CMD ["gunicorn", "-k", "gthread", "-w", "2", "-b", "0.0.0.0:5001", "--graceful-timeout", "30", "wsgi:app"]
|
||||||
1
solarDb/wsgi.py
Normal file
1
solarDb/wsgi.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from solarDb.server import app
|
||||||
Reference in New Issue
Block a user