diff --git a/Makefile b/Makefile index 6ae448e2..aa3b9518 100644 --- a/Makefile +++ b/Makefile @@ -120,11 +120,16 @@ publish: clean # Containers based target rules # -start: docker-compose-sdn.yml docker-compose.yml +start_recreate: docker-compose-sdn.yml docker-compose.yml docker-compose up --force-recreate --remove-orphans -d docker-compose --file $< up --force-recreate -d +start: docker-compose-sdn.yml docker-compose.yml + docker-compose up -d + docker-compose --file $< up -d + + stop: docker-compose-sdn.yml docker-compose.yml @docker-compose down --remove-orphans @@ -172,8 +177,8 @@ endif build_img: scripts/docker/Dockerfile - docker build -t networkapi:latest --file scripts/docker/Dockerfile . - docker build -t networkapi:$(NETAPI_IMAGE_VERSION) --file scripts/docker/Dockerfile . + docker build --platform=linux/x86_64 -t networkapi:latest --file scripts/docker/Dockerfile . + docker build --platform=linux/x86_64 -t networkapi:$(NETAPI_IMAGE_VERSION) --file scripts/docker/Dockerfile . push_img: scripts/docker/push_image.sh diff --git a/docker-compose.yml b/docker-compose.yml index c52a6d4b..c79824d0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,14 +5,21 @@ services: container_name: netapi_db image: mysql:5.7 platform: linux/x86_64 + command: --default-authentication-plugin=mysql_native_password ports: - - "3306:3306" + - "33306:3306" environment: - MYSQL_ALLOW_EMPTY_PASSWORD: 1 + MYSQL_ROOT_PASSWORD: 'put_your_password_here' volumes: - netapi_db_vol:/var/lib/mysql networks: - netapi_net + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1",-p$$MYSQL_ROOT_PASSWORD ,"--silent"] + interval: 5s + timeout: 3s + retries: 2 + start_period: 15s queue: container_name: netapi_queue @@ -55,11 +62,11 @@ services: - queue:netapi_queue - cache:netapi_cache depends_on: - - queue + - queue netapi: container_name: netapi_app - image: globocom:latest + image: networkapi:latest build: context: . dockerfile: ./scripts/docker/Dockerfile @@ -79,9 +86,8 @@ services: networks: - netapi_net depends_on: - - db - - queue - - cache + db: + condition: service_healthy links: - db:netapi_db external_links: diff --git a/fast_start_test.sh b/fast_start_test.sh index e29151f8..55a22289 100755 --- a/fast_start_test.sh +++ b/fast_start_test.sh @@ -1,5 +1,5 @@ #!/bin/sh -source venv/bin/activate +source /venv/bin/activate pip install --no-cache --upgrade pip pip install -r requirements_test.txt @@ -100,7 +100,7 @@ echo "=============== Tests for Network v6 =================" python manage.py test networkapi/api_network.tests.v3.unit.networkipv6.async.test_delete.py python manage.py test networkapi/api_network.tests.v3.unit.networkipv6.async.test_post.py python manage.py test networkapi/api_network.tests.v3.unit.networkipv6.async.test_put.py -python manage.py test networkapi/api_network.tests.v3.sanity.allocate.test_network_v4.py +python manage.py test networkapi/api_network.tests.v3.sanity.allocate.test_network_v6.py python manage.py test networkapi/api_network.tests.v3.sanity.networkipv6.sync.test_delete.py python manage.py test networkapi/api_network.tests.v3.sanity.networkipv6.sync.test_get.py python manage.py test networkapi/api_network.tests.v3.sanity.networkipv6.sync.test_post.py diff --git a/scripts/docker/Dockerfile b/scripts/docker/Dockerfile index 5a98a61e..4bbf628e 100644 --- a/scripts/docker/Dockerfile +++ b/scripts/docker/Dockerfile @@ -1,7 +1,7 @@ # # Base stage # -FROM alpine:3.7 as base +FROM alpine:3.7 as base RUN apk update diff --git a/scripts/docker/docker-start-netapi.sh b/scripts/docker/docker-start-netapi.sh index 3cc12301..ed37b82c 100755 --- a/scripts/docker/docker-start-netapi.sh +++ b/scripts/docker/docker-start-netapi.sh @@ -53,7 +53,7 @@ fi echo "Creating networkapi database" -mysql -u root -h ${NETWORKAPI_DATABASE_HOST} -e 'CREATE DATABASE IF NOT EXISTS networkapi;' +mysql -u root -h ${NETWORKAPI_DATABASE_HOST} -p${NETWORKAPI_DATABASE_PASSWORD} -e 'CREATE DATABASE IF NOT EXISTS networkapi;' # Running database migrations if exists @@ -61,7 +61,7 @@ cd /netapi/dbmigrate; db-migrate --show-sql echo "Loading base Network API data into database" -mysql -u root -h ${NETWORKAPI_DATABASE_HOST} networkapi < /netapi/dev/load_example_environment.sql +mysql -u root -h ${NETWORKAPI_DATABASE_HOST} -p${NETWORKAPI_DATABASE_PASSWORD} networkapi < /netapi/dev/load_example_environment.sql # Discovering SDN controller diff --git a/scripts/docker/netapi.env b/scripts/docker/netapi.env index 9b984950..2f79e793 100644 --- a/scripts/docker/netapi.env +++ b/scripts/docker/netapi.env @@ -1,10 +1,10 @@ -NETWORKAPI_DATABASE_NAME=networkapi +NETWORKAPI_DATABASE_NAME='networkapi' -NETWORKAPI_DATABASE_USER=root +NETWORKAPI_DATABASE_USER='root' -NETWORKAPI_DATABASE_PASSWORD= +NETWORKAPI_DATABASE_PASSWORD='put_your_password_here' -NETWORKAPI_DATABASE_HOST=netapi_db +NETWORKAPI_DATABASE_HOST='netapi_db' NETWORKAPI_DATABASE_PORT=3306