Fix lots of bugs

This commit is contained in:
Santiago Lo Coco 2023-11-10 00:49:26 -03:00
parent 6a49957eec
commit 53fa74b61d
22 changed files with 130 additions and 116 deletions

View File

@ -312,8 +312,8 @@ test-screen-client:
- docker compose -f auth-domain/docker-compose.dev.yml --env-file $ENV_DEV_FILE down - docker compose -f auth-domain/docker-compose.dev.yml --env-file $ENV_DEV_FILE down
- docker compose -f auth-domain/docker-compose.dev.yml --env-file $ENV_DEV_FILE pull - docker compose -f auth-domain/docker-compose.dev.yml --env-file $ENV_DEV_FILE pull
- docker compose -f auth-domain/docker-compose.dev.yml --env-file $ENV_DEV_FILE up -d - docker compose -f auth-domain/docker-compose.dev.yml --env-file $ENV_DEV_FILE up -d
- docker compose -f auth-domain/docker-compose.dev.yml --env-file $ENV_DEV_FILE exec usermanager-api-dev python manage.py recreate_db - docker compose -f auth-domain/docker-compose.dev.yml --env-file $ENV_DEV_FILE exec usermanager-api python manage.py recreate_db
- docker compose -f auth-domain/docker-compose.dev.yml --env-file $ENV_DEV_FILE exec usermanager-api-dev python manage.py seed_db - docker compose -f auth-domain/docker-compose.dev.yml --env-file $ENV_DEV_FILE exec usermanager-api python manage.py seed_db
- export API_IMAGE=$SUBSCRIPTION_TEST_IMAGE_NAME - export API_IMAGE=$SUBSCRIPTION_TEST_IMAGE_NAME
- docker compose -f subscription-domain/docker-compose.dev.yml --env-file $ENV_DEV_FILE down - docker compose -f subscription-domain/docker-compose.dev.yml --env-file $ENV_DEV_FILE down
- docker compose -f subscription-domain/docker-compose.dev.yml --env-file $ENV_DEV_FILE pull - docker compose -f subscription-domain/docker-compose.dev.yml --env-file $ENV_DEV_FILE pull

View File

@ -1,29 +1,28 @@
version: '3.8' version: '3.8'
name: fids_usermanager_dev name: fids-auth-dev
services: services:
usermanager-api-dev: auth-api:
extends: extends:
file: docker-template.yml file: docker-template.yml
service: usermanager-api service: auth-api
container_name: fids_usermanager_api_dev container_name: fids-auth-dev_auth-api
environment: environment:
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@usermanager-db-dev/${POSTGRES_DB} - DATABASE_TEST_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@auth-db/${POSTGRES_DB_TEST}
- DATABASE_TEST_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@usermanager-db-dev/${POSTGRES_DB_TEST}
depends_on: depends_on:
usermanager-db-dev: auth-db:
condition: service_healthy condition: service_healthy
networks: networks:
- auth-dev - auth
usermanager-db-dev: auth-db:
extends: extends:
file: docker-template.yml file: docker-template.yml
service: usermanager-db service: auth-db
container_name: fids_usermanager_db_dev container_name: fids-auth-dev_auth-db
networks: networks:
- auth-dev - auth
networks: networks:
auth-dev: auth:
driver: bridge driver: bridge

View File

@ -1,23 +1,21 @@
version: '3.8' version: '3.8'
name: fids_usermanager name: fids-auth
services: services:
usermanager-api: auth-api:
extends: extends:
file: docker-template.yml file: docker-template.yml
service: usermanager-api service: auth-api
container_name: fids_usermanager_api
depends_on: depends_on:
usermanager-db: auth-db:
condition: service_healthy condition: service_healthy
networks: networks:
- auth - auth
usermanager-db: auth-db:
container_name: fids_usermanager_db
extends: extends:
file: docker-template.yml file: docker-template.yml
service: usermanager-db service: auth-db
volumes: volumes:
- flights_db:/var/lib/postgresql/data - flights_db:/var/lib/postgresql/data
networks: networks:

View File

@ -1,8 +1,9 @@
version: '3.8' version: '3.8'
services: services:
usermanager-api: auth-api:
image: ${API_IMAGE} image: ${API_IMAGE}
container_name: fids-auth_auth-api
healthcheck: healthcheck:
test: ["CMD", "nc", "-vz", "-w1", "localhost", "5000"] test: ["CMD", "nc", "-vz", "-w1", "localhost", "5000"]
interval: 2s interval: 2s
@ -12,13 +13,14 @@ services:
environment: environment:
- TEST_TARGET=${TEST_TARGET} - TEST_TARGET=${TEST_TARGET}
- PORT=5000 - PORT=5000
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@usermanager-db/${POSTGRES_DB} - DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@auth-db/${POSTGRES_DB}
- APP_SETTINGS=${APP_SETTINGS} - APP_SETTINGS=${APP_SETTINGS}
usermanager-db: auth-db:
build: build:
context: ./db context: ./db
dockerfile: Dockerfile dockerfile: Dockerfile
container_name: fids-auth_auth-db
healthcheck: healthcheck:
test: psql postgres --command "select 1" -U ${POSTGRES_USER} test: psql postgres --command "select 1" -U ${POSTGRES_USER}
interval: 2s interval: 2s

View File

@ -1,10 +1,10 @@
version: '3.8' version: '3.8'
name: fids_browser_dev name: fids-browser-dev
services: services:
browser-client-dev: browser-client:
extends: extends:
file: docker-template.yml file: docker-template.yml
service: browser-client service: browser-client
container_name: fids_browser_client_dev container_name: fids-browser-dev_browser-client
network_mode: host network_mode: host

View File

@ -1,5 +1,5 @@
version: '3.8' version: '3.8'
name: fids_browser name: fids-browser
services: services:
browser-client: browser-client:

View File

@ -2,7 +2,7 @@ version: '3.8'
services: services:
browser-client: browser-client:
container_name: fids_browser_client container_name: fids-browser_browser-client
image: ${CLIENT_IMAGE} image: ${CLIENT_IMAGE}
environment: environment:
- TEST_TARGET=${TEST_TARGET} - TEST_TARGET=${TEST_TARGET}

View File

@ -1,32 +1,32 @@
version: '3.8' version: '3.8'
name: fids_flights_dev name: fids-flights-dev
services: services:
flights-api-dev: flights-api:
extends: extends:
file: docker-template.yml file: docker-template.yml
service: flights-api service: flights-api
container_name: fids_flights_api_dev container_name: fids-flights-dev_flights-api
environment: environment:
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@flights-api-db-dev/${POSTGRES_DB} - DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@flights-db/${POSTGRES_DB}
depends_on: depends_on:
flights-api-db-dev: flights-db:
condition: service_healthy condition: service_healthy
networks: networks:
- flights-dev - flights
- subscriptions-dev - subscriptions
flights-api-db-dev: flights-db:
extends: extends:
file: docker-template.yml file: docker-template.yml
service: flights-api-db service: flights-db
container_name: fids_flights_db_dev container_name: fids-flights-dev_flights-db
networks: networks:
- flights-dev - flights
networks: networks:
subscriptions-dev: subscriptions:
name: subscription-domain_subscriptions-dev name: fids-subs-dev_subscriptions
external: true external: true
flights-dev: flights:
driver: bridge driver: bridge

View File

@ -1,5 +1,5 @@
version: '3.8' version: '3.8'
name: fids_flights name: fids-flights
services: services:
flights-api: flights-api:
@ -24,7 +24,7 @@ services:
networks: networks:
subscriptions: subscriptions:
name: subscription-domain_subscriptions name: fids-subs_subscriptions
external: true external: true
flights: flights:
driver: bridge driver: bridge

View File

@ -2,7 +2,7 @@ version: '3.8'
services: services:
flights-api: flights-api:
container_name: fids_flights_api container_name: fids-flights_flights-api
image: ${API_IMAGE} image: ${API_IMAGE}
healthcheck: healthcheck:
test: ["CMD", "nc", "-vz", "-w1", "localhost", "5000"] test: ["CMD", "nc", "-vz", "-w1", "localhost", "5000"]
@ -13,11 +13,11 @@ services:
environment: environment:
- TEST_TARGET=${TEST_TARGET} - TEST_TARGET=${TEST_TARGET}
- PORT=5000 - PORT=5000
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@flights-api-db/${POSTGRES_DB} - DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@flights-db/${POSTGRES_DB}
- APP_SETTINGS=${APP_SETTINGS} - APP_SETTINGS=${APP_SETTINGS}
flights-api-db: flights-db:
container_name: fids_flights_db container_name: fids-flights_flights-db
build: build:
context: ./db context: ./db
dockerfile: Dockerfile dockerfile: Dockerfile

View File

@ -1 +1,8 @@
API_MESSAGES = "http://fids_subscriptions_api:5000/messages" import os
TEST_TARGET = os.getenv("TEST_TARGET")
if TEST_TARGET == "INTEGRATION":
API_MESSAGES = "http://fids-subs-dev_subscriptions-api:5000/messages"
else:
API_MESSAGES = "http://fids-subs_subscriptions-api:5000/messages"

View File

@ -1,29 +1,29 @@
version: '3.8' version: '3.8'
name: fids_gateway_dev name: fids-gateway-dev
services: services:
api-gateway-dev: api-gw:
extends: extends:
file: docker-template.yml file: docker-template.yml
service: api-gateway service: api-gw
container_name: fids_api_gateway_dev container_name: fids-gateway-dev_api-gw
ports: ports:
- 5001:5002 - 5001:5002
networks: networks:
- auth-dev - auth
- flights-dev - flights
- gateway-dev - gateway
- subscriptions-dev - subscriptions
networks: networks:
auth-dev: auth:
name: auth-domain_auth-dev name: fids-auth-dev_auth
external: true external: true
flights-dev: flights:
name: flights-domain_flights-dev name: fids-flights-dev_flights
external: true external: true
subscriptions-dev: subscriptions:
name: subscription-domain_subscriptions-dev name: fids-subs-dev_subscriptions
external: true external: true
gateway-dev: gateway:
driver: bridge driver: bridge

View File

@ -1,11 +1,11 @@
version: '3.8' version: '3.8'
name: fids_gateway name: fids-gateway-dev
services: services:
api-gateway: api-gw:
extends: extends:
file: docker-template.yml file: docker-template.yml
service: api-gateway service: api-gw
ports: ports:
- 5000:5002 - 5000:5002
networks: networks:
@ -21,13 +21,13 @@ services:
networks: networks:
auth: auth:
name: auth-domain_auth name: fids-auth_auth
external: true external: true
flights: flights:
name: flights-domain_flights name: fids-flights_flights
external: true external: true
subscriptions: subscriptions:
name: subscription-domain_subscriptions name: fids-subs_subscriptions
external: true external: true
gateway: gateway:
driver: bridge driver: bridge

View File

@ -1,8 +1,8 @@
version: '3.8' version: '3.8'
services: services:
api-gateway: api-gw:
container_name: fids_api_gateway container_name: fids-gateway_api-gw
image: ${API_IMAGE} image: ${API_IMAGE}
healthcheck: healthcheck:
test: ["CMD", "nc", "-vz", "-w1", "localhost", "5002"] test: ["CMD", "nc", "-vz", "-w1", "localhost", "5002"]

View File

@ -3,18 +3,18 @@ import os
TEST_TARGET = os.getenv("TEST_TARGET") TEST_TARGET = os.getenv("TEST_TARGET")
if TEST_TARGET == "INTEGRATION": if TEST_TARGET == "INTEGRATION":
API_USERS = "http://fids_usermanager_api_dev:5000/users" API_USERS = "http://fids-auth-dev_auth-api:5000/users"
API_FLIGHTS = "http://fids_flights_api_dev:5000/flights" API_FLIGHTS = "http://fids-flights-dev_flights-api:5000/flights"
API_AUTH = "http://fids_usermanager_api_dev:5000/auth" API_AUTH = "http://fids-auth-dev_auth-api:5000/auth"
LOGS_UPD = "udp://fids_logstash:12201" LOGS_UPD = "udp://fids_logstash:12201"
API_SUBSCRIPTIONS = "http://fids_subscriptions_api_dev:5000/subscriptions" API_SUBSCRIPTIONS = "http://fids-subs-dev_subscriptions-api:5000/subscriptions"
API_NOTIFICATIONS = "http://fids_subscriptions_api_dev:5000/notifications" API_NOTIFICATIONS = "http://fids-subs-dev_subscriptions-api:5000/notifications"
API_MESSAGES = "http://fids_subscriptions_api_dev:5000/messages" API_MESSAGES = "http://fids-subs-dev_subscriptions-api:5000/messages"
else: else:
API_USERS = "http://fids_usermanager_api:5000/users" API_USERS = "http://fids-auth_auth-api:5000/users"
API_FLIGHTS = "http://fids_flights_api:5000/flights" API_FLIGHTS = "http://fids-flights_flights-api:5000/flights"
API_AUTH = "http://fids_usermanager_api:5000/auth" API_AUTH = "http://fids-auth_auth-api:5000/auth"
LOGS_UPD = "udp://fids_logstash:12201" LOGS_UPD = "udp://fids_logstash:12201"
API_SUBSCRIPTIONS = "http://fids_subscriptions_api:5000/subscriptions" API_SUBSCRIPTIONS = "http://fids-subs_subscriptions-api:5000/subscriptions"
API_NOTIFICATIONS = "http://fids_subscriptions_api:5000/notifications" API_NOTIFICATIONS = "http://fids-subs_subscriptions-api:5000/notifications"
API_MESSAGES = "http://fids_subscriptions_api:5000/messages" API_MESSAGES = "http://fids-subs_subscriptions-api:5000/messages"

22
run.sh
View File

@ -1,19 +1,21 @@
#!/usr/bin/env bash #!/usr/bin/env bash
usage() { usage() {
printf "$0 usage: \n -x: down\n -d \$DOMAIN: domain\n -t: tests\n" $0 printf "$0 usage: \n -x: down\n -d \$DOMAIN: domain\n -t: tests\n -i integration\n" $0
exit 0 exit 0
} }
domain= domain=
down= down=
tests= tests=
integration=
while getopts ":hd:xt" arg; do while getopts ":hd:xti" arg; do
case $arg in case $arg in
x) down=Y ;; x) down=Y ;;
d) domain=${OPTARG} ;; d) domain=${OPTARG} ;;
t) tests=Y ;; t) tests=Y ;;
i) integration=Y ;;
h | *) usage ;; h | *) usage ;;
esac esac
done done
@ -65,13 +67,19 @@ elif [ -n "$domain" ] && [ -z "$down" ]; then
docker build $USER_MANAGER -f $USER_MANAGER/Dockerfile.test -t $USER/user-manager:test docker build $USER_MANAGER -f $USER_MANAGER/Dockerfile.test -t $USER/user-manager:test
export API_IMAGE=$USER/user-manager:test export API_IMAGE=$USER/user-manager:test
docker compose -f auth-domain/docker-compose.dev.yml --env-file auth-domain/.env.dev down docker compose -f auth-domain/docker-compose.dev.yml --env-file auth-domain/.env.dev down
docker compose -f auth-domain/docker-compose.dev.yml --env-file auth-domain/.env.dev up --abort-on-container-exit if [ -n "$integration" ]; then
docker compose -f auth-domain/docker-compose.dev.yml --env-file auth-domain/.env.dev up -d
docker compose -f auth-domain/docker-compose.dev.yml --env-file auth-domain/.env.dev exec auth-api python manage.py recreate_db
docker compose -f auth-domain/docker-compose.dev.yml --env-file auth-domain/.env.dev exec auth-api python manage.py seed_db
else
docker compose -f auth-domain/docker-compose.dev.yml --env-file auth-domain/.env.dev up --abort-on-container-exit
fi
else else
export API_IMAGE=$USER/user-manager:prod export API_IMAGE=$USER/user-manager:prod
docker compose -f auth-domain/docker-compose.yml --env-file auth-domain/.env.prod down docker compose -f auth-domain/docker-compose.yml --env-file auth-domain/.env.prod down
docker compose -f auth-domain/docker-compose.yml --env-file auth-domain/.env.prod up -d docker compose -f auth-domain/docker-compose.yml --env-file auth-domain/.env.prod up -d
docker compose -f auth-domain/docker-compose.yml --env-file auth-domain/.env.prod exec usermanager-api python manage.py recreate_db docker compose -f auth-domain/docker-compose.yml --env-file auth-domain/.env.prod exec auth-api python manage.py recreate_db
docker compose -f auth-domain/docker-compose.yml --env-file auth-domain/.env.prod exec usermanager-api python manage.py seed_db docker compose -f auth-domain/docker-compose.yml --env-file auth-domain/.env.prod exec auth-api python manage.py seed_db
fi fi
;; ;;
'flights') 'flights')
@ -193,8 +201,8 @@ else
export API_IMAGE=$USER/user-manager:prod export API_IMAGE=$USER/user-manager:prod
docker compose -f auth-domain/docker-compose.yml --env-file auth-domain/.env.prod down docker compose -f auth-domain/docker-compose.yml --env-file auth-domain/.env.prod down
docker compose -f auth-domain/docker-compose.yml --env-file auth-domain/.env.prod up -d docker compose -f auth-domain/docker-compose.yml --env-file auth-domain/.env.prod up -d
docker compose -f auth-domain/docker-compose.yml --env-file auth-domain/.env.prod exec usermanager-api python manage.py recreate_db docker compose -f auth-domain/docker-compose.yml --env-file auth-domain/.env.prod exec auth-api python manage.py recreate_db
docker compose -f auth-domain/docker-compose.yml --env-file auth-domain/.env.prod exec usermanager-api python manage.py seed_db docker compose -f auth-domain/docker-compose.yml --env-file auth-domain/.env.prod exec auth-api python manage.py seed_db
export API_IMAGE=slococo/subs-manager:prod export API_IMAGE=slococo/subs-manager:prod
docker compose -f subscription-domain/docker-compose.yml --env-file subscription-domain/.env.prod down docker compose -f subscription-domain/docker-compose.yml --env-file subscription-domain/.env.prod down
docker compose -f subscription-domain/docker-compose.yml --env-file subscription-domain/.env.prod up -d docker compose -f subscription-domain/docker-compose.yml --env-file subscription-domain/.env.prod up -d

View File

@ -1,10 +1,10 @@
version: '3.8' version: '3.8'
name: fids_screen_dev name: fids-screen-dev
services: services:
screens-client-dev: screen-client:
extends: extends:
file: docker-template.yml file: docker-template.yml
service: screens-client service: screen-client
container_name: fids_screens_client_dev container_name: fids-screen-dev_screen-client
network_mode: host network_mode: host

View File

@ -1,9 +1,9 @@
version: '3.8' version: '3.8'
name: fids_screen name: fids-screen
services: services:
screens-client: screen-client:
extends: extends:
file: docker-template.yml file: docker-template.yml
service: screens-client service: screen-client
network_mode: host network_mode: host

View File

@ -1,8 +1,8 @@
version: '3.8' version: '3.8'
services: services:
screens-client: screen-client:
container_name: fids_screens_client container_name: fids-screen_screen-client
image: ${CLIENT_IMAGE} image: ${CLIENT_IMAGE}
environment: environment:
- TEST_TARGET=${TEST_TARGET} - TEST_TARGET=${TEST_TARGET}

View File

@ -1,28 +1,28 @@
version: '3.8' version: '3.8'
name: fids_subscriptions_dev name: fids-subs-dev
services: services:
subscriptions-api-dev: subscriptions-api:
extends: extends:
file: docker-template.yml file: docker-template.yml
service: subscriptions-api service: subscriptions-api
container_name: fids_subscriptions_api_dev container_name: fids-subs-dev_subscriptions-api
environment: environment:
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@subscriptions-db-dev/${POSTGRES_DB} - DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@subscriptions-db/${POSTGRES_DB}
depends_on: depends_on:
subscriptions-db-dev: subscriptions-db:
condition: service_healthy condition: service_healthy
networks: networks:
- subscriptions-dev - subscriptions
subscriptions-db-dev: subscriptions-db:
extends: extends:
file: docker-template.yml file: docker-template.yml
service: subscriptions-db service: subscriptions-db
container_name: fids_subscriptions_db_dev container_name: fids-subs-dev_subscriptions-db
networks: networks:
- subscriptions-dev - subscriptions
networks: networks:
subscriptions-dev: subscriptions:
driver: bridge driver: bridge

View File

@ -1,5 +1,5 @@
version: '3.8' version: '3.8'
name: fids_subscriptions name: fids-subs
services: services:
subscriptions-api: subscriptions-api:

View File

@ -2,7 +2,7 @@ version: '3.8'
services: services:
subscriptions-api: subscriptions-api:
container_name: fids_subscriptions_api container_name: fids-subs_subscriptions-api
image: ${API_IMAGE} image: ${API_IMAGE}
healthcheck: healthcheck:
test: ["CMD", "nc", "-vz", "-w1", "localhost", "5000"] test: ["CMD", "nc", "-vz", "-w1", "localhost", "5000"]
@ -18,7 +18,7 @@ services:
- TOKEN=${TOKEN} - TOKEN=${TOKEN}
subscriptions-db: subscriptions-db:
container_name: fids_subscriptions_db container_name: fids-subs_subscriptions-db
build: build:
context: ./db context: ./db
dockerfile: Dockerfile dockerfile: Dockerfile