-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
52 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,11 @@ FROM nginx:1.23 | |
# MAINTAINER is deprecated. Use LABEL instead | ||
LABEL maintainer="[email protected]" | ||
|
||
# synchronize timezone for container | ||
# https://forums.docker.com/t/synchronize-timezone-from-host-to-container/39116 | ||
RUN echo "Europe/Rome" > /etc/timezone | ||
RUN dpkg-reconfigure -f noninteractive tzdata | ||
|
||
# Copy nginx configuration file in conf.d directory | ||
COPY nginx.conf /etc/nginx/nginx.conf | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,12 +62,20 @@ RUN poetry install | |
|
||
from python:${PYTHON_VERSION}-slim | ||
|
||
# MAINTAINER is deprecated. Use LABEL instead | ||
LABEL maintainer="[email protected]" | ||
|
||
# Import ARGs which I need in this build stage | ||
# IMPORTANT!: without this redefinition, you can't use variables defined | ||
# before the first FROM statement | ||
ARG APP_PATH | ||
ARG VIRTUAL_ENV=${APP_PATH}/.venv | ||
|
||
# synchronize timezone for container | ||
# https://forums.docker.com/t/synchronize-timezone-from-host-to-container/39116 | ||
RUN echo "Europe/Rome" > /etc/timezone | ||
RUN dpkg-reconfigure -f noninteractive tzdata | ||
|
||
# install required packages | ||
RUN apt-get update && apt-get install -y \ | ||
libmariadb3 \ | ||
|
@@ -83,6 +91,11 @@ ENV \ | |
VIRTUAL_ENV=${VIRTUAL_ENV} \ | ||
PATH="${VIRTUAL_ENV}/bin:${PATH}" | ||
|
||
# utility script to ensure that mysql server is up | ||
# mind to the context path | ||
COPY uwsgi/wait-for-mysql.sh /usr/local/bin | ||
RUN chmod 755 /usr/local/bin/wait-for-mysql.sh | ||
|
||
# copy the application from build stage | ||
COPY --from=0 ${APP_PATH} ${APP_PATH} | ||
WORKDIR ${APP_PATH} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
# wait-for-mysql.sh | ||
# https://docs.docker.com/compose/startup-order/ | ||
# adapted from https://raw.githubusercontent.com/agileek/docker/master/tomcat/wait-for-mysql.sh | ||
|
||
set -e | ||
set -x | ||
|
||
cmd="$@" | ||
|
||
NEXT_WAIT_TIME=0 | ||
MAX_STEPS=6 | ||
|
||
until mysql -h db -u ${SHINY_USER} -p${SHINY_PASSWORD} ${SHINY_DATABASE} -e 'select 1' || [ ${NEXT_WAIT_TIME} -eq ${MAX_STEPS} ]; do | ||
>&2 echo "MySQL is unavailable - sleeping" | ||
sleep 5 | ||
NEXT_WAIT_TIME=$((NEXT_WAIT_TIME+1)) | ||
done | ||
|
||
if [ ${NEXT_WAIT_TIME} -eq ${MAX_STEPS} ]; then | ||
>&2 echo "Problem in waiting MySQL" | ||
exit 1; | ||
fi | ||
|
||
>&2 echo "MySQL is up - executing command" | ||
exec $cmd |