Skip to content

Commit

Permalink
✨ Add support for custom prestart.sh script PR #59
Browse files Browse the repository at this point in the history
Add support for custom prestart.sh script
  • Loading branch information
tiangolo authored May 10, 2019
2 parents 9a4f7c7 + 656026f commit f58e505
Show file tree
Hide file tree
Showing 59 changed files with 481 additions and 13 deletions.
8 changes: 7 additions & 1 deletion python2.7-alpine3.7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ ENV NGINX_WORKER_PROCESSES 1
# (in a Dockerfile or with an option for `docker run`)
ENV LISTEN_PORT 80

# Copy start.sh script that will check for a /app/prestart.sh script and run it before starting the app
COPY start.sh /start.sh
RUN chmod +x /start.sh

# Copy the entrypoint that will generate Nginx additional configs
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
Expand All @@ -191,4 +195,6 @@ ENTRYPOINT ["sh", "/entrypoint.sh"]
COPY ./app /app
WORKDIR /app

CMD ["/usr/bin/supervisord"]
# Run the start script, it will check for an /app/prestart.sh script (e.g. for migrations)
# And then will start Supervisor, which in turn will start Nginx and uWSGI
CMD ["/start.sh"]
12 changes: 12 additions & 0 deletions python2.7-alpine3.7/app/prestart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /usr/bin/env sh

echo "Running inside /app/prestart.sh, you could add migrations to this file, e.g.:"

echo "
#! /usr/bin/env bash
# Let the DB start
sleep 10;
# Run migrations
alembic upgrade head
"
15 changes: 15 additions & 0 deletions python2.7-alpine3.7/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /usr/bin/env sh
set -e

# If there's a prestart.sh script in the /app directory, run it before starting
PRE_START_PATH=/app/prestart.sh
echo "Checking for script in $PRE_START_PATH"
if [ -f $PRE_START_PATH ] ; then
echo "Running script $PRE_START_PATH"
. $PRE_START_PATH
else
echo "There is no script $PRE_START_PATH"
fi

# Start Supervisor, with Nginx and uWSGI
exec /usr/bin/supervisord
8 changes: 7 additions & 1 deletion python2.7-alpine3.8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ ENV NGINX_WORKER_PROCESSES 1
# (in a Dockerfile or with an option for `docker run`)
ENV LISTEN_PORT 80

# Copy start.sh script that will check for a /app/prestart.sh script and run it before starting the app
COPY start.sh /start.sh
RUN chmod +x /start.sh

# Copy the entrypoint that will generate Nginx additional configs
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
Expand All @@ -191,4 +195,6 @@ ENTRYPOINT ["sh", "/entrypoint.sh"]
COPY ./app /app
WORKDIR /app

CMD ["/usr/bin/supervisord"]
# Run the start script, it will check for an /app/prestart.sh script (e.g. for migrations)
# And then will start Supervisor, which in turn will start Nginx and uWSGI
CMD ["/start.sh"]
12 changes: 12 additions & 0 deletions python2.7-alpine3.8/app/prestart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /usr/bin/env sh

echo "Running inside /app/prestart.sh, you could add migrations to this file, e.g.:"

echo "
#! /usr/bin/env bash
# Let the DB start
sleep 10;
# Run migrations
alembic upgrade head
"
15 changes: 15 additions & 0 deletions python2.7-alpine3.8/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /usr/bin/env sh
set -e

# If there's a prestart.sh script in the /app directory, run it before starting
PRE_START_PATH=/app/prestart.sh
echo "Checking for script in $PRE_START_PATH"
if [ -f $PRE_START_PATH ] ; then
echo "Running script $PRE_START_PATH"
. $PRE_START_PATH
else
echo "There is no script $PRE_START_PATH"
fi

# Start Supervisor, with Nginx and uWSGI
exec /usr/bin/supervisord
8 changes: 7 additions & 1 deletion python2.7-alpine3.9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ ENV NGINX_WORKER_PROCESSES 1
# (in a Dockerfile or with an option for `docker run`)
ENV LISTEN_PORT 80

# Copy start.sh script that will check for a /app/prestart.sh script and run it before starting the app
COPY start.sh /start.sh
RUN chmod +x /start.sh

# Copy the entrypoint that will generate Nginx additional configs
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
Expand All @@ -191,4 +195,6 @@ ENTRYPOINT ["sh", "/entrypoint.sh"]
COPY ./app /app
WORKDIR /app

CMD ["/usr/bin/supervisord"]
# Run the start script, it will check for an /app/prestart.sh script (e.g. for migrations)
# And then will start Supervisor, which in turn will start Nginx and uWSGI
CMD ["/start.sh"]
12 changes: 12 additions & 0 deletions python2.7-alpine3.9/app/prestart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /usr/bin/env sh

