chore: consolidate all persistent data into ./data folder
- Update docker-compose.yml to mount Caddyfile from ./data - Remove Dockerfile directory creation - handled by init-data.sh - Add init-data.sh script to initialize ./data with all required files - Add DATA_DEPLOYMENT.md documentation for deployment workflow - Update .gitignore to exclude ./data folder - All persistent data (app, config, database, uploads) now centralized in ./data
This commit is contained in:
75
DATA_DEPLOYMENT.md
Normal file
75
DATA_DEPLOYMENT.md
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
# Data Folder Deployment Guide
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
The `./data` folder is the **persistent data storage** for the DigiServer deployment. It is **NOT committed to the repository** but contains all necessary files copied from the repo during deployment.
|
||||||
|
|
||||||
|
## Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
data/
|
||||||
|
├── app/ # Complete application code (copied from ./app)
|
||||||
|
├── Caddyfile # Reverse proxy configuration (copied from root)
|
||||||
|
├── instance/ # Flask instance folder (database, configs)
|
||||||
|
├── uploads/ # User file uploads
|
||||||
|
├── caddy-data/ # Caddy SSL certificates and cache
|
||||||
|
└── caddy-config/ # Caddy configuration data
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deployment Process
|
||||||
|
|
||||||
|
### Step 1: Initialize Data Folder
|
||||||
|
|
||||||
|
Run this script to copy all necessary files from the repository to `./data`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./init-data.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
This will:
|
||||||
|
- Create the `./data` directory structure
|
||||||
|
- Copy `./app` folder to `./data/app`
|
||||||
|
- Copy `Caddyfile` to `./data/Caddyfile`
|
||||||
|
- Set proper permissions for all files and folders
|
||||||
|
|
||||||
|
### Step 2: Start Docker Containers
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose up -d --build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 3: Run Migrations (First Time Only)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo bash deploy.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## Important Notes
|
||||||
|
|
||||||
|
- **./data is NOT in git**: The `./data` folder is listed in `.gitignore` and will not be committed
|
||||||
|
- **All persistent data here**: Database files, uploads, certificates, and configurations are stored in `./data`
|
||||||
|
- **Easy backups**: To backup the entire deployment, backup the `./data` folder
|
||||||
|
- **Easy troubleshooting**: Check the `./data` folder to verify all required files are present
|
||||||
|
- **Updates**: When you pull new changes, run `./init-data.sh` to update app files in `./data`
|
||||||
|
|
||||||
|
## Deployment Checklist
|
||||||
|
|
||||||
|
✓ All volumes in docker-compose.yml point to `./data`
|
||||||
|
✓ `./data` folder contains: app/, Caddyfile, instance/, uploads/, caddy-data/, caddy-config/
|
||||||
|
✓ Files are copied from repository to `./data` via init-data.sh
|
||||||
|
✓ Permissions are correctly set for Docker container user
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
|
||||||
|
Before starting:
|
||||||
|
```bash
|
||||||
|
ls -la data/
|
||||||
|
# Should show: app/, Caddyfile, instance/, uploads/, caddy-data/, caddy-config/
|
||||||
|
```
|
||||||
|
|
||||||
|
After deployment check data folder for:
|
||||||
|
```bash
|
||||||
|
data/instance/*.db # Database files
|
||||||
|
data/uploads/ # User uploads
|
||||||
|
data/caddy-data/*.pem # SSL certificates
|
||||||
|
```
|
||||||
@@ -31,9 +31,6 @@ COPY . .
|
|||||||
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
||||||
RUN chmod +x /docker-entrypoint.sh
|
RUN chmod +x /docker-entrypoint.sh
|
||||||
|
|
||||||
# Create directories for uploads and database
|
|
||||||
RUN mkdir -p app/static/uploads instance
|
|
||||||
|
|
||||||
# Set environment variables
|
# Set environment variables
|
||||||
ENV FLASK_APP=app.app:create_app
|
ENV FLASK_APP=app.app:create_app
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ services:
|
|||||||
expose:
|
expose:
|
||||||
- "5000"
|
- "5000"
|
||||||
volumes:
|
volumes:
|
||||||
- ./instance:/app/instance
|
- ./data/app:/app
|
||||||
- ./app/static/uploads:/app/app/static/uploads
|
- ./data/instance:/app/instance
|
||||||
- ./Caddyfile:/app/Caddyfile
|
- ./data/uploads:/app/app/static/uploads
|
||||||
environment:
|
environment:
|
||||||
- FLASK_ENV=production
|
- FLASK_ENV=production
|
||||||
- SECRET_KEY=${SECRET_KEY:-your-secret-key-change-this}
|
- SECRET_KEY=${SECRET_KEY:-your-secret-key-change-this}
|
||||||
@@ -36,9 +36,9 @@ services:
|
|||||||
- "443:443/udp" # HTTP/3 support
|
- "443:443/udp" # HTTP/3 support
|
||||||
- "2019:2019" # Caddy admin API
|
- "2019:2019" # Caddy admin API
|
||||||
volumes:
|
volumes:
|
||||||
- ./Caddyfile:/etc/caddy/Caddyfile:ro
|
- ./data/Caddyfile:/etc/caddy/Caddyfile:ro
|
||||||
- caddy-data:/data
|
- ./data/caddy-data:/data
|
||||||
- caddy-config:/config
|
- ./data/caddy-config:/config
|
||||||
environment:
|
environment:
|
||||||
- DOMAIN=${DOMAIN:-localhost}
|
- DOMAIN=${DOMAIN:-localhost}
|
||||||
- EMAIL=${EMAIL:-admin@localhost}
|
- EMAIL=${EMAIL:-admin@localhost}
|
||||||
@@ -52,7 +52,3 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
digiserver-network:
|
digiserver-network:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|
||||||
volumes:
|
|
||||||
caddy-data:
|
|
||||||
caddy-config:
|
|
||||||
|
|||||||
25
init-data.sh
Executable file
25
init-data.sh
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Initialize ./data folder with all necessary files for deployment
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "🔧 Initializing data folder..."
|
||||||
|
mkdir -p data/{app,instance,uploads,caddy-data,caddy-config}
|
||||||
|
|
||||||
|
echo "📁 Copying app folder..."
|
||||||
|
rm -rf data/app
|
||||||
|
cp -r app data/
|
||||||
|
|
||||||
|
echo "📋 Copying Caddyfile..."
|
||||||
|
cp Caddyfile data/
|
||||||
|
|
||||||
|
echo "🔐 Setting permissions..."
|
||||||
|
chmod 755 data/{app,instance,uploads,caddy-data,caddy-config}
|
||||||
|
chmod 644 data/Caddyfile
|
||||||
|
chmod -R 755 data/app/
|
||||||
|
find data/app -type f \( -name "*.py" -o -name "*.html" -o -name "*.css" -o -name "*.js" \) -exec chmod 644 {} \;
|
||||||
|
chmod 777 data/instance data/uploads
|
||||||
|
|
||||||
|
echo "✅ Data folder initialized successfully!"
|
||||||
|
echo "📊 Data folder contents:"
|
||||||
|
du -sh data/*/
|
||||||
Reference in New Issue
Block a user