Update sk1/README.md
This commit is contained in:
parent
06118cf008
commit
ecf4948ca1
275
sk1/README.md
275
sk1/README.md
@ -0,0 +1,275 @@
|
|||||||
|
# Smart Share Hub – Secure Cloud File & Note Sharing Platform
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
Smart Share Hub is a cloud-based web application deployed using Docker containers on a Linux virtual machine. The application allows users to:
|
||||||
|
|
||||||
|
- Upload and share files
|
||||||
|
- Create and share notes
|
||||||
|
- Access the application publicly through a web browser
|
||||||
|
- Use HTTPS encryption
|
||||||
|
- Store persistent data using PostgreSQL and Docker volumes
|
||||||
|
|
||||||
|
> Developed for the Cloud Technologies assignment.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
### File Upload System
|
||||||
|
- Upload files through the web interface
|
||||||
|
- Files stored persistently inside a Docker volume
|
||||||
|
- Accessible through the browser
|
||||||
|
|
||||||
|
### Shared Notes
|
||||||
|
- Users can create notes
|
||||||
|
- Notes are stored in a PostgreSQL database
|
||||||
|
- Notes can be viewed publicly
|
||||||
|
|
||||||
|
### HTTPS Support
|
||||||
|
- Application accessible through HTTPS
|
||||||
|
- SSL/TLS certificate configured
|
||||||
|
- Secure encrypted communication
|
||||||
|
|
||||||
|
### Docker-Based Deployment
|
||||||
|
- Fully containerized application
|
||||||
|
- Easy deployment using Docker Compose
|
||||||
|
- Repeatable deployment using scripts
|
||||||
|
|
||||||
|
### Automatic Restart
|
||||||
|
- Containers restart automatically after failure
|
||||||
|
- Uses Docker restart policies
|
||||||
|
|
||||||
|
### Backup Support
|
||||||
|
- Backup script included
|
||||||
|
- Application data can be archived easily
|
||||||
|
|
||||||
|
### Persistent Storage
|
||||||
|
- PostgreSQL database volume
|
||||||
|
- Upload storage volume
|
||||||
|
|
||||||
|
### Environment Variable Configuration
|
||||||
|
- Database secrets stored in `.env`
|
||||||
|
- Sensitive data excluded from Git repository
|
||||||
|
|
||||||
|
### Logging
|
||||||
|
- NGINX access logs available
|
||||||
|
- Backend logs accessible through Docker
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Technologies Used
|
||||||
|
|
||||||
|
| Layer | Technology |
|
||||||
|
|---|---|
|
||||||
|
| Backend | Python, Flask, psycopg2 |
|
||||||
|
| Database | PostgreSQL 15 |
|
||||||
|
| Frontend | HTML, CSS, JavaScript |
|
||||||
|
| Reverse Proxy | NGINX |
|
||||||
|
| Containerization | Docker, Docker Compose |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## System Architecture
|
||||||
|
|
||||||
|
The application consists of four containers:
|
||||||
|
|
||||||
|
| Container | Purpose |
|
||||||
|
|---|---|
|
||||||
|
| `frontend` | Serves frontend web files |
|
||||||
|
| `backend` | Flask API server |
|
||||||
|
| `postgres` | PostgreSQL database |
|
||||||
|
| `nginx` | Reverse proxy and HTTPS |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Environment Variables
|
||||||
|
|
||||||
|
Secrets are stored using environment variables. Create a `.env` file in the project root:
|
||||||
|
|
||||||
|
```env
|
||||||
|
DB_PASSWORD=postgres123
|
||||||
|
```
|
||||||
|
|
||||||
|
> The `.env` file is excluded from Git using `.gitignore`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Docker Compose
|
||||||
|
|
||||||
|
The main deployment file is `docker-compose.yml`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Start application
|
||||||
|
docker-compose up -d --build
|
||||||
|
|
||||||
|
# Stop application
|
||||||
|
docker-compose down
|
||||||
|
|
||||||
|
# Remove everything including volumes
|
||||||
|
docker-compose down -v
|
||||||
|
```
|
||||||
|
|
||||||
|
**Database configuration example:**
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: smartshare
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Deployment Instructions
|
||||||
|
|
||||||
|
### 1. Install Docker
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install docker.io docker-compose -y
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Clone Repository
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone <repository-url>
|
||||||
|
cd sk1
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Create Environment File
|
||||||
|
|
||||||
|
```bash
|
||||||
|
nano .env
|
||||||
|
```
|
||||||
|
|
||||||
|
Add the following:
|
||||||
|
|
||||||
|
```env
|
||||||
|
DB_PASSWORD=postgres123
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Start Application
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose up -d --build
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Public Access
|
||||||
|
|
||||||
|
The application is publicly accessible at:
|
||||||
|
|
||||||
|
```
|
||||||
|
https://your-domain
|
||||||
|
```
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
https://joblin-share.duckdns.org
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## HTTPS Configuration
|
||||||
|
|
||||||
|
HTTPS is configured using:
|
||||||
|
- NGINX reverse proxy
|
||||||
|
- SSL/TLS certificates
|
||||||
|
|
||||||
|
All traffic is redirected through the secure HTTPS protocol.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Persistent Storage
|
||||||
|
|
||||||
|
| Volume | Purpose |
|
||||||
|
|---|---|
|
||||||
|
| `postgres_data` | PostgreSQL database storage |
|
||||||
|
| `uploads` | Uploaded files |
|
||||||
|
|
||||||
|
Data remains intact after container restarts.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Automatic Restart Policy
|
||||||
|
|
||||||
|
All containers are configured with:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
restart: always
|
||||||
|
```
|
||||||
|
|
||||||
|
This ensures automatic recovery after crashes or server reboots.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## NGINX Reverse Proxy
|
||||||
|
|
||||||
|
NGINX handles:
|
||||||
|
- HTTPS termination
|
||||||
|
- Reverse proxy routing
|
||||||
|
- Static frontend delivery
|
||||||
|
- API request forwarding
|
||||||
|
|
||||||
|
| Route | Target |
|
||||||
|
|---|---|
|
||||||
|
| `/` | Frontend |
|
||||||
|
| `/api/` | Backend API |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Security Features
|
||||||
|
|
||||||
|
- HTTPS encryption
|
||||||
|
- Environment-based secret management
|
||||||
|
- Docker network isolation
|
||||||
|
- Reverse proxy protection
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Backup System
|
||||||
|
|
||||||
|
Run the backup script:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./backup.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
The script:
|
||||||
|
- Creates compressed backups
|
||||||
|
- Stores them inside `/backups`
|
||||||
|
- Can be used for recovery
|
||||||
|
|
||||||
|
Example backup file:
|
||||||
|
|
||||||
|
```
|
||||||
|
backup_2026-05-12.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Scripts
|
||||||
|
|
||||||
|
| Script | Description | Usage |
|
||||||
|
|---|---|---|
|
||||||
|
| `prepare-app.sh` | Starts the application automatically | `./prepare-app.sh` |
|
||||||
|
| `remove-app.sh` | Stops and removes all containers | `./remove-app.sh` |
|
||||||
|
| `backup.sh` | Creates a compressed application backup | `./backup.sh` |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Logs
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# NGINX access logs
|
||||||
|
docker logs nginx
|
||||||
|
|
||||||
|
# Backend application logs
|
||||||
|
docker logs backend
|
||||||
|
|
||||||
|
# PostgreSQL logs
|
||||||
|
docker logs postgres
|
||||||
|
```
|
||||||
Loading…
Reference in New Issue
Block a user