Skip to content

Commit

Permalink
chore: add read-only user to deployment document
Browse files Browse the repository at this point in the history
  • Loading branch information
themantre committed Mar 2, 2025
1 parent 0cae08d commit f0eb7f3
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions deployment/README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,54 @@
## Pagu Deployment
# Pagu Deployment

This project includes an automated deployment process for both the `stable` and `latest` versions of the Pagu bots.

### First-Time Setup
## First-Time Setup

#### Database User Setup
### Database User Setup

To grant the correct privileges to a single database user, execute the following SQL commands.
Make sure to replace `<MYSQL_USER>`, `<USER_PASSWORD>`, `<MYSQL_READONLY>` and `<READONLY_PASSWORD>`
with the appropriate values for your setup.
The read_only user granted to just read the database and ahs no write or update privilages.
To grant the correct privileges to a database user, execute the following SQL commands.
Replace `<MYSQL_USER>`, `<USER_PASSWORD>`, `<MYSQL_READONLY>`, and `<READONLY_PASSWORD>`
with appropriate values for your setup.

The read-only user is granted permission to read the database but has no write or update privileges.

```sql
CREATE DATABASE IF NOT EXISTS pagu;
CREATE DATABASE IF NOT EXISTS pagu_staging;

-- Ensure the user exists
CREATE USER IF NOT EXISTS '<MYSQL_USER>'@'%' IDENTIFIED BY '<USER_PASSWORD>';
CREATE USER IF NOT EXISTS '<MYSQL_READONLY>'@'%' IDENTIFIED BY '<READONLY_PASSWORD>';;

GRANT SELECT ON `databasename`.* TO 'username'@'localhost';
CREATE USER IF NOT EXISTS '<MYSQL_READONLY>'@'%' IDENTIFIED BY '<READONLY_PASSWORD>';

-- Grant privileges to the user on both databases
-- Grant all privileges to the main user on both databases.
GRANT ALL PRIVILEGES ON pagu.* TO '<MYSQL_USER>'@'%';
GRANT ALL PRIVILEGES ON pagu_staging.* TO '<MYSQL_USER>'@'%';

-- Grant select privileges to the read_only on both databases
-- Grant select privilege to the read-only user.
GRANT SELECT ON pagu.* TO '<MYSQL_READONLY>'@'%';
GRANT SELECT ON pagu_staging.* TO '<MYSQL_READONLY>'@'%';

-- Apply the changes
FLUSH PRIVILEGES;
```

#### Docker Network Setup
### Docker Network Setup

To enable Docker containers to communicate with each other on the same network, you need to create an external network and share it between the containers.
Use the following command to create the network:
To enable Docker containers to communicate on the same network,
create an external Docker network with the following command:

```bash
docker network create pagu_network
```


### Deployment Overview
## Deployment Overview

The deployment system operates as follows:

- **Latest Version**: Triggered when changes are pushed to the `main` branch.
- **Stable Version**: Triggered when a new stable version is released.

### Releasing a Stable Version
## Releasing a Stable Version

To release and deploy a *Stable* version, create a Git tag and push it to the repository. Follow these steps:

Expand All @@ -68,7 +66,7 @@ git push origin v${VERSION}

After creating the tag, the stable version will be released, and the deployment process will be triggered automatically.

### Updating the Working Version
## Updating the Working Version

Once a stable version is released, immediately update the [version.go](../version.go) file and open a Pull Request.
For reference, you can check this [Pull Request](https://github.com/pagu-project/pagu/pull/215).
Expand Down

0 comments on commit f0eb7f3

Please sign in to comment.