Fix MySQL compatibility in the docker images. (#140)

* Fix MySQL compatibility in the docker images.

* Test the containers with MySQL containers too!
This commit is contained in:
Abhilash Raj
2017-09-30 20:38:33 -07:00
committed by GitHub
parent 035e694152
commit afb8f09eff
7 changed files with 137 additions and 19 deletions

View File

@@ -7,11 +7,14 @@ COPY mailman-web /opt/mailman-web
# Add startup script to container
COPY docker-entrypoint.sh /usr/local/bin/
# Install packages and dependencies for postorius and hyperkitty
# Add user for executing apps, change ownership for uwsgi+django files and set execution rights for management script
# Install packages and dependencies for postorius and hyperkitty Add user for
# executing apps, change ownership for uwsgi+django files and set execution
# rights for management script
RUN set -ex \
&& apk add --no-cache --virtual .build-deps gcc libc-dev linux-headers postgresql-dev \
&& apk add --no-cache --virtual .mailman-rundeps bash sassc postgresql-client \
&& apk add --no-cache --virtual .build-deps gcc libc-dev linux-headers \
postgresql-dev mariadb-dev \
&& apk add --no-cache --virtual .mailman-rundeps bash sassc \
postgresql-client mysql-client py-mysqldb \
&& pip install -U mailmanclient==3.1.0 \
postorius==1.1.0 \
hyperkitty==1.1.1 \
@@ -20,7 +23,7 @@ RUN set -ex \
uwsgi \
psycopg2 \
dj-database-url \
pymysql \
mysqlclient \
&& pip install -U django==1.10 \
&& apk del --no-cache .build-deps \
&& addgroup -S mailman \

View File

@@ -14,6 +14,17 @@ function wait_for_postgres () {
>&2 echo "Postgres is up - continuing"
}
function wait_for_mysql () {
# Check if MySQL is up and accepting connections.
HOSTNAME=$(python -c "from urlparse import urlparse; o = urlparse('$DATABASE_URL'); print(o.hostname);")
until mysqladmin ping --host "$HOSTNAME" --silent; do
>&2 echo "MySQL is unavailable - sleeping"
sleep 1
done
>&2 echo "MySQL is up - continuing"
}
function check_or_create () {
# Check if the path exists, if not, create the directory.
if [[ ! -e dir ]]; then
@@ -57,8 +68,12 @@ if [[ ! -v DATABASE_URL ]]; then
export DATABASE_TYPE='sqlite'
fi
if [[ "$DATABASE_TYPE" = 'postgres' ]]; then
if [[ "$DATABASE_TYPE" = 'postgres' ]]
then
wait_for_postgres
elif [[ "$DATABASE_TYPE" = 'mysql' ]]
then
wait_for_mysql
fi
# Check if we are in the correct directory before running commands.