testing docker
This commit is contained in:
28
Dockerfile
28
Dockerfile
@@ -23,32 +23,8 @@ COPY . .
|
|||||||
|
|
||||||
# Create necessary directories and set permissions
|
# Create necessary directories and set permissions
|
||||||
RUN mkdir -p /app/uploads /app/static/uploads && \
|
RUN mkdir -p /app/uploads /app/static/uploads && \
|
||||||
chown -R celery:celery /app
|
chown -R celery:celery /app && \
|
||||||
|
chmod +x /app/start.sh
|
||||||
# Create and set up startup script
|
|
||||||
RUN echo '#!/bin/bash\n\
|
|
||||||
echo "Waiting for database..."\n\
|
|
||||||
while ! nc -z db 5432; do\n\
|
|
||||||
sleep 0.1\n\
|
|
||||||
done\n\
|
|
||||||
echo "Database is ready!"\n\
|
|
||||||
\n\
|
|
||||||
echo "Waiting for Redis..."\n\
|
|
||||||
while ! nc -z redis 6379; do\n\
|
|
||||||
sleep 0.1\n\
|
|
||||||
done\n\
|
|
||||||
echo "Redis is ready!"\n\
|
|
||||||
\n\
|
|
||||||
echo "Running database migrations..."\n\
|
|
||||||
flask db upgrade\n\
|
|
||||||
\n\
|
|
||||||
echo "Creating admin user..."\n\
|
|
||||||
flask create-admin\n\
|
|
||||||
\n\
|
|
||||||
echo "Starting application..."\n\
|
|
||||||
exec "$@"' > /app/start.sh && \
|
|
||||||
chmod +x /app/start.sh && \
|
|
||||||
chown celery:celery /app/start.sh
|
|
||||||
|
|
||||||
# Switch to non-root user
|
# Switch to non-root user
|
||||||
USER celery
|
USER celery
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ version: '3.8'
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
web:
|
web:
|
||||||
build: .
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
command: gunicorn --bind 0.0.0.0:5000 app:app
|
command: gunicorn --bind 0.0.0.0:5000 app:app
|
||||||
ports:
|
ports:
|
||||||
- "10335:5000"
|
- "10335:5000"
|
||||||
@@ -16,9 +18,12 @@ services:
|
|||||||
- REDIS_URL=redis://redis:6379/0
|
- REDIS_URL=redis://redis:6379/0
|
||||||
volumes:
|
volumes:
|
||||||
- uploads:/app/uploads
|
- uploads:/app/uploads
|
||||||
|
- static:/app/static
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
db:
|
||||||
- redis
|
condition: service_healthy
|
||||||
|
redis:
|
||||||
|
condition: service_healthy
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
|
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
|
||||||
@@ -58,14 +63,16 @@ services:
|
|||||||
retries: 3
|
retries: 3
|
||||||
|
|
||||||
celery_worker:
|
celery_worker:
|
||||||
build: .
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
command: celery -A celery_worker.celery worker --loglevel=info
|
command: celery -A celery_worker.celery worker --loglevel=info
|
||||||
volumes:
|
volumes:
|
||||||
- ./uploads:/app/uploads
|
- uploads:/app/uploads
|
||||||
- ./static:/app/static
|
- static:/app/static
|
||||||
environment:
|
environment:
|
||||||
- FLASK_APP=app.py
|
- FLASK_APP=app.py
|
||||||
- FLASK_ENV=development
|
- FLASK_ENV=production
|
||||||
- DATABASE_URL=postgresql://postgres:postgres@db:5432/docupulse
|
- DATABASE_URL=postgresql://postgres:postgres@db:5432/docupulse
|
||||||
- REDIS_URL=redis://redis:6379/0
|
- REDIS_URL=redis://redis:6379/0
|
||||||
depends_on:
|
depends_on:
|
||||||
@@ -87,6 +94,8 @@ services:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
name: ${COMPOSE_PROJECT_NAME:-default}_postgres_data
|
name: docupulse_postgres_data
|
||||||
uploads:
|
uploads:
|
||||||
name: ${COMPOSE_PROJECT_NAME:-default}_uploads
|
name: docupulse_uploads
|
||||||
|
static:
|
||||||
|
name: docupulse_static
|
||||||
Reference in New Issue
Block a user