echo "Running inside /app/prestart.sh, you could add migrations to this file, e.g.:"

echo "
#! /usr/bin/env bash
# Let the DB start
sleep 10;
# Run migrations
alembic upgrade head
"
15 changes: 15 additions & 0 deletions python2.7-alpine3.9/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /usr/bin/env sh
set -e

# If there's a prestart.sh script in the /app directory, run it before starting
PRE_START_PATH=/app/prestart.sh
echo "Checking for script in $PRE_START_PATH"
if [ -f $PRE_START_PATH ] ; then
echo "Running script $PRE_START_PATH"
. $PRE_START_PATH
else
echo "There is no script $PRE_START_PATH"
fi

# Start Supervisor, with Nginx and uWSGI
exec /usr/bin/supervisord
8 changes: 7 additions & 1 deletion python2.7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ ENV NGINX_WORKER_PROCESSES 1
# (in a Dockerfile or with an option for `docker run`)
ENV LISTEN_PORT 80

# Copy start.sh script that will check for a /app/prestart.sh script and run it before starting the app
COPY start.sh /start.sh
RUN chmod +x /start.sh

# Copy the entrypoint that will generate Nginx additional configs
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
Expand All @@ -148,4 +152,6 @@ ENTRYPOINT ["/entrypoint.sh"]
COPY ./app /app
WORKDIR /app

CMD ["/usr/bin/supervisord"]
# Run the start script, it will check for an /app/prestart.sh script (e.g. for migrations)
# And then will start Supervisor, which in turn will start Nginx and uWSGI
CMD ["/start.sh"]
12 changes: 12 additions & 0 deletions python2.7/app/prestart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /usr/bin/env sh

echo "Running inside /app/prestart.sh, you could add migrations to this file, e.g.:"

echo "
#! /usr/bin/env bash
# Let the DB start
sleep 10;
# Run migrations
alembic upgrade head
"
15 changes: 15 additions & 0 deletions python2.7/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /usr/bin/env sh
set -e

# If there's a prestart.sh script in the /app directory, run it before starting
PRE_START_PATH=/app/prestart.sh
echo "Checking for script in $PRE_START_PATH"
if [ -f $PRE_START_PATH ] ; then
echo "Running script $PRE_START_PATH"
. $PRE_START_PATH
else
echo "There is no script $PRE_START_PATH"
fi

# Start Supervisor, with Nginx and uWSGI
exec /usr/bin/supervisord
8 changes: 7 additions & 1 deletion python3.5/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ ENV NGINX_WORKER_PROCESSES 1
# (in a Dockerfile or with an option for `docker run`)
ENV LISTEN_PORT 80

# Copy start.sh script that will check for a /app/prestart.sh script and run it before starting the app
COPY start.sh /start.sh
RUN chmod +x /start.sh

# Copy the entrypoint that will generate Nginx additional configs
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
Expand All @@ -146,4 +150,6 @@ ENTRYPOINT ["/entrypoint.sh"]
COPY ./app /app
WORKDIR /app

CMD ["/usr/bin/supervisord"]
# Run the start script, it will check for an /app/prestart.sh script (e.g. for migrations)
# And then will start Supervisor, which in turn will start Nginx and uWSGI
CMD ["/start.sh"]
12 changes: 12 additions & 0 deletions python3.5/app/prestart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /usr/bin/env sh

echo "Running inside /app/prestart.sh, you could add migrations to this file, e.g.:"

echo "
#! /usr/bin/env bash
# Let the DB start
sleep 10;
# Run migrations
alembic upgrade head
"
15 changes: 15 additions & 0 deletions python3.5/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /usr/bin/env sh
set -e

# If there's a prestart.sh script in the /app directory, run it before starting
PRE_START_PATH=/app/prestart.sh
echo "Checking for script in $PRE_START_PATH"
if [ -f $PRE_START_PATH ] ; then
echo "Running script $PRE_START_PATH"
. $PRE_START_PATH
else
echo "There is no script $PRE_START_PATH"
fi

# Start Supervisor, with Nginx and uWSGI
exec /usr/bin/supervisord
8 changes: 7 additions & 1 deletion python3.6-alpine3.7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ ENV NGINX_WORKER_PROCESSES 1
# (in a Dockerfile or with an option for `docker run`)
ENV LISTEN_PORT 80

# Copy start.sh script that will check for a /app/prestart.sh script and run it before starting the app
COPY start.sh /start.sh
RUN chmod +x /start.sh

# Copy the entrypoint that will generate Nginx additional configs
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
Expand All @@ -191,4 +195,6 @@ ENTRYPOINT ["sh", "/entrypoint.sh"]
COPY ./app /app
WORKDIR /app

