Docker buid issue
This commit is contained in:
@ -6,14 +6,21 @@ PAYU_MERCHANT_SALT=DusXSSjqqSMTPSpw32hlFXF6LKY2Zm3y
|
|||||||
PAYU_SUCCESS_URL=http://localhost:4200/payment-success
|
PAYU_SUCCESS_URL=http://localhost:4200/payment-success
|
||||||
PAYU_FAILURE_URL=http://localhost:4200/payment-failure
|
PAYU_FAILURE_URL=http://localhost:4200/payment-failure
|
||||||
|
|
||||||
|
# Flask Configuration
|
||||||
FLASK_ENV=production
|
FLASK_ENV=production
|
||||||
|
FLASK_APP=run.py
|
||||||
|
|
||||||
|
# MySQL Configuration (for production/Docker)
|
||||||
MYSQL_HOST=db
|
MYSQL_HOST=db
|
||||||
MYSQL_USER=vendinguser
|
MYSQL_USER=vendinguser
|
||||||
MYSQL_PASSWORD=vendingpass
|
MYSQL_PASSWORD=vendingpass
|
||||||
MYSQL_DATABASE=vending
|
MYSQL_DATABASE=vending
|
||||||
|
|
||||||
SQLITE_DB_PATH=machines
|
# SQLite Configuration (for development)
|
||||||
|
SQLITE_DB_PATH=machines.db
|
||||||
|
|
||||||
|
# SQLAlchemy Configuration
|
||||||
|
SQLALCHEMY_ECHO=False
|
||||||
|
|
||||||
BREVO_SMTP_EMAIL=smukeshsn2000@gmail.com
|
BREVO_SMTP_EMAIL=smukeshsn2000@gmail.com
|
||||||
BREVO_SMTP_KEY=your-brevo-smtp-key
|
BREVO_SMTP_KEY=your-brevo-smtp-key
|
||||||
|
|||||||
@ -7,6 +7,11 @@ WORKDIR /app
|
|||||||
# Prevent Python from buffering stdout/stderr
|
# Prevent Python from buffering stdout/stderr
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
# Install mysql-client for database connectivity checks
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y default-mysql-client curl && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Copy requirements first for better caching
|
# Copy requirements first for better caching
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
|
|
||||||
@ -28,4 +33,4 @@ ENV FLASK_RUN_PORT=5000
|
|||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
||||||
# Use Gunicorn for production
|
# Use Gunicorn for production
|
||||||
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "run:app"]
|
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "run:app"]
|
||||||
@ -42,8 +42,9 @@ def create_app():
|
|||||||
if not all([mysql_host, mysql_user, mysql_password, mysql_db]):
|
if not all([mysql_host, mysql_user, mysql_password, mysql_db]):
|
||||||
raise ValueError("Missing required MySQL environment variables")
|
raise ValueError("Missing required MySQL environment variables")
|
||||||
|
|
||||||
|
# FIXED: Use port 3306 (internal Docker port, not the host port 3307)
|
||||||
app.config['SQLALCHEMY_DATABASE_URI'] = (
|
app.config['SQLALCHEMY_DATABASE_URI'] = (
|
||||||
f'mysql+pymysql://{mysql_user}:{mysql_password}@{mysql_host}:3307/{mysql_db}'
|
f'mysql+pymysql://{mysql_user}:{mysql_password}@{mysql_host}:3306/{mysql_db}'
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
sqlite_db_path = os.getenv('SQLITE_DB_PATH', 'machines.db')
|
sqlite_db_path = os.getenv('SQLITE_DB_PATH', 'machines.db')
|
||||||
|
|||||||
@ -47,7 +47,21 @@ services:
|
|||||||
retries: 3
|
retries: 3
|
||||||
start_period: 40s
|
start_period: 40s
|
||||||
command: >
|
command: >
|
||||||
sh -c "python seed_user.py && gunicorn --bind 0.0.0.0:5000 --workers 2 --timeout 120 run:app"
|
sh -c "
|
||||||
|
echo '⏳ Waiting for MySQL to be ready for connections...'
|
||||||
|
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
|
||||||
|
if mysql -h db -u vendinguser -pvendingpass -e 'SELECT 1' >/dev/null 2>&1; then
|
||||||
|
echo '✓ MySQL is ready!'
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo 'Waiting for MySQL... (attempt' $$i'/15)'
|
||||||
|
sleep 3
|
||||||
|
done
|
||||||
|
echo '🌱 Running database seed script...'
|
||||||
|
python seed_user.py
|
||||||
|
echo '🚀 Starting Gunicorn server...'
|
||||||
|
gunicorn --bind 0.0.0.0:5000 --workers 2 --timeout 120 run:app
|
||||||
|
"
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
build:
|
build:
|
||||||
|
|||||||
Reference in New Issue
Block a user