I'm running a simple Python Flask app using Gunicorn. I want to start the Gunicorn service then run a custom shell script after the service is up.
Something like this:
FROM python:3.6.5-slim
RUN apt-get update \
&& apt-get clean \
&& apt-get install -qq -y git build-essential libpq-dev --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY . .
CMD ["entrypoint.sh"]
With the objective being to run my_custom_script.sh
after the Gunicorn service starts (currently will not run):
#!/bin/sh
echo "Waiting for postgres..."
while ! nc -z postgres 5432; do
sleep 0.1
done
echo "PostgreSQL started"
gunicorn -b 0.0.0.0:5000 manage:app
bash my_custom_script.sh
The script just builds the databases, runs some tests and adds some fact data.