fix: use script file instead of heredoc in Dockerfile
This commit is contained in:
@@ -12,32 +12,7 @@ COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
# Create startup script
|
||||
RUN cat > /start.sh << 'EOF'
|
||||
#!/bin/bash
|
||||
set -e
|
||||
echo "Waiting for database..."
|
||||
until python -c "
|
||||
import psycopg2, os
|
||||
try:
|
||||
conn = psycopg2.connect(os.environ.get('DATABASE_URL', 'postgresql://servesync:servesync@db:5432/servesync'))
|
||||
conn.close()
|
||||
print('DB ready')
|
||||
except Exception as e:
|
||||
print(f'DB not ready: {e}')
|
||||
exit(1)
|
||||
"; do
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo "Running seed..."
|
||||
python seed.py || echo "Seed already ran or error (continuing)"
|
||||
|
||||
echo "Starting server..."
|
||||
exec uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
|
||||
EOF
|
||||
RUN chmod +x /start.sh
|
||||
RUN chmod +x /app/start.sh
|
||||
|
||||
EXPOSE 8000
|
||||
CMD ["/start.sh"]
|
||||
CMD ["/app/start.sh"]
|
||||
|
||||
Reference in New Issue
Block a user