diff --git a/Dockerfile b/Dockerfile index ccdb443..36f1c1f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,10 @@ RUN rustc --version && cargo --version # Copy application files COPY . /app +# Copy entrypoint script and make it executable +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + # Upgrade pip and install Python dependencies (using piwheels for ARM) RUN python -m pip install --upgrade pip && \ pip install --no-cache-dir --extra-index-url https://www.piwheels.org/simple -r requirements.txt @@ -22,5 +26,5 @@ RUN python -m pip install --upgrade pip && \ # Expose the application port EXPOSE 5000 -# Start the application -CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "app:app"] \ No newline at end of file +# Use entrypoint script +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 61f95f5..e77cc58 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,8 @@ -version: '3.8' - services: web: - image: digi-server:latest + image: digiserver:latest ports: - - "80:5000" + - "8880:5000" environment: - FLASK_APP=app.py - FLASK_RUN_HOST=0.0.0.0 @@ -14,5 +12,4 @@ services: volumes: - /home/pi/Desktop/digi-server/db:/app/instance - /home/pi/Desktop/digi-server/static:/app/static/uploads - command: gunicorn -w 4 -b 0.0.0.0:5000 app:app restart: unless-stopped diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..50757ec --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# filepath: /home/ske087/digiserver/entrypoint.sh + +# Initialize the database if it doesn't exist +if [ ! -f "/app/instance/dashboard.db" ]; then + echo "Initializing database..." + python init_db.py +fi + +# Start Gunicorn +exec gunicorn -w 4 -b 0.0.0.0:5000 app:app \ No newline at end of file