CMD ["/usr/bin/supervisord"]
# Run the start script, it will check for an /app/prestart.sh script (e.g. for migrations)
# And then will start Supervisor, which in turn will start Nginx and uWSGI
CMD ["/start.sh"]
12 changes: 12 additions & 0 deletions python3.6-alpine3.7/app/prestart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /usr/bin/env sh

echo "Running inside /app/prestart.sh, you could add migrations to this file, e.g.:"

echo "
#! /usr/bin/env bash
# Let the DB start
sleep 10;
# Run migrations
alembic upgrade head
"
15 changes: 15 additions & 0 deletions python3.6-alpine3.7/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /usr/bin/env sh
set -e

# If there's a prestart.sh script in the /app directory, run it before starting
PRE_START_PATH=/app/prestart.sh
echo "Checking for script in $PRE_START_PATH"
if [ -f $PRE_START_PATH ] ; then
echo "Running script $PRE_START_PATH"
. $PRE_START_PATH
else
echo "There is no script $PRE_START_PATH"
fi

# Start Supervisor, with Nginx and uWSGI
exec /usr/bin/supervisord
8 changes: 7 additions & 1 deletion python3.6-alpine3.8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ ENV NGINX_WORKER_PROCESSES 1
# (in a Dockerfile or with an option for `docker run`)
ENV LISTEN_PORT 80

# Copy start.sh script that will check for a /app/prestart.sh script and run it before starting the app
COPY start.sh /start.sh
RUN chmod +x /start.sh

# Copy the entrypoint that will generate Nginx additional configs
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
Expand All @@ -191,4 +195,6 @@ ENTRYPOINT ["sh", "/entrypoint.sh"]
COPY ./app /app
WORKDIR /app

CMD ["/usr/bin/supervisord"]
# Run the start script, it will check for an /app/prestart.sh script (e.g. for migrations)
# And then will start Supervisor, which in turn will start Nginx and uWSGI
CMD ["/start.sh"]
12 changes: 12 additions & 0 deletions python3.6-alpine3.8/app/prestart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /usr/bin/env sh

echo "Running inside /app/prestart.sh, you could add migrations to this file, e.g.:"

echo "
#! /usr/bin/env bash
# Let the DB start
sleep 10;
# Run migrations
alembic upgrade head
"
15 changes: 15 additions & 0 deletions python3.6-alpine3.8/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /usr/bin/env sh
set -e

# If there's a prestart.sh script in the /app directory, run it before starting
PRE_START_PATH=/app/prestart.sh
echo "Checking for script in $PRE_START_PATH"
if [ -f $PRE_START_PATH ] ; then
echo "Running script $PRE_START_PATH"
. $PRE_START_PATH
else
echo "There is no script $PRE_START_PATH"
fi

# Start Supervisor, with Nginx and uWSGI
exec /usr/bin/supervisord
8 changes: 7 additions & 1 deletion python3.6-alpine3.9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ ENV NGINX_WORKER_PROCESSES 1
# (in a Dockerfile or with an option for `docker run`)
ENV LISTEN_PORT 80

# Copy start.sh script that will check for a /app/prestart.sh script and run it before starting the app
COPY start.sh /start.sh
RUN chmod +x /start.sh

# Copy the entrypoint that will generate Nginx additional configs
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
Expand All @@ -191,4 +195,6 @@ ENTRYPOINT ["sh", "/entrypoint.sh"]
COPY ./app /app
WORKDIR /app

CMD ["/usr/bin/supervisord"]
# Run the start script, it will check for an /app/prestart.sh script (e.g. for migrations)
# And then will start Supervisor, which in turn will start Nginx and uWSGI
CMD ["/start.sh"]
12 changes: 12 additions & 0 deletions python3.6-alpine3.9/app/prestart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /usr/bin/env sh

echo "Running inside /app/prestart.sh, you could add migrations to this file, e.g.:"

echo "
#! /usr/bin/env bash
# Let the DB start
sleep 10;
# Run migrations
alembic upgrade head
"
15 changes: 15 additions & 0 deletions python3.6-alpine3.9/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /usr/bin/env sh
set -e

# If there's a prestart.sh script in the /app directory, run it before starting
PRE_START_PATH=/app/prestart.sh
echo "Checking for script in $PRE_START_PATH"
if [ -f $PRE_START_PATH ] ; then
echo "Running script $PRE_START_PATH"
. $PRE_START_PATH
else
echo "There is no script $PRE_START_PATH"
fi

# Start Supervisor, with Nginx and uWSGI
exec /usr/bin/supervisord
Loading

0 comments on commit f58e505

Please sign in to comment.