Skip to content

Commit

Permalink
Newbie mistakes were made. Fix postgres service
Browse files Browse the repository at this point in the history
  • Loading branch information
dc740 committed Jan 10, 2020
1 parent da98d0e commit f8581a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
11 changes: 4 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,14 @@ RUN apt-get update \
RUN pip install --upgrade pip virtualenv

# setup postgresql database and user.
# We don't expose the port, but allow all incomming connections
USER postgres
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/11/main/pg_hba.conf
RUN echo "listen_addresses='*'" >> /etc/postgresql/11/main/postgresql.conf
RUN service postgresql restart
RUN psql -c "CREATE USER ctest WITH SUPERUSER PASSWORD 'coveragetest123';ALTER USER ctest CREATEDB;"
RUN createdb -O ctest demo
# configure the user for later. the service will be started in the entrypoint
RUN service postgresql start \
&& psql -c "CREATE USER ctest WITH SUPERUSER PASSWORD 'coveragetest123';ALTER USER ctest CREATEDB;"
USER root


EXPOSE 5432

COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
8 changes: 7 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ echo "Starting ${GITHUB_WORKFLOW}:${GITHUB_ACTION}"
APP=$1
MIN_COVERAGE=$2

# start PostgreSQL
service postgresql start

# setup run settings
if [ -z "${APP}" ]; then
# coverage on everything when app is empty
APP_LOCATION="."
Expand All @@ -17,6 +21,7 @@ else
VENV_NAME=virtenv_$APP
fi

# init virtual environment
if ! [ -e "${GITHUB_WORKSPACE}/${VENV_NAME}" ]; then
python3 -m venv "${GITHUB_WORKSPACE}/${VENV_NAME}"
fi
Expand All @@ -25,8 +30,9 @@ source "${GITHUB_WORKSPACE}/${VENV_NAME}/bin/activate"

pip install -r requirements.txt

echo "Base setup complete. Setting up a sample DB url and running..."
export DATABASE_URL='postgresql://ctest:[email protected]:5432/demo'
echo "Base setup complete. Setting up a sample DB url"

# This will automatically fail (set -e is set by default) if the tests fail, which is OK.
coverage run --source "${APP_LOCATION}" manage.py test "${APP}"

Expand Down

0 comments on commit f8581a7

Please sign in to comment.