I have the following folder structure:
app_name:
index.py
app.py
Dockerfile
app.py looks like so:
from dash import Dash
# meta_tags are required for the app layout to be mobile responsive
app = Dash(
__name__,
suppress_callback_exceptions=True,
meta_tags=[
{"name": "viewport", "content": "width=device-width, initial-scale=1.0"}
],
update_title=None,
)
server = app.server
and index.py looks like so:
from app import app, server
app.layout = ....
app.callbacks etc
if __name__ == "__main__":
app.run_server(
host="127.0.0.1", port="8050", debug=False, dev_tools_hot_reload=False
)
Finally, the Dockerfile looks like so:
FROM python:3.10
# Copy local code to the container image.
ENV APP_HOME /app
ENV PYTHONUNBUFFERED True
ENV SQLALCHEMY_SILENCE_UBER_WARNING 1
WORKDIR $APP_HOME
COPY requirements.txt /app/
RUN pip install -r requirements.txt
RUN pip install --no-cache-dir gunicorn
# Install Python dependencies and Gunicorn
# COPY poetry.lock pyproject.toml /app/
# RUN pip3 install --no-cache-dir poetry==1.6.1 \
# && poetry config virtualenvs.create false \
# && poetry install --no-root
RUN groupadd -r app && useradd -r -g app app
# ADD requirements.txt .
# RUN pip install --no-cache-dir -r requirements.txt && pip install --no-cache-dir gunicorn
# Copy the rest of the codebase into the image
COPY --chown=app:app . ./
USER app
EXPOSE 80
EXPOSE 443
EXPOSE 8080
# Run the web service on container startup. Here we use the gunicorn
# webserver, with one worker process and 8 threads.
# For environments with multiple CPU cores, increase the number of workers
# to be equal to the cores available in Cloud Run.
#--log-level info --workers 1 --threads 8 --timeout 0 index:server
CMD exec gunicorn --bind :8080 --log-level info index:server
However, I am finding that when I run
docker run <image_id>
[2024-07-29 04:46:20 +0000] [1] [INFO] Starting gunicorn 21.2.0
[2024-07-29 04:46:20 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1)
[2024-07-29 04:46:20 +0000] [1] [INFO] Using worker: sync
[2024-07-29 04:46:20 +0000] [7] [INFO] Booting worker with pid: 7
but when I visit http://0.0.0.0:8080 I receive nothing. What could the problem be?
Deeply appreciate any guidance, thank you