Prudhvi K
07/16/2024, 12:52 PMFROM prefecthq/prefect:2-python3.10
RUN apt-get update && apt-get install -y curl
COPY requirements.txt .
RUN pip install -r requirements.txt --trusted-host pypi.python.org --no-cache-dir
COPY etl_flows.py /opt/prefect/flows/etl_flows.py
COPY start_prefect.sh /opt/prefect/start_prefect.sh
WORKDIR /opt/prefect
RUN chmod +x /opt/prefect/start_prefect.sh
ENV PREFECT_API_URL="<http://127.0.0.1:4200/api>"
CMD ["./start_prefect.sh"]
Here is start_prefect.sh
#!/bin/bash
# Start the Prefect server
echo "Starting Prefect server..."
prefect server start --host 0.0.0.0 &
# Capture the PID of the Prefect server process
PREFECT_SERVER_PID=$!
# Wait for the Prefect server to start
echo "Waiting for Prefect server to start..."
sleep 20
# Check if Prefect server is still running
if ! kill -0 $PREFECT_SERVER_PID > /dev/null 2>&1; then
echo "Prefect server failed to start. Exiting..."
exit 1
fi
echo "Prefect server started successfully."
# Register the flow
echo "Registering ETL flows..."
python /opt/prefect/flows/etl_flows.py
# Keep the container running by foregrounding the Prefect server
wait $PREFECT_SERVER_PID
I'm able to successfully build this docker file and deploy it into azure container app but the problem is, I use app gateway to connect to the azure container app and through a separate route.
Example:- https://example-domain.com/prefect is my gateway url exposed to connect to container app.
If I navigate to my host, it is successfully navigating to the prefect server but rest of the url's of prefect like static /assets are being served directly from my base url instead of the relative url. They are taking https://example-domain.com/assets instead of https://example-domain.com/prefect/assets