add docker compose and update deployment manual
This commit is contained in:
+10
-19
@@ -1,23 +1,14 @@
|
||||
version: "3.9"
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16
|
||||
container_name: antrian_operasi
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_USER: rssa
|
||||
POSTGRES_PASSWORD: supersecret
|
||||
POSTGRES_DB: antrian_operasi
|
||||
api:
|
||||
container_name: antrian-operasi-api
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: antrianoperasi-api:latest
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U rssa -d antrian_operasi"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
- "8080:8080"
|
||||
restart: unless-stopped
|
||||
@@ -88,14 +88,13 @@ cd <project_name>
|
||||
go run ./migrations/seeder.go
|
||||
```
|
||||
|
||||
## Docker
|
||||
## Deployment
|
||||
```bash
|
||||
// masuk ke root project
|
||||
cd <project_name>
|
||||
// 1. Sesuaikan environment di file .env
|
||||
|
||||
// build docker image
|
||||
docker build -t antrianoperasi-api:latest .
|
||||
// 2. Build dan run container
|
||||
docker compose up -d --build
|
||||
|
||||
// run docker container
|
||||
docker run -d --name antrian-operasi-api --env-file .env -p 8080:8080 antrianoperasi-api:latest
|
||||
// 3. Run container saja (case: .env saja yang berubah)
|
||||
docker compose up -d
|
||||
```
|
||||
Reference in New Issue
Block a user