updating the documentation of the SilverLinux Insftracture
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
services:
|
||||
gitea:
|
||||
image: gitea/gitea:latest
|
||||
container_name: gitea
|
||||
restart: unless-stopped
|
||||
|
||||
env_file:
|
||||
- /srv/secrets/company.env
|
||||
|
||||
environment:
|
||||
USER_UID: "1000"
|
||||
USER_GID: "1000"
|
||||
|
||||
GITEA__database__DB_TYPE: postgres
|
||||
GITEA__database__HOST: postgres:5432
|
||||
GITEA__database__NAME: gitea
|
||||
GITEA__database__USER: postgres
|
||||
GITEA__database__PASSWD: ${POSTGRES_ROOT_PASSWORD}
|
||||
|
||||
GITEA__server__DOMAIN: git.silveressence.net
|
||||
GITEA__server__ROOT_URL: https://git.silveressence.net/
|
||||
GITEA__server__SSH_DOMAIN: git.silveressence.net
|
||||
GITEA__server__SSH_PORT: "2222"
|
||||
|
||||
GITEA__mailer__ENABLED: "true"
|
||||
GITEA__mailer__FROM: noreply@silveressence.net
|
||||
GITEA__mailer__PROTOCOL: smtp+starttls
|
||||
GITEA__mailer__SMTP_ADDR: ${SMTP_HOST}
|
||||
GITEA__mailer__SMTP_PORT: "${SMTP_PORT}"
|
||||
GITEA__mailer__USER: ${SMTP_USERNAME}
|
||||
GITEA__mailer__PASSWD: ${SMTP_PASSWORD}
|
||||
|
||||
GITEA__openid__ENABLE_OPENID_SIGNIN: "false"
|
||||
GITEA__openid__ENABLE_OPENID_SIGNUP: "false"
|
||||
|
||||
volumes:
|
||||
- /srv/docker/gitea/data:/data
|
||||
|
||||
ports:
|
||||
- "2222:22"
|
||||
|
||||
networks:
|
||||
- proxy
|
||||
- internal
|
||||
|
||||
networks:
|
||||
proxy:
|
||||
external: true
|
||||
internal:
|
||||
external: true
|
||||
@@ -0,0 +1,287 @@
|
||||
# PostgreSQL
|
||||
|
||||
## Overview
|
||||
|
||||
PostgreSQL is the central database platform for SilverLinux.
|
||||
|
||||
Multiple applications use the same PostgreSQL instance while maintaining separate databases and database users.
|
||||
|
||||
This approach simplifies:
|
||||
|
||||
* Backup management
|
||||
* Monitoring
|
||||
* Security
|
||||
* Resource utilization
|
||||
|
||||
---
|
||||
|
||||
## Service Information
|
||||
|
||||
Container Name:
|
||||
|
||||
```text
|
||||
postgres
|
||||
```
|
||||
|
||||
Network:
|
||||
|
||||
```text
|
||||
internal
|
||||
```
|
||||
|
||||
Purpose:
|
||||
|
||||
* Application databases
|
||||
* Centralized data storage
|
||||
* Shared database platform
|
||||
|
||||
---
|
||||
|
||||
## Current Databases
|
||||
|
||||
### gitea
|
||||
|
||||
Owner:
|
||||
|
||||
```text
|
||||
gitea
|
||||
```
|
||||
|
||||
Purpose:
|
||||
|
||||
Source control and repository management.
|
||||
|
||||
Used by:
|
||||
|
||||
```text
|
||||
gitea
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### openproject
|
||||
|
||||
Owner:
|
||||
|
||||
```text
|
||||
openproject
|
||||
```
|
||||
|
||||
Purpose:
|
||||
|
||||
Project management and collaboration.
|
||||
|
||||
Used by:
|
||||
|
||||
```text
|
||||
openproject
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### postgres
|
||||
|
||||
Owner:
|
||||
|
||||
```text
|
||||
postgres
|
||||
```
|
||||
|
||||
Purpose:
|
||||
|
||||
Administrative database.
|
||||
|
||||
Used for PostgreSQL administration and maintenance.
|
||||
|
||||
---
|
||||
|
||||
## Database Ownership
|
||||
|
||||
| Database | Owner |
|
||||
| ----------- | ----------- |
|
||||
| gitea | gitea |
|
||||
| openproject | openproject |
|
||||
| postgres | postgres |
|
||||
|
||||
Each application should use its own dedicated database user whenever possible.
|
||||
|
||||
---
|
||||
|
||||
## Credentials
|
||||
|
||||
Credentials are stored in:
|
||||
|
||||
```text
|
||||
/srv/secrets/company.env
|
||||
```
|
||||
|
||||
Current variables:
|
||||
|
||||
```text
|
||||
POSTGRES_ROOT_PASSWORD
|
||||
POSTGRES_OPENPROJECT_PASSWORD
|
||||
```
|
||||
|
||||
Future variables:
|
||||
|
||||
```text
|
||||
POSTGRES_GITEA_PASSWORD
|
||||
POSTGRES_BAGET_PASSWORD
|
||||
```
|
||||
|
||||
Passwords must never be committed to Git repositories.
|
||||
|
||||
---
|
||||
|
||||
## Administration
|
||||
|
||||
Open PostgreSQL shell:
|
||||
|
||||
```bash
|
||||
docker exec -it postgres psql -U postgres
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### List Databases
|
||||
|
||||
```sql
|
||||
\l
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### List Roles
|
||||
|
||||
```sql
|
||||
\du
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### List Connections
|
||||
|
||||
```sql
|
||||
SELECT * FROM pg_stat_activity;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Create Database
|
||||
|
||||
Example:
|
||||
|
||||
```sql
|
||||
CREATE DATABASE myapp;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Create User
|
||||
|
||||
Example:
|
||||
|
||||
```sql
|
||||
CREATE USER myapp WITH PASSWORD 'StrongPassword';
|
||||
```
|
||||
|
||||
Grant permissions:
|
||||
|
||||
```sql
|
||||
GRANT ALL PRIVILEGES ON DATABASE myapp TO myapp;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Backup
|
||||
|
||||
Create database backup:
|
||||
|
||||
```bash
|
||||
docker exec postgres pg_dump -U postgres openproject > openproject.sql
|
||||
```
|
||||
|
||||
Create full cluster backup:
|
||||
|
||||
```bash
|
||||
docker exec postgres pg_dumpall -U postgres > postgres-full-backup.sql
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Restore
|
||||
|
||||
Restore database:
|
||||
|
||||
```bash
|
||||
docker exec -i postgres psql -U postgres openproject < openproject.sql
|
||||
```
|
||||
|
||||
Restore complete cluster:
|
||||
|
||||
```bash
|
||||
docker exec -i postgres psql -U postgres < postgres-full-backup.sql
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Security
|
||||
|
||||
* PostgreSQL is not exposed publicly.
|
||||
* Database traffic is restricted to Docker internal networks.
|
||||
* Credentials are stored in `/srv/secrets/company.env`.
|
||||
* Administrative access should use the `postgres` role only when necessary.
|
||||
* Applications should use dedicated database users.
|
||||
|
||||
---
|
||||
|
||||
## Monitoring
|
||||
|
||||
Useful commands:
|
||||
|
||||
Database size:
|
||||
|
||||
```sql
|
||||
SELECT pg_database.datname,
|
||||
pg_size_pretty(pg_database_size(pg_database.datname))
|
||||
FROM pg_database;
|
||||
```
|
||||
|
||||
Current connections:
|
||||
|
||||
```sql
|
||||
SELECT count(*) FROM pg_stat_activity;
|
||||
```
|
||||
|
||||
PostgreSQL version:
|
||||
|
||||
```sql
|
||||
SELECT version();
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Disaster Recovery
|
||||
|
||||
Minimum requirements for recovery:
|
||||
|
||||
* PostgreSQL container configuration
|
||||
* Database backups
|
||||
* `/srv/secrets/company.env`
|
||||
* Docker network configuration
|
||||
|
||||
Without the secrets file, applications may not be able to reconnect to their databases after restoration.
|
||||
|
||||
---
|
||||
|
||||
## Related Services
|
||||
|
||||
* Gitea
|
||||
* OpenProject
|
||||
|
||||
## Related Documentation
|
||||
|
||||
* docs/server.md
|
||||
* docs/security.md
|
||||
* docs/secrets.md
|
||||
* docs/backups.md
|
||||
@@ -0,0 +1,50 @@
|
||||
services:
|
||||
gitea:
|
||||
image: gitea/gitea:latest
|
||||
container_name: gitea
|
||||
restart: unless-stopped
|
||||
|
||||
env_file:
|
||||
- /srv/secrets/company.env
|
||||
|
||||
environment:
|
||||
USER_UID: "1000"
|
||||
USER_GID: "1000"
|
||||
|
||||
GITEA__database__DB_TYPE: postgres
|
||||
GITEA__database__HOST: postgres:5432
|
||||
GITEA__database__NAME: gitea
|
||||
GITEA__database__USER: postgres
|
||||
GITEA__database__PASSWD: ${POSTGRES_ROOT_PASSWORD}
|
||||
|
||||
GITEA__server__DOMAIN: git.silveressence.net
|
||||
GITEA__server__ROOT_URL: https://git.silveressence.net/
|
||||
GITEA__server__SSH_DOMAIN: git.silveressence.net
|
||||
GITEA__server__SSH_PORT: "2222"
|
||||
|
||||
GITEA__mailer__ENABLED: "true"
|
||||
GITEA__mailer__FROM: noreply@silveressence.net
|
||||
GITEA__mailer__PROTOCOL: smtp+starttls
|
||||
GITEA__mailer__SMTP_ADDR: ${SMTP_HOST}
|
||||
GITEA__mailer__SMTP_PORT: "${SMTP_PORT}"
|
||||
GITEA__mailer__USER: ${SMTP_USERNAME}
|
||||
GITEA__mailer__PASSWD: ${SMTP_PASSWORD}
|
||||
|
||||
GITEA__openid__ENABLE_OPENID_SIGNIN: "false"
|
||||
GITEA__openid__ENABLE_OPENID_SIGNUP: "false"
|
||||
|
||||
volumes:
|
||||
- /srv/docker/gitea/data:/data
|
||||
|
||||
ports:
|
||||
- "2222:22"
|
||||
|
||||
networks:
|
||||
- proxy
|
||||
- internal
|
||||
|
||||
networks:
|
||||
proxy:
|
||||
external: true
|
||||
internal:
|
||||
external: true
|
||||
Reference in New Issue
Block a user