feat: add Gitea deployment workflow for SG region and document Droplet deployment
This commit is contained in:
@@ -200,3 +200,51 @@ pub async fn delete_task_handler(
|
||||
Ok(Redirect::to("/tasks"))
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Production Deployment to a Cloud Host (DigitalOcean Droplet)
|
||||
|
||||
For production deployments (such as to a DigitalOcean Droplet), we avoid using `--network="host"`. Instead, we deploy both the database and the application container to a shared, user-defined Docker bridge network named **`dockernet`**. This provides secure internal DNS resolution and container isolation.
|
||||
|
||||
### 1. Create the Isolated Docker Network
|
||||
On your Droplet, create the bridge network:
|
||||
```bash
|
||||
docker network create dockernet
|
||||
```
|
||||
|
||||
### 2. Build and Run the Database Infrastructure
|
||||
Build the custom MongoDB infrastructure image using the dedicated `Infra.DockerFile`:
|
||||
```bash
|
||||
# 1. Build the database image
|
||||
docker build -t stick-db -f Infra.DockerFile .
|
||||
|
||||
# 2. Run the database container on 'dockernet' with host persistence
|
||||
docker run --name stick-mongodb \
|
||||
--network dockernet \
|
||||
-v /var/lib/mongodb/data:/data/db \
|
||||
-d \
|
||||
stick-db
|
||||
```
|
||||
*Note: The database container is named `stick-mongodb`. Other containers on `dockernet` can now resolve this container using `mongodb://stick-mongodb:27017`.*
|
||||
|
||||
### 3. Build and Deploy the Application Container
|
||||
Build the main application image and launch it on the same network:
|
||||
```bash
|
||||
# 1. Build the application image
|
||||
docker build -t stick-app .
|
||||
|
||||
# 2. Run the application container, linking to the database using its container name
|
||||
docker run --name stick-app-container \
|
||||
--network dockernet \
|
||||
-p 80:3007 \
|
||||
-e DATABASE_URL="mongodb://stick-mongodb:27017" \
|
||||
-e DATABASE_NAME="stick_db" \
|
||||
-e JWT_SECRET="your_secure_production_jwt_signing_key_at_least_32_chars_long" \
|
||||
-e HOST="0.0.0.0" \
|
||||
-e PORT="3007" \
|
||||
-d \
|
||||
stick-app
|
||||
```
|
||||
*Note: `-p 80:3007` maps the Droplet's external HTTP port 80 to the application's internal container port 3007.*
|
||||
|
||||
|
||||
Reference in New Issue
Block a user