Remove unnecesary files, fixed docker stuff.
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
# Example environment configuration for Axia4
|
||||
# Copy this file to .env and customize as needed
|
||||
|
||||
# Port to expose the application on
|
||||
WEB_PORT=8080
|
||||
|
||||
# Data directory (mounted as /DATA in container)
|
||||
DATA_DIR=./DATA
|
||||
166
DOCKER.md
166
DOCKER.md
@@ -1,166 +0,0 @@
|
||||
# Axia4 Docker Setup
|
||||
|
||||
This document explains how to run the Axia4 PHP application using Docker.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Docker Engine 20.10+
|
||||
- Docker Compose V2
|
||||
|
||||
## Quick Start
|
||||
|
||||
1. **Prepare the data directory**
|
||||
```bash
|
||||
mkdir -p DATA/entreaulas/Usuarios
|
||||
mkdir -p DATA/entreaulas/Centros
|
||||
```
|
||||
|
||||
2. **Build and start the application**
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
3. **Access the application**
|
||||
|
||||
Open your browser and navigate to: `http://localhost:8080`
|
||||
|
||||
## Configuration
|
||||
|
||||
### Data Directory Structure
|
||||
|
||||
The application stores all data in the `/DATA` directory which is mounted from `./DATA` on the host:
|
||||
|
||||
```
|
||||
DATA/
|
||||
├── Usuarios.json # Main user accounts
|
||||
└── entreaulas/
|
||||
├── Usuarios/ # EntreAulas user files
|
||||
│ └── {username}.json
|
||||
└── Centros/ # Centro data
|
||||
└── {centro_id}/
|
||||
└── Aularios/ # Aulario configurations
|
||||
└── {aulario_id}.json
|
||||
```
|
||||
|
||||
### Creating Initial Users
|
||||
|
||||
**Main Users** (`DATA/Usuarios.json`):
|
||||
```json
|
||||
{
|
||||
"username": {
|
||||
"password_hash": "hashed_password_here"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**EntreAulas Users** (`DATA/entreaulas/Usuarios/{username}.json`):
|
||||
```json
|
||||
{
|
||||
"password_hash": "hashed_password_here",
|
||||
"display_name": "Full Name",
|
||||
"centro": "centro_id",
|
||||
"aulas": ["aulario_id_1", "aulario_id_2"]
|
||||
}
|
||||
```
|
||||
|
||||
To generate a password hash, you can use PHP:
|
||||
```bash
|
||||
docker exec -it axia4-app php -r "echo password_hash('your_password', PASSWORD_DEFAULT);"
|
||||
```
|
||||
|
||||
### Port Configuration
|
||||
|
||||
By default, the application runs on port 8080. To change this, edit `docker-compose.yml`:
|
||||
|
||||
```yaml
|
||||
ports:
|
||||
- "YOUR_PORT:80"
|
||||
```
|
||||
|
||||
## Docker Commands
|
||||
|
||||
### Start the application
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### Stop the application
|
||||
```bash
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
### View logs
|
||||
```bash
|
||||
docker-compose logs -f
|
||||
```
|
||||
|
||||
### Rebuild after changes
|
||||
```bash
|
||||
docker-compose up -d --build
|
||||
```
|
||||
|
||||
### Access the container shell
|
||||
```bash
|
||||
docker exec -it axia4-app bash
|
||||
```
|
||||
|
||||
## Development Mode
|
||||
|
||||
To enable live code updates without rebuilding, uncomment the volume mount in `docker-compose.yml`:
|
||||
|
||||
```yaml
|
||||
volumes:
|
||||
- ./DATA:/DATA
|
||||
- ./public_html:/var/www/html # Uncomment this line
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Permission Issues
|
||||
|
||||
If you encounter permission errors with the DATA directory:
|
||||
|
||||
```bash
|
||||
sudo chown -R 33:33 DATA
|
||||
sudo chmod -R 755 DATA
|
||||
```
|
||||
|
||||
(User ID 33 is typically the www-data user in the container)
|
||||
|
||||
### Check Application Logs
|
||||
|
||||
```bash
|
||||
docker-compose logs axia4-web
|
||||
```
|
||||
|
||||
### Inspect Container
|
||||
|
||||
```bash
|
||||
docker exec -it axia4-app bash
|
||||
# Then inside the container:
|
||||
ls -la /DATA
|
||||
cat /var/log/apache2/error.log
|
||||
```
|
||||
|
||||
## Security Notes
|
||||
|
||||
- Change default passwords immediately in production
|
||||
- Ensure the DATA directory has appropriate permissions
|
||||
- Consider using environment variables for sensitive configuration
|
||||
- Use HTTPS in production (add a reverse proxy like Nginx or Traefik)
|
||||
|
||||
## Backup
|
||||
|
||||
To backup your data:
|
||||
|
||||
```bash
|
||||
tar -czf axia4-data-backup-$(date +%Y%m%d).tar.gz DATA/
|
||||
```
|
||||
|
||||
## Restore
|
||||
|
||||
To restore from backup:
|
||||
|
||||
```bash
|
||||
tar -xzf axia4-data-backup-YYYYMMDD.tar.gz
|
||||
```
|
||||
@@ -34,7 +34,13 @@ RUN chown -R www-data:www-data /var/www/html && \
|
||||
|
||||
# Configure PHP settings
|
||||
RUN echo "session.cookie_lifetime = 604800" >> /usr/local/etc/php/conf.d/custom.ini && \
|
||||
echo "session.gc_maxlifetime = 604800" >> /usr/local/etc/php/conf.d/custom.ini
|
||||
echo "session.gc_maxlifetime = 604800" >> /usr/local/etc/php/conf.d/custom.ini && \
|
||||
echo "upload_max_filesize = 500M" >> /usr/local/etc/php/conf.d/custom.ini && \
|
||||
echo "post_max_size = 500M" >> /usr/local/etc/php/conf.d/custom.ini && \
|
||||
echo "memory_limit = 512M" >> /usr/local/etc/php/conf.d/custom.ini && \
|
||||
echo "max_execution_time = 300" >> /usr/local/etc/php/conf.d/custom.ini && \
|
||||
echo "date.timezone = UTC" >> /usr/local/etc/php/conf.d/custom.ini && \
|
||||
echo "display_errors = off" >> /usr/local/etc/php/conf.d/custom.ini
|
||||
|
||||
# Expose port 80
|
||||
EXPOSE 80
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
# Dockerization Implementation Summary
|
||||
|
||||
## Overview
|
||||
Successfully dockerized the Axia4 PHP application and migrated all data references to use the `/DATA/` directory for better portability and consistency.
|
||||
|
||||
## Changes Made
|
||||
|
||||
### 1. Docker Configuration Files
|
||||
|
||||
#### Dockerfile
|
||||
- Base image: `php:8.2-apache`
|
||||
- Installed PHP extensions: GD (with freetype and jpeg support)
|
||||
- Enabled Apache modules: `rewrite`
|
||||
- Configured PHP session settings for longer lifetime (7 days)
|
||||
- Created `/DATA` directory with proper permissions
|
||||
- Set up Apache document root at `/var/www/html`
|
||||
|
||||
#### docker-compose.yml
|
||||
- Service: `axia4-web` running on port 8080
|
||||
- Volume mount: `./DATA:/DATA` for persistent storage
|
||||
- Network: `axia4-network` for container isolation
|
||||
- Environment variables support via `.env` file
|
||||
- Restart policy: `unless-stopped`
|
||||
|
||||
#### Supporting Files
|
||||
- `.dockerignore`: Excludes unnecessary files from build context
|
||||
- `.env.example`: Template for environment configuration
|
||||
- Updated `.gitignore`: Excludes Docker runtime files and DATA directory
|
||||
|
||||
### 2. Data Path Migration
|
||||
|
||||
All data file paths were updated from hardcoded system-specific paths to use the `/DATA/` directory:
|
||||
|
||||
#### Main Application
|
||||
- `/mnt/dietpi_userdata/www_userdata/Usuarios.json` → `/DATA/Usuarios.json`
|
||||
|
||||
#### EntreAulas Module
|
||||
- `/srv/storage/entreaulas/Usuarios/*.json` → `/DATA/entreaulas/Usuarios/*.json`
|
||||
- `/srv/storage/entreaulas/Centros/*/Aularios/*.json` → `/DATA/entreaulas/Centros/*/Aularios/*.json`
|
||||
|
||||
#### Files Modified
|
||||
- `public_html/_login.php`
|
||||
- `public_html/entreaulas/_login.php`
|
||||
- `public_html/entreaulas/_incl/auth_redir.php`
|
||||
- `public_html/entreaulas/index.php`
|
||||
- `public_html/entreaulas/aulario.php`
|
||||
- `public_html/entreaulas/admin/aularios.php`
|
||||
|
||||
### 3. Path Portability Fixes
|
||||
|
||||
Fixed hardcoded `/var/www/` paths to use relative paths:
|
||||
|
||||
#### Files Modified
|
||||
- `public_html/_incl/pre-body.php`:
|
||||
- Changed `/var/www/_autoreload.php` → `__DIR__ . "/../_autoreload.php"`
|
||||
- Changed `/var/www$APP_ROOT/__menu.php` → `__DIR__ . "/.." . $APP_ROOT . "/__menu.php"`
|
||||
- `public_html/entreaulas/_incl/pre-body.php`:
|
||||
- Changed `/var/www/_incl/pre-body.php` → `__DIR__ . "/../../_incl/pre-body.php"`
|
||||
|
||||
### 4. Documentation
|
||||
|
||||
Created comprehensive documentation:
|
||||
|
||||
#### DOCKER.md
|
||||
- Quick start guide
|
||||
- Data directory structure explanation
|
||||
- Configuration instructions
|
||||
- Docker commands reference
|
||||
- Development mode setup
|
||||
- Troubleshooting guide
|
||||
- Security notes
|
||||
- Backup and restore procedures
|
||||
|
||||
#### DATA_STRUCTURE.md
|
||||
- Complete data directory structure
|
||||
- JSON file format examples
|
||||
- Password hash generation instructions
|
||||
- Security best practices
|
||||
|
||||
#### README.md
|
||||
- Updated with Docker quick start
|
||||
- Links to detailed documentation
|
||||
- Feature overview
|
||||
- Requirements section
|
||||
- Development setup guide
|
||||
|
||||
## Testing
|
||||
|
||||
All changes were tested and verified:
|
||||
|
||||
✅ Docker image builds successfully
|
||||
✅ Container starts without errors
|
||||
✅ Main page loads correctly (HTTP 200)
|
||||
✅ EntreAulas module loads correctly (HTTP 200)
|
||||
✅ DATA directory is properly mounted
|
||||
✅ Application can read from DATA/Usuarios.json
|
||||
✅ No hardcoded paths remain in the codebase
|
||||
✅ Code review completed with all issues addressed
|
||||
|
||||
## Benefits
|
||||
|
||||
1. **Portability**: Application can run on any system with Docker
|
||||
2. **Consistency**: Same environment across development, staging, and production
|
||||
3. **Easy Setup**: One-command deployment with `docker compose up`
|
||||
4. **Data Isolation**: All data in a single `/DATA` directory
|
||||
5. **Clean Architecture**: Separation of code and data
|
||||
6. **Documentation**: Comprehensive guides for setup and usage
|
||||
|
||||
## Usage
|
||||
|
||||
### Quick Start
|
||||
```bash
|
||||
# Clone and navigate to repository
|
||||
git clone https://github.com/Axia4/Axia4.git
|
||||
cd Axia4
|
||||
|
||||
# Create data directories
|
||||
mkdir -p DATA/entreaulas/Usuarios
|
||||
mkdir -p DATA/entreaulas/Centros
|
||||
|
||||
# Start the application
|
||||
docker compose up -d
|
||||
|
||||
# Access at http://localhost:8080
|
||||
```
|
||||
|
||||
### Customization
|
||||
- Port: Change in `.env` or `docker-compose.yml`
|
||||
- Data location: Update `DATA_DIR` in `.env`
|
||||
- Development: Uncomment code volume mount in `docker-compose.yml`
|
||||
|
||||
## Security Notes
|
||||
|
||||
- DATA directory excluded from version control
|
||||
- Password hashing using PHP's `password_hash()`
|
||||
- Session security configured (cookie lifetime, secure flags)
|
||||
- Proper file permissions set in container
|
||||
- No sensitive data in Docker image
|
||||
|
||||
## Future Improvements
|
||||
|
||||
Potential enhancements:
|
||||
- Add HTTPS support with reverse proxy (Nginx/Traefik)
|
||||
- Implement environment-based configuration
|
||||
- Add health checks to docker-compose
|
||||
- Create Docker multi-stage build for smaller image
|
||||
- Add database container if needed in future
|
||||
|
||||
## Conclusion
|
||||
|
||||
The Axia4 application is now fully containerized with Docker, making it easy to deploy, maintain, and scale. All data references use a consistent `/DATA/` directory structure, and comprehensive documentation is provided for users and developers.
|
||||
@@ -1,24 +1,14 @@
|
||||
services:
|
||||
axia4-web:
|
||||
build: .
|
||||
image: ghcr.io/axia4/axia4:main
|
||||
container_name: axia4-app
|
||||
ports:
|
||||
- "${WEB_PORT:-8080}:80"
|
||||
- "882:80"
|
||||
volumes:
|
||||
# Mount the DATA directory for persistent storage
|
||||
- ${DATA_DIR:-./DATA}:/DATA
|
||||
- ./DATA:/DATA
|
||||
# Optional: Mount the application code for development
|
||||
# - ./public_html:/var/www/html
|
||||
environment:
|
||||
- APACHE_DOCUMENT_ROOT=/var/www/html
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- axia4-network
|
||||
|
||||
networks:
|
||||
axia4-network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
data:
|
||||
driver: local
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<?php
|
||||
$reloaded = 0;
|
||||
opcache_reset();
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/bash
|
||||
cd /mnt/dietpi_userdata/familia
|
||||
find . -name "._*" -delete
|
||||
|
||||
cd /mnt/dietpi_userdata/www
|
||||
find . -name "._*" -delete
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php require_once __DIR__ . "/../_autoreload.php";
|
||||
|
||||
<?php
|
||||
if (!isset($APP_CODE)) {
|
||||
$APP_CODE = "ax4";
|
||||
$APP_ROOT = "/";
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if (isset($_POST["user"])) {
|
||||
$valid = "";
|
||||
$user = trim(strtolower($_POST["user"]));
|
||||
$password = $_POST["password"];
|
||||
$users = json_decode(file_get_contents("/DATA/Usuarios.json"), true);
|
||||
if (!isset($users)) {
|
||||
$valid = "Fallo del sistema: No hay cuentas.";
|
||||
}
|
||||
|
||||
$userdata = $users[$user];
|
||||
if (!isset($userdata["password_hash"])) {
|
||||
$valid = "El usuario no existe.";
|
||||
}
|
||||
|
||||
$hash = $userdata["password_hash"];
|
||||
if (password_verify($password, $hash)) {
|
||||
$_SESSION['auth_user'] = $user;
|
||||
$_SESSION['auth_data'] = $userdata;
|
||||
$_SESSION['auth_ok'] = "yes";
|
||||
header("Location: /");
|
||||
die();
|
||||
} else {
|
||||
$valid = "La contraseña no es correcta.";
|
||||
}
|
||||
|
||||
}
|
||||
require_once "_incl/pre-body.php"; ?>
|
||||
<div class="card pad">
|
||||
|
||||
<h1>Iniciar sesión</h1>
|
||||
|
||||
<form method="post">
|
||||
<fieldset class="card" style="border: 2px solid black; border-radius: 6.5px; padding: 10px 25px; max-width: 500px;">
|
||||
<label>
|
||||
<b>Usuario:</b><br>
|
||||
<input required type="text" name="user" placeholder="Ej: PepitoFlores3">
|
||||
</label><br><br>
|
||||
<label>
|
||||
<b>Contraseña:</b><br>
|
||||
<input required type="password" name="password" placeholder="Ej: PerroArbolPianoPizza">
|
||||
</label>
|
||||
<button type="submit">Iniciar sesión</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<?php require_once "_incl/post-body.php"; ?>
|
||||
@@ -7,6 +7,7 @@
|
||||
<div class="card grid-item">
|
||||
<img src="/static/logo-club.png" alt="Logo Club">
|
||||
<b>La web del club</b>
|
||||
<b>No disponible</b>
|
||||
<a href="/club/" class="button">Acceso publico</a>
|
||||
</div>
|
||||
<div class="card grid-item">
|
||||
@@ -15,12 +16,12 @@
|
||||
<span>Gestión de aularios conectados.</span>
|
||||
<a href="/entreaulas/" class="button">Tengo cuenta</a>
|
||||
</div>
|
||||
<div class="card grid-item">
|
||||
<!--<div class="card grid-item">
|
||||
<img src="/static/logo-oscar.png" alt="Logo OSCAR">
|
||||
<b>OSCAR</b>
|
||||
<span>Red de IA Absoluta.</span>
|
||||
<a href="/oscar/" disabled class="button">No disponible</a>
|
||||
</div>
|
||||
</div>-->
|
||||
<div class="card grid-item">
|
||||
<img src="/static/logo-aularios.png" alt="Logo Aularios">
|
||||
<b>Aularios<sup>2</sup></b>
|
||||
|
||||
Reference in New Issue
Block a user