I am having issues running a test suite in a dockerize Django application using Travis CI. I ran the test suite locally without any issue i.e after using:
docker-compose up --build -d
docker-compose run django --no-deps python manage.py test polls
This is my github repo: https://github.com/bgreatfit/Docker_django Everything works(test suite) fine on my local machine that contains the Dockerized Django Application. While in Travis the build creation is successful but test suite doesn’t run. This is the last line of the output on Travis:
docker_django-mysql | Version: '5.6.43' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
This is my travis url:https://travis-ci.org/bgreatfit/Docker_django
This is my travis.yaml file
sudo: required
services:
- docker
before_install:
- docker-compose up -d
- docker ps
script:
- docker-compose run django python manage.py test polls
This is my docker-compose file
version: "3.1"
services:
django:
build: ./app
container_name: ${PROJECT_NAME}-django
command: gunicorn first_project.wsgi:application --bind 0.0.0.0:8000
volumes:
- ./app:/app
- static_volume:/app/static
expose:
- 8000
depends_on:
- mysql
mysql:
image: mysql:5.6
container_name: ${PROJECT_NAME}-mysql
volumes:
- db-data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=docker_root
- MYSQL_DATABASE=docker_django_db
- MYSQL_USER=dbuser
- MYSQL_PASSWORD=dbpw
ports:
- "8306:3306"
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: ${PROJECT_NAME}-phpmyadmin
environment:
- PMA_ARBITRARY=1
restart: always
ports:
- 8082:80
volumes:
- /session
nginx:
build: ./nginx
container_name: ${PROJECT_NAME}-nginx
volumes:
- static_volume:/app/static
ports:
- 1337:80
depends_on:
- django
volumes:
db-data:
static_volume:
My docker file :
FROM python:3.6
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# set work directory
WORKDIR /app
# Install python mysql client
RUN apt-get update \
&& apt-get -y install libmysqlclient-dev \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
# install dependencies
COPY requirements.txt /app/
RUN pip install -r requirements.txt
# copy project
# copy entrypoint.sh
COPY ./entrypoint.sh /usr/src/app/entrypoint.sh
# copy project
COPY. /app/
# run entrypoint.sh
RUN ["chmod","+x","/app/entrypoint.sh"]