From 274e38c1630dc25d2726093cb69efb2aced6b321 Mon Sep 17 00:00:00 2001 From: "deivison.marteleto" Date: Tue, 26 Mar 2024 12:49:54 -0300 Subject: [PATCH 1/2] ajustar deploy local --- docker-compose.yml | 9 +++++---- scripts/docker/docker-start-netapi.sh | 4 ++-- scripts/docker/netapi.env | 8 ++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index c52a6d4b..684108dd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,10 +5,11 @@ 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: @@ -55,11 +56,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 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..4442b6f6 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 From cb724412213bc5e0ed4b02b019000c05c34fdf96 Mon Sep 17 00:00:00 2001 From: "deivison.marteleto" Date: Tue, 26 Mar 2024 13:49:19 -0300 Subject: [PATCH 2/2] ajustar deploy local --- Makefile | 11 ++++++++--- docker-compose.yml | 13 +++++++++---- scripts/docker/Dockerfile | 2 +- scripts/docker/netapi.env | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) 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 684108dd..c79824d0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,11 +9,17 @@ services: ports: - "33306:3306" environment: - MYSQL_ROOT_PASSWORD: 'put your password here' + 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 @@ -80,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/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/netapi.env b/scripts/docker/netapi.env index 4442b6f6..2f79e793 100644 --- a/scripts/docker/netapi.env +++ b/scripts/docker/netapi.env @@ -2,7 +2,7 @@ NETWORKAPI_DATABASE_NAME='networkapi' NETWORKAPI_DATABASE_USER='root' -NETWORKAPI_DATABASE_PASSWORD='put your password here' +NETWORKAPI_DATABASE_PASSWORD='put_your_password_here' NETWORKAPI_DATABASE_HOST='netapi_db'