Skip to content
Snippets Groups Projects
Commit 9c8bd268 authored by migudel's avatar migudel :speech_balloon:
Browse files

Planteamiento de configuración de docker compose

parent 541bae82
No related branches found
No related tags found
1 merge request!36Develop
AUTH_SERVICE_HOSTNAME=auth-api
USERS_SERVICE_HOSTNAME=users-api
HOTELS_SERVICE_HOSTNAME=hotels-api
BOOKINGS_SERVICE_HOSTNAME=bookings-api
ROOMS_BOOKING_SERVICE_HOSTNAME=rooms-booking-api
DB_SERVICE_HOSTNAME=RoomsBooking-database
DB_DATABASE_NAME=RoomsBooking
DB_USER=user
BD_PASSWORD=password
\ No newline at end of file
#######################################
# Environment
#######################################
## Meter aquí cosas sobre las keys del token y esas mierdas
#######################################
# APIs
#######################################
## AUTH
API_AUTH_ENDPOINT=/users
API_AUTH_HOSTNAME=auth-api
API_AUTH_PORT=8201
API_AUTH_URL=http://$API_AUTH_HOSTNAME:$API_AUTH_PORT$API_AUTH_ENDPOINT
## Bookings
API_BOOKINGS_ENDPOINT=/bookings
API_BOOKINGS_HOSTNAME=bookings-api
API_BOOKINGS_PORT=4201
API_BOOKINGS_URL=http://$API_BOOKINGS_HOSTNAME:$API_BOOKINGS_PORT$API_BOOKINGS_ENDPOINT
## Hotels
API_HOTELS_ENDPOINT=/hotels
API_HOTELS_HOSTNAME=hotels-api
API_HOTELS_PORT=8301
API_HOTELS_URL=http://$API_HOTELS_HOSTNAME:$API_HOTELS_PORT$API_HOTELS_ENDPOINT
## Users
API_USERS_ENDPOINT=/users
API_USERS_HOSTNAME=users-api
API_USERS_PORT=8201
API_USERS_URL=http://$API_USERS_HOSTNAME:$API_USERS_PORT$API_USERS_ENDPOINT
#
#######################################
# Databases
#######################################
## DB Bookings
DB_BOOKINGS_DATABASE=Bookings
DB_BOOKINGS_HOSTNAME=BookingsDB
## DB Hotels
DB_HOTELS_DATABASE=Hotels
DB_HOTELS_HOSTNAME=HotelsDB
## DB Users
DB_USERS_DATABASE=Users
DB_USERS_HOSTNAME=UsersDB
// const monolithUrl = 'http://rooms-booking-api:8080';
// export const environment = {
// production: true,
// authAPI: 'http://auth-api:8101',
// userAPI: `http://${monolithUrl}/users`,
// hotelAPI: `http://${monolithUrl}/hotels`,
// bookingAPI: `http://${monolithUrl}/bookings`,
// };
const monolithUrl = 'localhost:8080';
const gateWayUrl = 'localhost:8000'; // kong
export const environment = {
production: false,
authAPI: 'http://localhost:8101',
userAPI: `http://${monolithUrl}/users`,
hotelAPI: `http://${monolithUrl}/hotels`,
bookingAPI: `http://${monolithUrl}/bookings`,
production: true,
authAPI: `http://${gateWayUrl}/auth`,
userAPI: `http://${gateWayUrl}/users`,
hotelAPI: `http://${gateWayUrl}/hotels`,
bookingAPI: `http://${gateWayUrl}/bookings`,
};
const monolithUrl = 'localhost:8080';
const developmentHost = 'localhost';
export const environment = {
production: false,
authAPI: 'http://localhost:8101',
userAPI: `http://${monolithUrl}/users`,
hotelAPI: `http://${monolithUrl}/hotels`,
bookingAPI: `http://${monolithUrl}/bookings`,
authAPI: `http://${developmentHost}:8101`,
userAPI: `http://${developmentHost}:8201`,
hotelAPI: `http://${developmentHost}:8301`,
bookingAPI: `http://${developmentHost}:8401`,
};
volumes:
kong_data: {}
users_data: {}
hotels_data: {}
bookings_data: {}
networks:
kong-net: {}
networks: #Red interna para comunicar los servicios
kong-net:
services:
#######################################
# Kong
#######################################
# Postgres: The database used by Kong
kong-database:
image: postgres:9.6
container_DATABASE: kong-postgres
restart: on-failure
networks:
- kong-net
volumes:
- kong_data:/var/lib/postgresql/data
environment:
POSTGRES_USER: kong
POSTGRES_PASSWORD: ${KONG_PG_PASSWORD:-kong}
POSTGRES_DB: kong
ports:
- 5432:5432
healthcheck:
test: [CMD, pg_isready, -U, kong]
interval: 30s
timeout: 30s
retries: 3
# Kong database migration
kong-migration:
image: ${KONG_DOCKER_TAG:-kong:latest}
command: kong migrations bootstrap
networks:
- kong-net
restart: on-failure
environment:
KONG_DATABASE: postgres
KONG_PG_HOST: kong-database
KONG_PG_DATABASE: kong
KONG_PG_USER: kong
KONG_PG_PASSWORD: ${KONG_PG_PASSWORD:-kong}
depends_on:
kong-database:
condition: service_healthy
# Kong: The API Gateway
kong:
image: ${KONG_DOCKER_TAG:-kong:latest}
restart: on-failure
networks:
- kong-net
environment:
KONG_DATABASE: postgres
KONG_PG_HOST: kong-database
KONG_PG_DATABASE: kong
KONG_PG_USER: kong
KONG_PG_PASSWORD: ${KONG_PG_PASSWORD:-kong}
KONG_PROXY_LISTEN: 0.0.0.0:8000
KONG_PROXY_LISTEN_SSL: 0.0.0.0:8443
KONG_ADMIN_LISTEN: 0.0.0.0:8001
depends_on:
kong-database:
condition: service_healthy
healthcheck:
test: [CMD, kong, health]
interval: 10s
timeout: 10s
retries: 10
ports:
- 8000:8000
- 8001:8001
- 8443:8443
- 8444:8444
#######################################
# Konga
#######################################
# Konga database prepare
konga-prepare:
image: pantsel/konga:latest
command: "-c prepare -a postgres -u postgresql://kong:${KONG_PG_PASSWORD:-kong}@kong-database:5432/konga"
networks:
- kong-net
restart: on-failure
depends_on:
kong-database:
condition: service_healthy
# Konga: Kong GUI
konga:
image: pantsel/konga:latest
restart: always
networks:
- kong-net
environment:
DB_ADAPTER: postgres
DB_URI: postgresql://kong:${KONG_PG_PASSWORD:-kong}@kong-database:5432/konga
NODE_ENV: production
depends_on:
kong-database:
condition: service_healthy
ports:
- 1337:133
#######################################
# APIs
#######################################
Auth-API:
image: auth-api-image
hostname: ${AUTH_SERVICE_HOSTNAME}
hostname: ${API_AUTH_HOSTNAME}
build:
context: ./java/services/auth
dockerfile: Dockerfile
restart: unless-stopped
ports:
- 8101:8101
networks:
- kong-net
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://${DB_SERVICE_HOSTNAME}:3306/${DB_DATABASE_NAME}?createDatabaseIfNotExist=true
# TODO Meter kid y secret key
KID: ${JWT_KID}
SECRET_KEY: ${JWT_KID}
EXTERNAL_SERVICE_USERS_URL: ${API_USERS_URL}${API_USERS_ENDPOINT}
depends_on:
- RoomsBooking-database
- Users-API
RoomsBooking-API:
image: rooms-booking-api-image
hostname: ${ROOMS_BOOKING_SERVICE_HOSTNAME}
Users-API:
image: users-api-image
hostname: ${API_USERS_HOSTNAME}
build:
context: ./java/roomBooking
context: ./java/services/user
dockerfile: Dockerfile
restart: unless-stopped
ports:
- 8080:8080
networks:
- kong-net
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://${DB_SERVICE_HOSTNAME}:3306/${DB_DATABASE_NAME}?createDatabaseIfNotExist=true
SPRING_DATASOURCE_URL: jdbc:mysql://${DB_USERS_HOSTNAME}:${DB_USERS_PORT:-3306}/${DB_USERS_DATABASE}?createDatabaseIfNotExist=true
EXTERNAL_SERVICE_USERS_URL: ${API_USERS_URL}${API_USERS_ENDPOINT}
depends_on:
- RoomsBooking-database
- Users-DB
Hotels-API:
image: hotels-api-image
hostname: ${API_HOTELS_HOSTNAME}
build:
context: ./java/services/hotels
dockerfile: Dockerfile
restart: unless-stopped
networks:
- kong-net
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://${DB_HOTELS_HOSTNAME}:${DB_HOTELS_PORT:-3306}/${DB_HOTELS_DATABASE}?createDatabaseIfNotExist=true
depends_on:
- Hotels-DB
RoomsBooking-database:
Bookings-API:
image: bookings-api-image
hostname: ${API_BOOKINGS_HOSTNAME}
build:
context: ./java/services/bookings
dockerfile: Dockerfile
restart: unless-stopped
networks:
- kong-net
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://${DB_BOOKINGS_HOSTNAME}:${DB_BOOKINGS_PORT:-3306}/${DB_BOOKINGS_DATABASE}?createDatabaseIfNotExist=true
depends_on:
- Users-API
- Hotels-API
- Bookings-DB
#######################################
# Databases
#######################################
Users-DB:
image: mysql
hostname: ${DB_SERVICE_HOSTNAME}
hostname: ${DB_USERS_HOSTNAME}
cap_add:
- SYS_NICE
restart: unless-stopped
ports:
- "3307:3306"
networks:
- kong-net
volumes:
- users_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: ClaveRoot
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_DATABASE: RoomsBooking
MYSQL_ROOT_PASSWORD: ${DB_CREDENTIALS_ROOT_PASSWORD:-ClaveRoot}
MYSQL_USER: ${DB_CREDENTIALS_USER:-user}
MYSQL_PASSWORD: ${DB_CREDENTIALS_PASSWORD:-password}
MYSQL_DATABASE: ${DB_USERS_DATABASE}
MYSQL_ROOT_HOST: "%"
Hotels-DB:
image: mysql
hostname: ${DB_HOTELS_HOSTNAME}
cap_add:
- SYS_NICE
restart: unless-stopped
networks:
- kong-net
volumes:
- hotels_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: ${DB_CREDENTIALS_ROOT_PASSWORD:-ClaveRoot}
MYSQL_USER: ${DB_CREDENTIALS_USER:-user}
MYSQL_PASSWORD: ${DB_CREDENTIALS_PASSWORD:-password}
MYSQL_DATABASE: ${DB_HOTELS_DATABASE}
MYSQL_ROOT_HOST: "%"
Bookings-DB:
image: mysql
hostname: ${DB_BOOKINGS_HOSTNAME}
cap_add:
- SYS_NICE
restart: unless-stopped
networks:
- kong-net
volumes:
- hotels_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: ${DB_CREDENTIALS_ROOT_PASSWORD:-ClaveRoot}
MYSQL_USER: ${DB_CREDENTIALS_USER:-user}
MYSQL_PASSWORD: ${DB_CREDENTIALS_PASSWORD:-password}
MYSQL_DATABASE: ${DB_BOOKINGS_DATABASE}
MYSQL_ROOT_HOST: "%"
#######################################
# Cliente Angular
#######################################
RoomsBooking-Web:
image: roomsbooking-web-image
build:
......@@ -67,7 +244,5 @@ services:
- 4200:80
networks:
- kong-net
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://${DB_SERVICE_HOSTNAME}:3306/${DB_DATABASE_NAME}?createDatabaseIfNotExist=true
depends_on:
- RoomsBooking-database
......@@ -5,6 +5,8 @@ spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/RoomsBooking?cre
spring.datasource.username=user
spring.datasource.password=password
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.security.user.name=admin
spring.security.user.password=admin
# Usar esto para alternar entre las exposición del room repository ya que no es necesario su uso pero por defecto, al no cubrir su ruta, se expone
# spring.data.rest.base-path=false
......
......
......@@ -31,7 +31,7 @@ public class UserAPI {
private final User USER = new User(-1, "admin", null, null, UserRol.ADMIN);
private String getAccessToken() {
if (token == null || token.isEmpty() || jwtUtil.isTokenValid(token, USER)) {
if (token == null || token.isEmpty()) {
token = jwtUtil.generateToken(USER);
}
return token;
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment