Skip to content

Commit d915c9a

Browse files
committed
feat: Configure default Docker network, add SELinux volume mount compatibility, and refine PostgreSQL healthcheck.
1 parent 2ef2b8f commit d915c9a

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

app/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async def lifespan(app: FastAPI):
2020
# A. Nyalakan MQTT
2121
start_mqtt()
2222
print("✅ MQTT Listener Berjalan!")
23-
23+
2424
init_firebase()
2525

2626
# B. Konek Redis & Init Rate Limiter

docker-compose.yml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
version: '3.8'
22

3+
networks:
4+
default:
5+
driver: bridge
6+
37
services:
48
# --- SERVICE DATABASE (PostgreSQL) ---
59
db:
610
image: postgres:15-alpine
711
container_name: iot_postgres
812
restart: always
913
volumes:
10-
- postgres_data:/var/lib/postgresql/data
14+
- postgres_data:/var/lib/postgresql/data:z
1115
environment:
1216
- POSTGRES_USER=${DB_USER}
1317
- POSTGRES_PASSWORD=${DB_PASSWORD}
1418
- POSTGRES_DB=${DB_NAME}
1519
ports:
1620
- "5432:5432"
1721
healthcheck:
18-
test: ["CMD-SHELL", "pg_isready -U ${DB_USER} -d ${DB_NAME}"]
22+
# Menggunakan user yang benar (iot_postgres) agar healthcheck valid
23+
test: [ "CMD-SHELL", "pg_isready -U ${DB_USER}" ]
1924
interval: 5s
2025
timeout: 5s
2126
retries: 5
2227

28+
# --- SERVICE REDIS ---
2329
redis:
2430
image: redis:7-alpine
2531
container_name: iot_redis
@@ -29,33 +35,24 @@ services:
2935

3036
# --- SERVICE BACKEND (FastAPI) ---
3137
web:
32-
# Pakai Image dari GitHub Container Registry
3338
image: ghcr.io/bagus-devlab/pcb-backend-api:latest
34-
3539
container_name: iot_fastapi
3640
restart: always
37-
38-
# Perintah start server
3941
command: uvicorn app.main:app --host 0.0.0.0 --port 8000
40-
4142
environment:
4243
- REDIS_URL=redis://redis:6379/0
43-
44-
# PERBAIKAN: Spasi sudah diratakan & Mapping spesifik file saja
4544
volumes:
46-
- ./app/serviceAccountKey.json:/code/app/serviceAccountKey.json
47-
45+
# Ditambahkan :z karena kamu pakai Fedora (SELinux)
46+
- ./app/serviceAccountKey.json:/code/app/serviceAccountKey.json:z
4847
ports:
4948
- "8006:8000"
50-
5149
env_file:
5250
- .env
53-
5451
depends_on:
5552
db:
5653
condition: service_healthy
5754
redis:
5855
condition: service_started
5956

6057
volumes:
61-
postgres_data:
58+
postgres_data:

0 commit comments

Comments
 (0)