Provide a better way to run extra scripts from children images
The current way requires an `extra_scripts.sh` file to be present in on children images. With this approach a new folder `/docker-entrypoint.d` is created when an image extends this one. The children image can then copy any shell or python file that they want executed at the start of container in that directory. For instance consider the following setup: ``` cloud-mysite ├── .env ├── docker-entrypoint.d │ └── 00_setup_validation.sh │ └── 01_check_users.py └── Dockerfile ``` The `Dockerfile` will look like: ``` FROM keitaro/ckan:2.8.1 [...] COPY docker-entrypoint.d/* /docker-entrypoint.d/ ``` The files will be executed in alphabetical order.
This commit is contained in:
parent
59e403a760
commit
c0e229197e
|
@ -103,6 +103,9 @@ RUN pip install -e /srv/app/src/ckan && \
|
||||||
# Remove wheels
|
# Remove wheels
|
||||||
RUN rm -rf /srv/app/wheels
|
RUN rm -rf /srv/app/wheels
|
||||||
|
|
||||||
|
# Create entrypoint directory for children image scripts
|
||||||
|
ONBUILD RUN mkdir /docker-entrypoint.d
|
||||||
|
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
||||||
HEALTHCHECK --interval=10s --timeout=5s --retries=5 CMD curl --fail http://localhost:5000/api/3/action/status_show || exit 1
|
HEALTHCHECK --interval=10s --timeout=5s --retries=5 CMD curl --fail http://localhost:5000/api/3/action/status_show || exit 1
|
||||||
|
|
|
@ -2,13 +2,25 @@
|
||||||
# Run the prerun script to init CKAN and create the default admin user
|
# Run the prerun script to init CKAN and create the default admin user
|
||||||
python prerun.py
|
python prerun.py
|
||||||
|
|
||||||
|
# Run any startup scripts provided by images extending this one
|
||||||
|
if [[ -d "/docker-entrypoint.d" ]]
|
||||||
|
then
|
||||||
|
for f in /docker-entrypoint.d/*; do
|
||||||
|
case "$f" in
|
||||||
|
*.sh) echo "$0: Running init file $f"; . "$f" ;;
|
||||||
|
*.py) echo "$0: Running init file $f"; python "$f"; echo ;;
|
||||||
|
*) echo "$0: Ignoring $f (not an sh or py file)" ;;
|
||||||
|
esac
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# Set the common uwsgi options
|
# Set the common uwsgi options
|
||||||
UWSGI_OPTS="--plugins http,python,gevent --socket /tmp/uwsgi.sock --uid 92 --gid 92 --http :5000 --master --enable-threads --paste config:/srv/app/production.ini --lazy-apps --gevent 2000 -p 2 -L"
|
UWSGI_OPTS="--plugins http,python,gevent --socket /tmp/uwsgi.sock --uid 92 --gid 92 --http :5000 --master --enable-threads --paste config:/srv/app/production.ini --lazy-apps --gevent 2000 -p 2 -L"
|
||||||
|
|
||||||
# Check whether http basic auth password protection is enabled and enable basicauth routing on uwsgi respecfully
|
# Check whether http basic auth password protection is enabled and enable basicauth routing on uwsgi respecfully
|
||||||
if [ $? -eq 0 ]
|
if [ $? -eq 0 ]
|
||||||
then
|
then
|
||||||
extra_scripts.sh
|
|
||||||
if [ "$PASSWORD_PROTECT" = true ]
|
if [ "$PASSWORD_PROTECT" = true ]
|
||||||
then
|
then
|
||||||
if [ "$HTPASSWD_USER" ] || [ "$HTPASSWD_PASSWORD" ]
|
if [ "$HTPASSWD_USER" ] || [ "$HTPASSWD_PASSWORD" ]
|
||||||
|
|
Loading…
Reference in New Issue