Skip to content

Commit 91c0a0f

Browse files
committed
Docker Fix
1 parent 7a4d8d9 commit 91c0a0f

3 files changed

Lines changed: 218 additions & 17 deletions

File tree

.github/workflows/docker-build.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- name: Build Docker image
2121
run: |
22-
docker build -t video-subtitle-generator:test .
22+
docker compose build subtitle-generator
2323
2424
- name: Create test directories
2525
run: |
@@ -31,21 +31,15 @@ jobs:
3131
3232
- name: Test Docker container startup
3333
run: |
34-
docker run --rm \
35-
-v $(pwd)/data:/data \
36-
video-subtitle-generator:test \
34+
docker compose run --rm subtitle-generator \
3735
python -c "from src.health_checker import quick_health_check; print('Health check passed')"
3836
3937
- name: Test help command
4038
run: |
41-
docker run --rm \
42-
-v $(pwd)/data:/data \
43-
video-subtitle-generator:test \
39+
docker compose run --rm subtitle-generator \
4440
python main.py --help
4541
4642
- name: Test configuration validation
4743
run: |
48-
docker run --rm \
49-
-v $(pwd)/data:/data \
50-
video-subtitle-generator:test \
44+
docker compose run --rm subtitle-generator \
5145
python -c "from src.config_manager import ConfigManager; cm = ConfigManager(); print('Config validation passed')"

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ cp /path/to/your-service-account.json data/config/
3333

3434
### 2️⃣ Run
3535
```bash
36-
# Modern Docker Compose syntax
36+
# Modern Docker Compose syntax (uses compose.yml)
3737
docker compose run --rm subtitle-generator
3838

3939
# Or use convenience scripts
@@ -99,7 +99,7 @@ docker compose down
9999
Video-subtitle-Generator/
100100
├── 🐳 Docker Files
101101
│ ├── Dockerfile # Production container
102-
│ ├── docker-compose.yml # Service orchestration
102+
│ ├── compose.yml # Service orchestration (modern)
103103
│ ├── docker-entrypoint.sh # Container initialization
104104
│ └── docker-run.sh/.bat # Convenience scripts
105105
├── 📱 Application
@@ -133,11 +133,11 @@ processing:
133133
```
134134
135135
### Environment Variables
136-
Edit `docker-compose.yml`:
136+
Edit `compose.yml`:
137137
```yaml
138138
environment:
139-
- LOG_LEVEL=INFO # DEBUG, INFO, WARNING, ERROR
140-
- ENV=production # production, development
139+
LOG_LEVEL: INFO # DEBUG, INFO, WARNING, ERROR
140+
ENV: production # production, development
141141
```
142142

143143
## 🌍 Supported Languages
@@ -231,7 +231,7 @@ docker compose exec subtitle-generator python -c \
231231

232232
### Docker Swarm
233233
```bash
234-
docker stack deploy -c docker-compose.yml subtitle-stack
234+
docker stack deploy -c compose.yml subtitle-stack
235235
```
236236

237237
### Kubernetes
@@ -241,7 +241,7 @@ docker build -t your-registry/subtitle-generator:latest .
241241
docker push your-registry/subtitle-generator:latest
242242
243243
# Deploy (create k8s manifests from compose)
244-
kompose convert -f docker-compose.yml
244+
kompose convert -f compose.yml
245245
kubectl apply -f .
246246
```
247247

compose.yml

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
# Docker Compose for Video Subtitle Generator
2+
# Using modern Compose specification with latest best practices
3+
4+
name: video-subtitle-generator
5+
6+
services:
7+
subtitle-generator:
8+
build:
9+
context: .
10+
dockerfile: Dockerfile
11+
tags:
12+
- video-subtitle-generator:latest
13+
- video-subtitle-generator:${VERSION:-latest}
14+
image: video-subtitle-generator:latest
15+
container_name: video-subtitle-generator
16+
restart: unless-stopped
17+
18+
environment:
19+
# Application settings
20+
LOG_LEVEL: INFO
21+
PYTHONUNBUFFERED: "1"
22+
ENV: production
23+
24+
# Google Cloud settings (optional - can use service account file instead)
25+
# GOOGLE_APPLICATION_CREDENTIALS: /app/service-account.json
26+
# GCP_PROJECT_ID: your-project-id
27+
28+
volumes:
29+
# Input/Output directories - map to your local directories
30+
- type: bind
31+
source: ./data/input
32+
target: /data/input
33+
read_only: false
34+
- type: bind
35+
source: ./data/output
36+
target: /data/output
37+
read_only: false
38+
- type: bind
39+
source: ./data/logs
40+
target: /data/logs
41+
read_only: false
42+
- type: bind
43+
source: ./data/temp
44+
target: /data/temp
45+
read_only: false
46+
- type: bind
47+
source: ./data/jobs
48+
target: /data/jobs
49+
read_only: false
50+
51+
# Configuration and credentials
52+
- type: bind
53+
source: ./data/config
54+
target: /data/config
55+
read_only: true
56+
57+
# Optional: Mount local development code for hot reload
58+
# - type: bind
59+
# source: ./src
60+
# target: /app/src
61+
# read_only: true
62+
63+
ports:
64+
# Web interface port (if implemented)
65+
- target: 8080
66+
published: 8080
67+
protocol: tcp
68+
mode: host
69+
70+
# Resource limits for production
71+
deploy:
72+
resources:
73+
limits:
74+
memory: 8G
75+
cpus: '4'
76+
reservations:
77+
memory: 2G
78+
cpus: '1'
79+
80+
# Health check
81+
healthcheck:
82+
test:
83+
- CMD
84+
- python
85+
- -c
86+
- "from src.health_checker import quick_health_check; h=quick_health_check(); exit(0 if h['overall_status'] in ['healthy','warning'] else 1)"
87+
interval: 30s
88+
timeout: 10s
89+
retries: 3
90+
start_period: 60s
91+
start_interval: 5s
92+
93+
# Run in interactive mode by default
94+
stdin_open: true
95+
tty: true
96+
97+
# Security settings
98+
security_opt:
99+
- no-new-privileges:true
100+
cap_drop:
101+
- ALL
102+
cap_add:
103+
- CHOWN
104+
- SETUID
105+
- SETGID
106+
107+
# Override command examples:
108+
# command: ["python", "main.py", "--help"]
109+
# command: ["python", "main.py", "--video", "/data/input/video.mp4", "--languages", "eng,hin"]
110+
# command: ["python", "main.py", "--batch", "/data/input"]
111+
112+
# Optional: Add monitoring stack
113+
prometheus:
114+
image: prom/prometheus:v2.47.2
115+
container_name: subtitle-prometheus
116+
ports:
117+
- target: 9090
118+
published: 9090
119+
protocol: tcp
120+
mode: host
121+
volumes:
122+
- type: bind
123+
source: ./monitoring/prometheus.yml
124+
target: /etc/prometheus/prometheus.yml
125+
read_only: true
126+
- type: volume
127+
source: prometheus_data
128+
target: /prometheus
129+
command:
130+
- --config.file=/etc/prometheus/prometheus.yml
131+
- --storage.tsdb.path=/prometheus
132+
- --storage.tsdb.retention.time=30d
133+
- --web.console.libraries=/etc/prometheus/console_libraries
134+
- --web.console.templates=/etc/prometheus/consoles
135+
profiles:
136+
- monitoring
137+
security_opt:
138+
- no-new-privileges:true
139+
user: "65534:65534"
140+
restart: unless-stopped
141+
142+
grafana:
143+
image: grafana/grafana:10.2.0
144+
container_name: subtitle-grafana
145+
ports:
146+
- target: 3000
147+
published: 3000
148+
protocol: tcp
149+
mode: host
150+
environment:
151+
GF_SECURITY_ADMIN_PASSWORD: admin
152+
GF_USERS_ALLOW_SIGN_UP: "false"
153+
GF_SECURITY_DISABLE_GRAVATAR: "true"
154+
GF_USERS_DEFAULT_THEME: light
155+
GF_LOG_LEVEL: warn
156+
volumes:
157+
- type: volume
158+
source: grafana_data
159+
target: /var/lib/grafana
160+
- type: bind
161+
source: ./monitoring/grafana/dashboards
162+
target: /etc/grafana/provisioning/dashboards
163+
read_only: true
164+
- type: bind
165+
source: ./monitoring/grafana/datasources
166+
target: /etc/grafana/provisioning/datasources
167+
read_only: true
168+
depends_on:
169+
prometheus:
170+
condition: service_healthy
171+
restart: true
172+
profiles:
173+
- monitoring
174+
security_opt:
175+
- no-new-privileges:true
176+
user: "472:472"
177+
restart: unless-stopped
178+
healthcheck:
179+
test:
180+
- CMD-SHELL
181+
- "curl -f http://localhost:3000/api/health || exit 1"
182+
interval: 30s
183+
timeout: 10s
184+
retries: 3
185+
start_period: 40s
186+
187+
volumes:
188+
prometheus_data:
189+
driver: local
190+
driver_opts:
191+
type: none
192+
o: bind
193+
device: ./data/monitoring/prometheus
194+
grafana_data:
195+
driver: local
196+
driver_opts:
197+
type: none
198+
o: bind
199+
device: ./data/monitoring/grafana
200+
201+
networks:
202+
default:
203+
name: subtitle-generator-network
204+
driver: bridge
205+
ipam:
206+
config:
207+
- subnet: 172.20.0.0/16

0 commit comments

Comments
 (0)