Skip to content

Commit e2629e8

Browse files
codingjoeCopilot
andauthored
Add a first draft of user documentation (#30)
--------- Co-authored-by: Copilot <[email protected]>
1 parent cae71d8 commit e2629e8

File tree

14 files changed

+284
-2
lines changed

14 files changed

+284
-2
lines changed

.dtop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
hosts:
2+
- host: local
3+
dozzle: https://logs.localhost/

.github/workflows/pg-backup.yml renamed to .github/workflows/backup.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PostgreSQL Backup
1+
name: Backup
22
on:
33
schedule:
44
- cron: '0 0 * * *' # Sync daily at midnight
@@ -9,7 +9,7 @@ concurrency:
99
jobs:
1010
pg_dump:
1111
if: vars.SSH_HOSTNAME != ''
12-
name: Capture and store backup
12+
name: PostgreSQL
1313
runs-on: ubuntu-latest
1414
environment:
1515
name: production
File renamed without changes.

bin/backup_download.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env sh
2+
3+
# Download the database dump from the latest GitHub workflow
4+
# Usage: ./backup_download.sh [workflow_id]
5+
6+
set -eux
7+
8+
workflow_id="${1:-$(gh api "repos/{owner}/{repo}/actions/runs" | jq -r '.workflow_runs[] | select(.name == "Backup" and .conclusion == "success") | .id' | sed 's/"//g' | head -n 1)}"
9+
10+
gh run download "$workflow_id" -n backup.dump

bin/backup_restore.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env sh
2+
3+
# Restore the PostgreSQL database from a dump file
4+
# Usage: ./backup_restore.sh [dump_file] [database_name] [num_jobs]
5+
6+
set -eux
7+
8+
dump_file="${1:-backup.dump}"
9+
database_name="${2:-postgres}"
10+
num_jobs="${3:-$(getconf _NPROCESSORS_ONLN)}"
11+
12+
pg_restore "$dump_file" -d "$database_name" --no-acl --no-owner --no-privileges -j "$num_jobs" --disable-triggers

compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
include:
22
- path:
3+
- containers/web/compose.yml
34
- containers/web/python/compose.yml
45
- containers/compose.smtp.yml
56
- containers/compose.postgres.yml

containers/web/compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
services:
2+
web:
3+
memswap_limit: 1g # Limit total memory usage (RAM + swap) to 1GB
4+
deploy:
5+
mode: replicated
6+
replicas: 2
7+
resources:
8+
limits:
9+
cpus: '0.25' # Limit to 25% of a CPU
10+
memory: 512M # Limit to 512MB of RAM

docs/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# freePaaS
2+
3+
freePaaS is an open-source platform-as-a-service (PaaS) solution that enables developers to easily deploy, manage, and scale applications in a cloud environment. It provides a user-friendly interface and a variety of tools to streamline the application lifecycle, from development to production.
4+
5+
## Features
6+
7+
- [Easy Deployment](deployment.md): Deploy applications with just a few clicks.
8+
- [Scalability](scaling.md): Automatically scale applications based on demand.
9+
- [Monitoring](monitoring.md): Keep track of application performance and health.
10+
- [Environment Management](enviroment.md): Manage configuration and environment variables effectively.
11+
- [Backups](backups.md): Schedule and manage database backups with ease.
12+
- [File Storage](storage.md): Handle file uploads and storage seamlessly.
13+
14+
## Why and How
15+
16+
freePaaS aims to provide a zero touch CD pipeline for developers, allowing them to focus on writing code rather than managing infrastructure.
17+
18+
It is built around best practices to provide simplicity and security, while providing you the freedom to customize anything you want.
19+
20+
freePaaS uses technologies most developers are already familiar with to lower the learning curve and speed up adoption.
21+
No PhD in Kubernetes is required to deploy and manage applications, since we don't use it.

docs/backups.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Backups
2+
3+
## Database backups
4+
5+
PostgreSQL backups are captured daily using [pg_dump](https://www.postgresql.org/docs/current/app-pgdump.html) and stored as repository artifacts in GitHub Actions.
6+
7+
### Durability
8+
9+
By default, GitHub retains workflow artifacts for 90 days. You can [adjust the retention period](https://docs.github.com/en/organizations/managing-organization-settings/configuring-the-retention-period-for-github-actions-artifacts-and-logs-in-your-organization) up to a maximum of 400 days.
10+
11+
Importantly, artifacts are stored independently of your application server, ensuring that backups remain safe even if your server fails.
12+
13+
The backup frequency may be altered in the [`.github/workflows/backup.yml`](../.github/workflows/backup.yml) file. Here you may also configure additional backup targets, such as cloud storage providers.
14+
15+
### Restoration
16+
17+
To restore a backup, download the desired artifact from the GitHub Actions workflow run history. The artifact will be a compressed file containing the SQL dump.
18+
19+
You can restore the database using the built-in database scripts:
20+
21+
```bash
22+
bin/backup_download.sh
23+
bin/backup_restore.sh
24+
```
25+
26+
> [!NOTE]
27+
> Backups are stored in PostgreSQL's [custom format](https://www.postgresql.org/docs/current/app-pgdump.html) which is compressed and allows for more flexible restoration options.
28+
29+
### Privacy
30+
31+
With backups being stored on GitHub, it's crucial to consider the sensitivity of your data. Ensure that your repository is private to prevent unauthorized access to your backups. Additionally, consider encrypting your database dumps before uploading them as artifacts for an added layer of security.
32+
33+
> [!IMPORTANT]
34+
> If you are serving customers in the EU, ensure that you add GitHub as a data processor in your privacy policy to comply with GDPR regulations.

docs/deployment.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Deployment
2+
3+
Deploying your application with freePaaS is a streamlined process that involves running an installation script and leveraging GitHub Actions for continuous deployment.
4+
5+
## Initial Setup
6+
7+
The primary setup is handled by an interactive script. To start the installation wizard, run the following command from the root of the repository:
8+
9+
```bash
10+
./bin/install.sh
11+
```
12+
13+
This script will guide you through the following steps:
14+
15+
1. **Domain Configuration**: You will be prompted to enter your domain name.
16+
1. **Server Access**: The script will verify SSH access to your server.
17+
1. **GitHub Integration**: It will help you create a GitHub OAuth App for secure authentication.
18+
1. **Repository Configuration**: The script will set up the necessary GitHub repository secrets and variables to enable automated deployments. These include:
19+
- `SSH_HOSTNAME`: Your server's hostname or IP address.
20+
- `SSH_PRIVATE_KEY`: A private SSH key for accessing the server.
21+
- `SSH_KNOWN_HOSTS`: Your server's SSH host key.
22+
23+
## Continuous Deployment
24+
25+
Once the initial setup is complete, your application will be automatically deployed whenever you push changes to the `main` branch. This is handled by the [`.github/workflows/deploy.yml`](../.github/workflows/deploy.yml) GitHub Actions workflow.
26+
27+
The deployment workflow performs the following steps:
28+
29+
1. **Trigger**: The workflow is triggered by a push to the `main` branch (after the `ci` workflow succeeds) or can be triggered manually.
30+
1. **Environment Setup**: It sets up an SSH connection to your production server using the configured secrets.
31+
1. **Remote Deployment**: It establishes a remote Docker context to your server.
32+
1. **Application Start**: It uses `docker compose` to pull the latest images and start the application containers.
33+
34+
Your application will be served via a Caddy reverse proxy, which also handles automatic SSL certificate provisioning.

0 commit comments

Comments
 (0)