From 6abe43bd0441eca4df560f48169e4e25403eaba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Mon, 4 Mar 2019 16:58:19 +0400 Subject: [PATCH] :sparkles: Make /start.sh independent of /entrypoint.sh And remove /entrypoint.sh, as it doesn't modify anything in the system --- python3.6-alpine3.8/Dockerfile | 7 +------ python3.6-alpine3.8/entrypoint.sh | 22 ---------------------- python3.6-alpine3.8/start.sh | 18 ++++++++++++++++++ python3.6/Dockerfile | 7 +------ python3.6/entrypoint.sh | 22 ---------------------- python3.6/start.sh | 18 ++++++++++++++++++ python3.7-alpine3.8/Dockerfile | 7 +------ python3.7-alpine3.8/entrypoint.sh | 22 ---------------------- python3.7-alpine3.8/start.sh | 18 ++++++++++++++++++ python3.7/Dockerfile | 7 +------ python3.7/entrypoint.sh | 22 ---------------------- python3.7/start.sh | 18 ++++++++++++++++++ 12 files changed, 76 insertions(+), 112 deletions(-) delete mode 100644 python3.6-alpine3.8/entrypoint.sh delete mode 100644 python3.6/entrypoint.sh delete mode 100644 python3.7-alpine3.8/entrypoint.sh delete mode 100644 python3.7/entrypoint.sh diff --git a/python3.6-alpine3.8/Dockerfile b/python3.6-alpine3.8/Dockerfile index 1b57a060..44a53022 100644 --- a/python3.6-alpine3.8/Dockerfile +++ b/python3.6-alpine3.8/Dockerfile @@ -6,9 +6,6 @@ RUN apk add --no-cache --virtual .build-deps gcc libc-dev make \ && pip install uvicorn gunicorn \ && apk del .build-deps gcc libc-dev make -COPY ./entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh - COPY ./start.sh /start.sh RUN chmod +x /start.sh @@ -21,8 +18,6 @@ ENV PYTHONPATH=/app EXPOSE 80 -ENTRYPOINT ["/entrypoint.sh"] - # Run the start script, it will check for an /app/prestart.sh script (e.g. for migrations) -# And then will start Gunicorn with Meinheld +# And then will start Gunicorn with Uvicorn CMD ["/start.sh"] diff --git a/python3.6-alpine3.8/entrypoint.sh b/python3.6-alpine3.8/entrypoint.sh deleted file mode 100644 index bcf66db2..00000000 --- a/python3.6-alpine3.8/entrypoint.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env sh -set -e - -if [ -f /app/app/main.py ]; then - DEFAULT_MODULE_NAME=app.main -elif [ -f /app/main.py ]; then - DEFAULT_MODULE_NAME=main -fi -MODULE_NAME=${MODULE_NAME:-$DEFAULT_MODULE_NAME} -VARIABLE_NAME=${VARIABLE_NAME:-app} -export APP_MODULE=${APP_MODULE:-"$MODULE_NAME:$VARIABLE_NAME"} - -if [ -f /app/gunicorn_conf.py ]; then - DEFAULT_GUNICORN_CONF=/app/gunicorn_conf.py -elif [ -f /app/app/gunicorn_conf.py ]; then - DEFAULT_GUNICORN_CONF=/app/app/gunicorn_conf.py -else - DEFAULT_GUNICORN_CONF=/gunicorn_conf.py -fi -export GUNICORN_CONF=${GUNICORN_CONF:-$DEFAULT_GUNICORN_CONF} - -exec "$@" diff --git a/python3.6-alpine3.8/start.sh b/python3.6-alpine3.8/start.sh index 47f42723..65879b4d 100644 --- a/python3.6-alpine3.8/start.sh +++ b/python3.6-alpine3.8/start.sh @@ -1,6 +1,24 @@ #! /usr/bin/env sh set -e +if [ -f /app/app/main.py ]; then + DEFAULT_MODULE_NAME=app.main +elif [ -f /app/main.py ]; then + DEFAULT_MODULE_NAME=main +fi +MODULE_NAME=${MODULE_NAME:-$DEFAULT_MODULE_NAME} +VARIABLE_NAME=${VARIABLE_NAME:-app} +export APP_MODULE=${APP_MODULE:-"$MODULE_NAME:$VARIABLE_NAME"} + +if [ -f /app/gunicorn_conf.py ]; then + DEFAULT_GUNICORN_CONF=/app/gunicorn_conf.py +elif [ -f /app/app/gunicorn_conf.py ]; then + DEFAULT_GUNICORN_CONF=/app/app/gunicorn_conf.py +else + DEFAULT_GUNICORN_CONF=/gunicorn_conf.py +fi +export GUNICORN_CONF=${GUNICORN_CONF:-$DEFAULT_GUNICORN_CONF} + # 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" diff --git a/python3.6/Dockerfile b/python3.6/Dockerfile index 10a62a6a..7436b0de 100644 --- a/python3.6/Dockerfile +++ b/python3.6/Dockerfile @@ -4,9 +4,6 @@ LABEL maintainer="Sebastian Ramirez " RUN pip install uvicorn gunicorn -COPY ./entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh - COPY ./start.sh /start.sh RUN chmod +x /start.sh @@ -19,8 +16,6 @@ ENV PYTHONPATH=/app EXPOSE 80 -ENTRYPOINT ["/entrypoint.sh"] - # Run the start script, it will check for an /app/prestart.sh script (e.g. for migrations) -# And then will start Gunicorn with Meinheld +# And then will start Gunicorn with Uvicorn CMD ["/start.sh"] diff --git a/python3.6/entrypoint.sh b/python3.6/entrypoint.sh deleted file mode 100644 index bcf66db2..00000000 --- a/python3.6/entrypoint.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env sh -set -e - -if [ -f /app/app/main.py ]; then - DEFAULT_MODULE_NAME=app.main -elif [ -f /app/main.py ]; then - DEFAULT_MODULE_NAME=main -fi -MODULE_NAME=${MODULE_NAME:-$DEFAULT_MODULE_NAME} -VARIABLE_NAME=${VARIABLE_NAME:-app} -export APP_MODULE=${APP_MODULE:-"$MODULE_NAME:$VARIABLE_NAME"} - -if [ -f /app/gunicorn_conf.py ]; then - DEFAULT_GUNICORN_CONF=/app/gunicorn_conf.py -elif [ -f /app/app/gunicorn_conf.py ]; then - DEFAULT_GUNICORN_CONF=/app/app/gunicorn_conf.py -else - DEFAULT_GUNICORN_CONF=/gunicorn_conf.py -fi -export GUNICORN_CONF=${GUNICORN_CONF:-$DEFAULT_GUNICORN_CONF} - -exec "$@" diff --git a/python3.6/start.sh b/python3.6/start.sh index 47f42723..65879b4d 100644 --- a/python3.6/start.sh +++ b/python3.6/start.sh @@ -1,6 +1,24 @@ #! /usr/bin/env sh set -e +if [ -f /app/app/main.py ]; then + DEFAULT_MODULE_NAME=app.main +elif [ -f /app/main.py ]; then + DEFAULT_MODULE_NAME=main +fi +MODULE_NAME=${MODULE_NAME:-$DEFAULT_MODULE_NAME} +VARIABLE_NAME=${VARIABLE_NAME:-app} +export APP_MODULE=${APP_MODULE:-"$MODULE_NAME:$VARIABLE_NAME"} + +if [ -f /app/gunicorn_conf.py ]; then + DEFAULT_GUNICORN_CONF=/app/gunicorn_conf.py +elif [ -f /app/app/gunicorn_conf.py ]; then + DEFAULT_GUNICORN_CONF=/app/app/gunicorn_conf.py +else + DEFAULT_GUNICORN_CONF=/gunicorn_conf.py +fi +export GUNICORN_CONF=${GUNICORN_CONF:-$DEFAULT_GUNICORN_CONF} + # 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" diff --git a/python3.7-alpine3.8/Dockerfile b/python3.7-alpine3.8/Dockerfile index 09032a29..21c2fa90 100644 --- a/python3.7-alpine3.8/Dockerfile +++ b/python3.7-alpine3.8/Dockerfile @@ -6,9 +6,6 @@ RUN apk add --no-cache --virtual .build-deps gcc libc-dev make \ && pip install uvicorn gunicorn \ && apk del .build-deps gcc libc-dev make -COPY ./entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh - COPY ./start.sh /start.sh RUN chmod +x /start.sh @@ -21,8 +18,6 @@ ENV PYTHONPATH=/app EXPOSE 80 -ENTRYPOINT ["/entrypoint.sh"] - # Run the start script, it will check for an /app/prestart.sh script (e.g. for migrations) -# And then will start Gunicorn with Meinheld +# And then will start Gunicorn with Uvicorn CMD ["/start.sh"] diff --git a/python3.7-alpine3.8/entrypoint.sh b/python3.7-alpine3.8/entrypoint.sh deleted file mode 100644 index bcf66db2..00000000 --- a/python3.7-alpine3.8/entrypoint.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env sh -set -e - -if [ -f /app/app/main.py ]; then - DEFAULT_MODULE_NAME=app.main -elif [ -f /app/main.py ]; then - DEFAULT_MODULE_NAME=main -fi -MODULE_NAME=${MODULE_NAME:-$DEFAULT_MODULE_NAME} -VARIABLE_NAME=${VARIABLE_NAME:-app} -export APP_MODULE=${APP_MODULE:-"$MODULE_NAME:$VARIABLE_NAME"} - -if [ -f /app/gunicorn_conf.py ]; then - DEFAULT_GUNICORN_CONF=/app/gunicorn_conf.py -elif [ -f /app/app/gunicorn_conf.py ]; then - DEFAULT_GUNICORN_CONF=/app/app/gunicorn_conf.py -else - DEFAULT_GUNICORN_CONF=/gunicorn_conf.py -fi -export GUNICORN_CONF=${GUNICORN_CONF:-$DEFAULT_GUNICORN_CONF} - -exec "$@" diff --git a/python3.7-alpine3.8/start.sh b/python3.7-alpine3.8/start.sh index 47f42723..65879b4d 100644 --- a/python3.7-alpine3.8/start.sh +++ b/python3.7-alpine3.8/start.sh @@ -1,6 +1,24 @@ #! /usr/bin/env sh set -e +if [ -f /app/app/main.py ]; then + DEFAULT_MODULE_NAME=app.main +elif [ -f /app/main.py ]; then + DEFAULT_MODULE_NAME=main +fi +MODULE_NAME=${MODULE_NAME:-$DEFAULT_MODULE_NAME} +VARIABLE_NAME=${VARIABLE_NAME:-app} +export APP_MODULE=${APP_MODULE:-"$MODULE_NAME:$VARIABLE_NAME"} + +if [ -f /app/gunicorn_conf.py ]; then + DEFAULT_GUNICORN_CONF=/app/gunicorn_conf.py +elif [ -f /app/app/gunicorn_conf.py ]; then + DEFAULT_GUNICORN_CONF=/app/app/gunicorn_conf.py +else + DEFAULT_GUNICORN_CONF=/gunicorn_conf.py +fi +export GUNICORN_CONF=${GUNICORN_CONF:-$DEFAULT_GUNICORN_CONF} + # 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" diff --git a/python3.7/Dockerfile b/python3.7/Dockerfile index 6f2cf760..5f26a0b1 100644 --- a/python3.7/Dockerfile +++ b/python3.7/Dockerfile @@ -4,9 +4,6 @@ LABEL maintainer="Sebastian Ramirez " RUN pip install uvicorn gunicorn -COPY ./entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh - COPY ./start.sh /start.sh RUN chmod +x /start.sh @@ -19,8 +16,6 @@ ENV PYTHONPATH=/app EXPOSE 80 -ENTRYPOINT ["/entrypoint.sh"] - # Run the start script, it will check for an /app/prestart.sh script (e.g. for migrations) -# And then will start Gunicorn with Meinheld +# And then will start Gunicorn with Uvicorn CMD ["/start.sh"] diff --git a/python3.7/entrypoint.sh b/python3.7/entrypoint.sh deleted file mode 100644 index bcf66db2..00000000 --- a/python3.7/entrypoint.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env sh -set -e - -if [ -f /app/app/main.py ]; then - DEFAULT_MODULE_NAME=app.main -elif [ -f /app/main.py ]; then - DEFAULT_MODULE_NAME=main -fi -MODULE_NAME=${MODULE_NAME:-$DEFAULT_MODULE_NAME} -VARIABLE_NAME=${VARIABLE_NAME:-app} -export APP_MODULE=${APP_MODULE:-"$MODULE_NAME:$VARIABLE_NAME"} - -if [ -f /app/gunicorn_conf.py ]; then - DEFAULT_GUNICORN_CONF=/app/gunicorn_conf.py -elif [ -f /app/app/gunicorn_conf.py ]; then - DEFAULT_GUNICORN_CONF=/app/app/gunicorn_conf.py -else - DEFAULT_GUNICORN_CONF=/gunicorn_conf.py -fi -export GUNICORN_CONF=${GUNICORN_CONF:-$DEFAULT_GUNICORN_CONF} - -exec "$@" diff --git a/python3.7/start.sh b/python3.7/start.sh index 47f42723..65879b4d 100644 --- a/python3.7/start.sh +++ b/python3.7/start.sh @@ -1,6 +1,24 @@ #! /usr/bin/env sh set -e +if [ -f /app/app/main.py ]; then + DEFAULT_MODULE_NAME=app.main +elif [ -f /app/main.py ]; then + DEFAULT_MODULE_NAME=main +fi +MODULE_NAME=${MODULE_NAME:-$DEFAULT_MODULE_NAME} +VARIABLE_NAME=${VARIABLE_NAME:-app} +export APP_MODULE=${APP_MODULE:-"$MODULE_NAME:$VARIABLE_NAME"} + +if [ -f /app/gunicorn_conf.py ]; then + DEFAULT_GUNICORN_CONF=/app/gunicorn_conf.py +elif [ -f /app/app/gunicorn_conf.py ]; then + DEFAULT_GUNICORN_CONF=/app/app/gunicorn_conf.py +else + DEFAULT_GUNICORN_CONF=/gunicorn_conf.py +fi +export GUNICORN_CONF=${GUNICORN_CONF:-$DEFAULT_GUNICORN_CONF} + # 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"