Launch multiple server apps in localhost with different port numbers within the same container in Cloud Run

I’m creating a webapp with 2 main services: Flask and Chainlit.

When I launch my webapp locally on localhost:8080, on my landing page, when I click on the “chat” button, it redirects me to my second service chainlit, which is an AI chatbot (there are many other functionalities in the app). Here’s how I launch my two services in production:

Flask: poetry run gunicorn -b 0.0.0.0:8080 src.app.app:app

Chainlit: poetry run chainlit run --headless src/chatbot.py

When I build my docker image and launch my container locally, everything works perfectly with the 2 ports exposed. But it doesn’t work on Cloud Run. Here are the contents of my files :


app.py

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>from flask import Flask, redirect, render_template
app = Flask(__name__)
@app.route("/")
def home():
return render_template("index.html")
@app.route("/chat")
def chat():
return redirect("http://localhost:8000")
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8080)
</code>
<code>from flask import Flask, redirect, render_template app = Flask(__name__) @app.route("/") def home(): return render_template("index.html") @app.route("/chat") def chat(): return redirect("http://localhost:8000") if __name__ == "__main__": app.run(host="0.0.0.0", port=8080) </code>
from flask import Flask, redirect, render_template

app = Flask(__name__)


@app.route("/")
def home():
    return render_template("index.html")


@app.route("/chat")
def chat():
    return redirect("http://localhost:8000")


if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8080)

Dockerfile

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>FROM ollama/ollama
ENV DEBIAN_FRONTEND=noninteractive
PATH="/root/.local/bin:$PATH"
ENV HOST 0.0.0.0
# Update package list and install pipx
RUN apt-get update -y &&
apt-get install -y ffmpeg &&
apt-get install -y pipx &&
pipx install poetry==1.7.1 &&
rm -rf /var/lib/apt/lists/*
# Set the working directory
WORKDIR /app
# Copy the current directory contents into the container
COPY . .
# Install dependencies with poetry
RUN poetry install --no-root --no-cache --without explo &&
chmod +x pull_ollama_models_and_launch_app_servers.sh
EXPOSE 8080 8000
ENTRYPOINT ["./pull_ollama_models_and_launch_app_servers.sh"]
</code>
<code>FROM ollama/ollama ENV DEBIAN_FRONTEND=noninteractive PATH="/root/.local/bin:$PATH" ENV HOST 0.0.0.0 # Update package list and install pipx RUN apt-get update -y && apt-get install -y ffmpeg && apt-get install -y pipx && pipx install poetry==1.7.1 && rm -rf /var/lib/apt/lists/* # Set the working directory WORKDIR /app # Copy the current directory contents into the container COPY . . # Install dependencies with poetry RUN poetry install --no-root --no-cache --without explo && chmod +x pull_ollama_models_and_launch_app_servers.sh EXPOSE 8080 8000 ENTRYPOINT ["./pull_ollama_models_and_launch_app_servers.sh"] </code>
FROM ollama/ollama

ENV DEBIAN_FRONTEND=noninteractive 
    PATH="/root/.local/bin:$PATH"

ENV HOST 0.0.0.0

# Update package list and install pipx
RUN apt-get update -y && 
    apt-get install -y ffmpeg && 
    apt-get install -y pipx && 
    pipx install poetry==1.7.1 && 
    rm -rf /var/lib/apt/lists/*


# Set the working directory
WORKDIR /app

# Copy the current directory contents into the container
COPY . .

# Install dependencies with poetry
RUN poetry install --no-root --no-cache --without explo && 
    chmod +x pull_ollama_models_and_launch_app_servers.sh

EXPOSE 8080 8000

ENTRYPOINT ["./pull_ollama_models_and_launch_app_servers.sh"]


Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>#!/bin/bash
# Start Ollama in the background.
ollama serve &
# Pause for Ollama to start.
sleep 5
# Pause before server launch
echo "???? Launching Servers (Flask and Chainlit) ..."
sleep 5
# Start Chainlit
poetry run chainlit run --headless src/chatbot.py &
# start flask landing page
poetry run gunicorn -b 0.0.0.0:8080 src.app.app:app &
# Wait for both background processes to exit
wait
</code>
<code>#!/bin/bash # Start Ollama in the background. ollama serve & # Pause for Ollama to start. sleep 5 # Pause before server launch echo "???? Launching Servers (Flask and Chainlit) ..." sleep 5 # Start Chainlit poetry run chainlit run --headless src/chatbot.py & # start flask landing page poetry run gunicorn -b 0.0.0.0:8080 src.app.app:app & # Wait for both background processes to exit wait </code>
#!/bin/bash

# Start Ollama in the background.
ollama serve &

# Pause for Ollama to start.
sleep 5

# Pause before server launch
echo "???? Launching Servers (Flask and Chainlit) ..."
sleep 5

# Start Chainlit
poetry run chainlit run --headless src/chatbot.py &

# start flask landing page
poetry run gunicorn -b 0.0.0.0:8080 src.app.app:app &


# Wait for both background processes to exit
wait


My problem is that on Cloud Run, the landing page (index.html) works fine when I access the application via the generated URL. However, the chat part doesn’t work at all (This site can’t be reached error). Default STARTUP TCP probe succeeded after 1 attempt for container "xxx" on port 8080 is the only stack-trace available on the log, no trace of chainlit service running on port 8000.

Can anyone help me?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật