Skip to content

Commit 27cc6f0

Browse files
committed
feat: Add Docker testing infrastructure and fix Flask-SocketIO compatibility
- Fix Flask-SocketIO production startup by adding allow_unsafe_werkzeug=True flag - Add automated Docker test scripts for Windows (test_docker.bat) and Linux/Mac (test_docker.sh) - Create GitHub Actions workflow for automated CI/CD testing on push and PR - Add comprehensive testing documentation (deployment/TESTING.md) - Configure data volume persistence for checkpoint/resume functionality - Remove obsolete docker-compose.yml version attribute to eliminate warnings - Add SIGNATURE_ENABLED environment variable to Docker configuration
1 parent 6e4f433 commit 27cc6f0

File tree

10 files changed

+1118
-4
lines changed

10 files changed

+1118
-4
lines changed

.github/workflows/docker-test.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Docker Build and Test
2+
3+
on:
4+
push:
5+
branches: [ main, dev ]
6+
paths:
7+
- 'deployment/**'
8+
- 'src/**'
9+
- 'translation_api.py'
10+
- 'requirements.txt'
11+
- '.github/workflows/docker-test.yml'
12+
pull_request:
13+
branches: [ main, dev ]
14+
paths:
15+
- 'deployment/**'
16+
- 'src/**'
17+
- 'translation_api.py'
18+
- 'requirements.txt'
19+
workflow_dispatch: # Allow manual trigger
20+
21+
jobs:
22+
docker-build-test:
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
- name: Build Docker image
33+
working-directory: ./deployment
34+
run: |
35+
docker-compose build
36+
37+
- name: Start Docker container
38+
working-directory: ./deployment
39+
run: |
40+
# Create .env file from example
41+
cp .env.docker.example .env
42+
# Start container in detached mode
43+
docker-compose up -d
44+
45+
- name: Wait for container to be healthy
46+
run: |
47+
echo "Waiting for container to start (45 seconds)..."
48+
sleep 45
49+
50+
- name: Check container status
51+
working-directory: ./deployment
52+
run: |
53+
docker-compose ps
54+
# Check if container is running
55+
if ! docker-compose ps | grep -q "Up"; then
56+
echo "Container is not running!"
57+
docker-compose logs
58+
exit 1
59+
fi
60+
61+
- name: Test health endpoint
62+
run: |
63+
echo "Testing health endpoint..."
64+
response=$(curl -s http://localhost:5000/api/health)
65+
echo "Response: $response"
66+
67+
# Check if response contains "ok" status
68+
if echo "$response" | grep -q '"status":"ok"'; then
69+
echo "✅ Health check passed"
70+
else
71+
echo "❌ Health check failed"
72+
exit 1
73+
fi
74+
75+
- name: Test web interface
76+
run: |
77+
echo "Testing web interface..."
78+
http_code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5000/)
79+
echo "HTTP Status Code: $http_code"
80+
81+
if [ "$http_code" = "200" ]; then
82+
echo "✅ Web interface is accessible"
83+
else
84+
echo "❌ Web interface test failed"
85+
exit 1
86+
fi
87+
88+
- name: View container logs (on failure)
89+
if: failure()
90+
working-directory: ./deployment
91+
run: |
92+
echo "Container logs:"
93+
docker-compose logs
94+
95+
- name: Stop and cleanup
96+
if: always()
97+
working-directory: ./deployment
98+
run: |
99+
docker-compose down -v
100+
101+
- name: Test summary
102+
if: success()
103+
run: |
104+
echo "============================================"
105+
echo "✅ All Docker tests passed successfully!"
106+
echo "============================================"
107+
echo ""
108+
echo "Tests completed:"
109+
echo " ✅ Docker image build"
110+
echo " ✅ Container startup"
111+
echo " ✅ Health endpoint (HTTP 200, status: ok)"
112+
echo " ✅ Web interface (HTTP 200)"

deployment/.env.docker.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,12 @@ RETRY_DELAY_SECONDS=5
7272
# ============================================================================
7373
SRT_LINES_PER_BLOCK=5
7474
SRT_MAX_CHARS_PER_BLOCK=500
75+
76+
# ============================================================================
77+
# TRANSLATION SIGNATURE
78+
# ============================================================================
79+
# Add discrete attribution to translations
80+
# - EPUB: Adds metadata (dc:contributor, dc:description)
81+
# - TXT: Adds footer with project name and GitHub link
82+
# - SRT: Adds comment at end with attribution
83+
SIGNATURE_ENABLED=true

deployment/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ RUN pip install --no-cache-dir -r requirements.txt
1818
COPY . .
1919

2020
# Create necessary directories
21-
RUN mkdir -p /app/translated_files /app/logs
21+
RUN mkdir -p /app/translated_files /app/logs /app/data/uploads
2222

2323
ARG PORT=5000
2424
ENV PORT=$PORT
2525
EXPOSE $PORT
2626

2727
VOLUME /app/translated_files
2828
VOLUME /app/logs
29+
VOLUME /app/data
2930

3031
# Healthcheck to verify the server is responding
3132
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \

0 commit comments

Comments
 (0)