Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add read-only user to deployment document #337

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions deployment/README.md
Original file line number Diff line number Diff line change
@@ -1,47 +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>` and `<MYSQL_PASSWORD>` with the appropriate values for your setup.
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 '<MYSQL_PASSWORD>';
CREATE USER IF NOT EXISTS '<MYSQL_USER>'@'%' IDENTIFIED BY '<USER_PASSWORD>';
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 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 @@ -59,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