Skip to content
Snippets Groups Projects
Commit ed69f8ac authored by Etxaniz Errazkin, Iñaki's avatar Etxaniz Errazkin, Iñaki
Browse files

y3 final updates

parent 38b5f196
No related branches found
No related tags found
No related merge requests found
Pipeline #139011 failed
Showing
with 463 additions and 57 deletions
ADMIN_USER=piacere ADMIN_USER=admin
ADMIN_PASSWORD=piacerePassword ADMIN_PASSWORD=projectPassword
HTTPS_PORT=443 HTTPS_PORT=443
SERVER_HOST=ci.piacere.digital.tecnalia.dev SERVER_HOST=ci.piacere.digital.tecnalia.dev
COMPOSE_PROJECT_NAME=piacere-iec-production COMPOSE_PROJECT_NAME=iec
IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3 IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3 IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3 IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
COMPOSE_FILE=docker-compose.yaml:docker-compose-jhipster-network-external.yaml:docker-compose-traefik-network-external.yaml:release/docker-compose.yaml IMAGE_IEC_INFLUXDBCLIENT=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3
COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-jhipster-network-external.yaml:release/docker-compose.yaml
...@@ -2,23 +2,41 @@ ...@@ -2,23 +2,41 @@
# Focus default variables as production, to allow direct download and run in production # Focus default variables as production, to allow direct download and run in production
# Required external variables that must be defined externally are those that have no value # Required external variables that must be defined externally are those that have no value
#### Environments managed #### Environments managed ####
# this is the default environment if needed uncomment and adjust # this is the default environment if needed uncomment and adjust
# some conventions on environment prefixes # some conventions on environment prefixes
# - _ENV_LOCAL_ .env.local purpouse is to cache build and start the setup locally using cache images exposing dev ports (i.e 3306, 5432, 8086, ...) for debug and development purposes. It is the default behaviour (_ENV_LOCAL_:build-cache:.env.local) # - development: purpouse is to cache build and start the setup locally using cache images exposing dev ports (i.e 3306, 5432, 8086, ...) for debug and development purposes. It is the default behaviour (local:run-build-cache)
# - _ENV_CACHE_ .env.cache purpouse is to generate images tagged for build cache from that use BUILDKIT_INLINE_CACHE 1 (_ENV_CACHE_:build-cache:.env.cache) # - release: purpouse is to generate images (that do not use BUILDKIT_INLINE_CACHE 1) tagged for the clients/pilots usage (release:run-build-release)
# - _ENV_RELEASE_ .env.release purpouse is to generate images (that do not use BUILDKIT_INLINE_CACHE 1) tagged for the clients/pilots usage (_ENV_RELEASE_:build-release:.env.release) # - prod: purpose is to generate non building docker-compose that uses the release to deploy on generic client (prod:run-release)
# - _ENV_DEPLOY_ .env purpose is to generate non building docker-compose that uses the release to deploy on generic client (_ENV_DEPLOY_:release:.env) # - test: the purpouse is to test from the cache images the correct behaviour without exposing ports (test:run-cache)
# - _ENV_TEST_ .env.test the purpouse is to test from the cache images the correct behaviour without exposing ports ()
# types of building # types of building
# - run-build-cache: it focuses in the generation of images with BUILDKIT_INLINE_CACHE 1 for its usage in the cache-from for subsequent build, for each compose-file in compose-file build it finds build/cache the same name to add it to the build, it will use cache from.
# - run-build-release: it focuses in the generation of images for distribution it avoid using BUILDKIT_INLINE_CACHE 1 to reduce the size, it will use cache from.
# - build-cache: it focuses in the generation of images with BUILDKIT_INLINE_CACHE 1 for its usage in the cache-from for subsequent build, for each compose-file in compose-file build it finds build/cache the same name to add it to the build, it will use cache from. # - build-cache: it focuses in the generation of images with BUILDKIT_INLINE_CACHE 1 for its usage in the cache-from for subsequent build, for each compose-file in compose-file build it finds build/cache the same name to add it to the build, it will use cache from.
# - build-release: it focuses in the generation of images for distribution it avoid using BUILDKIT_INLINE_CACHE 1 to reduce the size, it will use cache from. # - build-release: it focuses in the generation of images for distribution it avoid using BUILDKIT_INLINE_CACHE 1 to reduce the size, it will not use cache from.
# - cache: it runs using cache images # - run-cache: it runs using cache images
# - release: it runs using release images # - run-release: it runs using release images
# default enviroment # default enviroment
# _ENVIRONMENTS=_ENV_LOCAL_:build-cache:.env.local # __ENVIRONMENTS=development:run-build-cache
# to add more enviroments use split with ";" # to add more enviroments use split with ";"
_ENVIRONMENTS=_ENV_LOCAL_:build-cache:.env.local;_ENV_RELEASE_:build-release:.env.release;_ENV_DEPLOY_:release:.env;_ENV_PIACERE_:release:.env.piacere __ENVIRONMENTS=development:run-build-cache;prod:run-release;release:build-release
#### Modules managed ####
# this will create individual docker composes that enables the individual usage of the modules through the docker-compose command and specific env files i.e.
# __MODULES=traefik;step-ca
# will enable the following docker-compose commands
# docker-compose --env-file .env/modules/traefik/prod ----project-directory . up -d
# __MODULES=traefik;step-ca
__MODULES=iec
#### default environment ####
# __DEFAULT_ENVIRONMENT=.envs/global/prod
#### default environment ####
# __DEFAULT_DEVELOPMENT_ENVIRONMENT=.envs/global/development
#### default release environment ####
# __DEFAULT_RELEASE_ENVIRONMENT=.envs/global/release
#### Common image related #### #### Common image related ####
DOCKER_REGISTRY_CACHE_PREFIX=cache.euve.digital.tecnalia.dev:5000 DOCKER_REGISTRY_CACHE_PREFIX=cache.euve.digital.tecnalia.dev:5000
...@@ -32,56 +50,65 @@ DOCKER_REGISTRY_CACHE_VERSION=latest ...@@ -32,56 +50,65 @@ DOCKER_REGISTRY_CACHE_VERSION=latest
### Common Traefik related ### ### Common Traefik related ###
TRAEFIK_NETWORK_NAME=traefik_network TRAEFIK_NETWORK_NAME=traefik_network
TRAEFIK_HTTPS_ENTRYPOINT_NAME=websecure TRAEFIK_HTTPS_ENTRYPOINT_NAME=websecure
TRAEFIK_HTTP_ENTRYPOINT_NAME=web # TRAEFIK_HTTP_ENTRYPOINT_NAME=web
#### Common Production related #### #### Common Production related ####
ADMIN_USER=piacere ADMIN_USER=admin
ADMIN_PASSWORD=piacerePassword ADMIN_PASSWORD=projectPassword
# to calculate password hash `openssl passwd -apr1 $ADMIN_PASSWORD`
# ADMIN_PASSWORD_HASH='$apr1$chTuJ7f9$.Ul8E16QYHtydKw.ehzZC.'
# to calculate password bcrypt hash `sudo apt-get update; sudo apt-get install -y apache2-utils; htpasswd -bnBC 12 "" $ADMIN_PASSWORD | tr -d ':\n'`
# ADMIN_PASSWORD_BCRYPT_HASH='$2y$12$NxJ.FkLgDZWWjc15y9bhX./GOTp67krCxWPanJLyCjofKyIN.zS96'
# HTTPS_PORT must be 443 if you use step-ca
HTTPS_PORT=443 HTTPS_PORT=443
# server host is configured during the sync based on _ENV_LOCAL_ and _ENV_DEPLOY, _ENV_LOCAL_ will be used for test and release unless _ENV_RELEASE_ or _ENV_TEST_ specified
# SERVER_HOST=project.org
SERVER_HOST=ci.piacere.digital.tecnalia.dev SERVER_HOST=ci.piacere.digital.tecnalia.dev
#### Platform Specific #### #### Platform Specific ####
TZ=Madrid # TZ=Madrid
#### Platform Specific path ####
EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem
#### Common docker-compose related #### #### Common docker-compose related ####
# https://docs.docker.com/compose/reference/envvars/#compose_file#compose_project_name # https://docs.docker.com/compose/reference/envvars/#compose_file#compose_project_name
# these are docker-compose related environment variables # these are docker-compose related environment variables
COMPOSE_PROJECT_NAME=piacere-iec-production COMPOSE_PROJECT_NAME=iec
# _ENV_LOCAL_COMPOSE_FILE_BASE= # These are oriented for local vagrant usually it contains local traefik configuration, dev services, etc # _ENV_LOCAL_COMPOSE_FILE_BASE= # These are oriented for local vagrant usually it contains local traefik configuration, dev services, etc
# _ENV_RELEASE_COMPOSE_FILE_BASE= # These are oriented for tagging relevant images for upload to official release repositories # _ENV_RELEASE_COMPOSE_FILE_BASE= # These are oriented for tagging relevant images for upload to official release repositories
# _ENV_DEPLOY_COMPOSE_FILE_BASE= # These are oriented for final deployment it contains production traefik configuration, etc # _ENV_DEPLOY_COMPOSE_FILE_BASE= # These are oriented for final deployment it contains production traefik configuration, etc
# _ENV_TEST_COMPOSE_FILE_BASE= # These are oriented for testing # _ENV_TEST_COMPOSE_FILE_BASE= # These are oriented for testing
# COMPOSE_FILE_BASE= # (MANDATORY) These are those main services of the project, that will apply to all the scenarios # COMPOSE_FILE_BASE= # (MANDATORY) These are those main services of the project, that will apply to all the scenarios
COMPOSE_FILE_BASE=docker-compose.yaml COMPOSE_FILE_BASE=
COMPOSE_FILE_BASE_JHIPSTER_NETWORK=docker-compose-jhipster-network-external.yaml
COMPOSE_FILE= COMPOSE_FILE=
# COMPOSE_FILE Is generated automatically # COMPOSE_FILE Is generated automatically
COMPOSE_FILE_BASE_NETWORK=docker-compose-traefik-network-external.yaml __iec__COMPOSE_FILE_BASE=docker-compose.yaml
__iec__COMPOSE_FILE_BASE_NETWORK=docker-compose-traefik-network-external.yaml
IEC_CONFIG_PATH=
IEC_BASE_PATH= __iec__IEC_CONFIG_PATH=
__iec__IEC_BASE_PATH=
IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3 __iec_development__SERVER_HOST=192.168.56.1.nip.io
IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3 __iec_development__COMPOSE_FILE_BASE_EXPOSE_DEV=docker-compose-dev-expose.yaml
IMAGE_IEC_MYSQL_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3 __iec_development__COMPOSE_FILE_BASE_LOCAL_JHIPSTER_REGISTRY_VOLUMES=docker-compose-jhipster-registry-volumes.yaml
IMAGE_IEC_BACKEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3 __iec_development__COMPOSE_FILE_BASE_LOCAL_JHIPSTER_REGISTRY=git/jhipster-registry/docker-compose.yaml
IMAGE_IEC_FRONTEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3 __iec_development__COMPOSE_FILE_BASE_LOCAL_JHIPSTER_REGISTRY_DEV=git/jhipster-registry/docker-compose-dev.yaml
__iec_development__JHIPSTER_REGISTRY_CONFIG_PATH=git/jhipster-registry/
_ENV_LOCAL_SERVER_HOST=192.168.56.1.nip.io
_ENV_LOCAL_COMPOSE_FILE_BASE_EXPOSE_DEV=docker-compose-dev-expose.yaml __iec__IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
_ENV_LOCAL_COMPOSE_FILE_BASE_LOCAL_JHIPSTER_REGISTRY_VOLUMES=docker-compose-jhipster-registry-volumes.yaml __iec__IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
_ENV_LOCAL_COMPOSE_FILE_BASE_LOCAL_JHIPSTER_REGISTRY=git/jhipster-registry/docker-compose.yaml __iec__IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
_ENV_LOCAL_COMPOSE_FILE_BASE_LOCAL_JHIPSTER_REGISTRY_DEV=git/jhipster-registry/docker-compose-dev.yaml __iec__IMAGE_IEC_INFLUXDBCLIENT=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3
_ENV_LOCAL_JHIPSTER_REGISTRY_CONFIG_PATH=git/jhipster-registry/ __iec__IMAGE_IEC_MYSQL_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
__iec__IMAGE_IEC_BACKEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
_ENV_PIACERE_COMPOSE_FILE_BASE_PIACERE_BUILD=piacere-build/docker-compose.yaml __iec__IMAGE_IEC_FRONTEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
_ENV_PIACERE_COMPOSE_FILE_BASE_PIACERE_RELEASE=release/docker-compose.yaml __iec__IMAGE_IEC_INFLUXDBCLIENT_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3
_ENV_PIACERE_COMPOSE_FILE_BASE_ARTIFACTORY=docker-compose-artifactory.yaml
_ENV_PIACERE_COMPOSE_FILE_BASE_TRAEFIK_NETWORK=docker-compose-traefik-network-internal.yaml __iec__COMPOSE_FILE_BASE_JHIPSTER_NETWORK=docker-compose-jhipster-network-external.yaml
__iec_release__COMPOSE_FILE_BASE_PIACERE_BUILD=piacere-build/docker-compose.yaml
__iec_release__COMPOSE_FILE_BASE_PIACERE_RELEASE=release/docker-compose.yaml
__iec_release__COMPOSE_FILE_BASE_ARTIFACTORY=docker-compose-artifactory.yaml
__iec_release__COMPOSE_FILE_BASE_TRAEFIK_NETWORK=docker-compose-traefik-network-internal.yaml
DOCKER_REGISTRY_CACHE_PREFIX=cache.euve.digital.tecnalia.dev:5000
DOCKER_REGISTRY_CACHE_VERSION=latest
TRAEFIK_NETWORK_NAME=traefik_network
TRAEFIK_HTTPS_ENTRYPOINT_NAME=websecure
ADMIN_USER=admin
ADMIN_PASSWORD=projectPassword
HTTPS_PORT=443
SERVER_HOST=192.168.56.1.nip.io
EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem
COMPOSE_PROJECT_NAME=iec
IEC_CONFIG_PATH=
IEC_BASE_PATH=
JHIPSTER_REGISTRY_CONFIG_PATH=git/jhipster-registry/
COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-dev-expose.yaml:docker-compose-jhipster-registry-volumes.yaml:git/jhipster-registry/docker-compose.yaml:git/jhipster-registry/docker-compose-dev.yaml:docker-compose-jhipster-network-external.yaml:build/docker-compose.yaml:build/inline-cache/docker-compose.yaml:build/image/docker-compose.yaml
ADMIN_USER=admin
ADMIN_PASSWORD=projectPassword
HTTPS_PORT=443
SERVER_HOST=ci.piacere.digital.tecnalia.dev
COMPOSE_PROJECT_NAME=iec
IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
IMAGE_IEC_INFLUXDBCLIENT=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3
COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-jhipster-network-external.yaml:release/docker-compose.yaml
DOCKER_REGISTRY_CACHE_PREFIX=cache.euve.digital.tecnalia.dev:5000
DOCKER_REGISTRY_CACHE_VERSION=latest
TRAEFIK_NETWORK_NAME=traefik_network
ADMIN_USER=admin
ADMIN_PASSWORD=projectPassword
HTTPS_PORT=443
SERVER_HOST=ci.piacere.digital.tecnalia.dev
EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem
COMPOSE_PROJECT_NAME=iec
IEC_BASE_PATH=
IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
IMAGE_IEC_INFLUXDBCLIENT=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3
IMAGE_IEC_MYSQL_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
IMAGE_IEC_BACKEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
IMAGE_IEC_FRONTEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-jhipster-network-external.yaml:piacere-build/docker-compose.yaml:release/docker-compose.yaml:docker-compose-artifactory.yaml:docker-compose-traefik-network-internal.yaml:build/docker-compose.yaml
DOCKER_REGISTRY_CACHE_PREFIX=cache.euve.digital.tecnalia.dev:5000
DOCKER_REGISTRY_CACHE_VERSION=latest
TRAEFIK_NETWORK_NAME=traefik_network
TRAEFIK_HTTPS_ENTRYPOINT_NAME=websecure
ADMIN_USER=admin
ADMIN_PASSWORD=projectPassword
HTTPS_PORT=443
SERVER_HOST=192.168.56.1.nip.io
EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem
COMPOSE_PROJECT_NAME=iec
IEC_CONFIG_PATH=
IEC_BASE_PATH=
JHIPSTER_REGISTRY_CONFIG_PATH=git/jhipster-registry/
COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-dev-expose.yaml:docker-compose-jhipster-registry-volumes.yaml:git/jhipster-registry/docker-compose.yaml:git/jhipster-registry/docker-compose-dev.yaml:docker-compose-jhipster-network-external.yaml:build/docker-compose.yaml:build/inline-cache/docker-compose.yaml:build/image/docker-compose.yaml
ADMIN_USER=admin
ADMIN_PASSWORD=projectPassword
HTTPS_PORT=443
SERVER_HOST=ci.piacere.digital.tecnalia.dev
COMPOSE_PROJECT_NAME=iec
IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
IMAGE_IEC_INFLUXDBCLIENT=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3
COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-jhipster-network-external.yaml:release/docker-compose.yaml
DOCKER_REGISTRY_CACHE_PREFIX=cache.euve.digital.tecnalia.dev:5000
DOCKER_REGISTRY_CACHE_VERSION=latest
TRAEFIK_NETWORK_NAME=traefik_network
ADMIN_USER=admin
ADMIN_PASSWORD=projectPassword
HTTPS_PORT=443
SERVER_HOST=ci.piacere.digital.tecnalia.dev
EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem
COMPOSE_PROJECT_NAME=iec
IEC_BASE_PATH=
IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
IMAGE_IEC_INFLUXDBCLIENT=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3
IMAGE_IEC_MYSQL_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3
IMAGE_IEC_BACKEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3
IMAGE_IEC_FRONTEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3
COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-jhipster-network-external.yaml:piacere-build/docker-compose.yaml:release/docker-compose.yaml:docker-compose-artifactory.yaml:docker-compose-traefik-network-internal.yaml:build/docker-compose.yaml
...@@ -57,8 +57,8 @@ stages: ...@@ -57,8 +57,8 @@ stages:
DOCKER_BUILDKIT: 1 DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1 COMPOSE_DOCKER_CLI_BUILD: 1
DOCKER_COMPOSE_PATH: "." DOCKER_COMPOSE_PATH: "."
DOCKER_COMPOSE_ENV_FILE_CACHE: ".env.piacere" DOCKER_COMPOSE_ENV_FILE_CACHE: ".envs/global/release"
DOCKER_COMPOSE_ENV_FILE: ".env.piacere" DOCKER_COMPOSE_ENV_FILE: ".envs/global/release"
before_script: before_script:
- !reference [.artifactory-login] - !reference [.artifactory-login]
script: script:
......
...@@ -23,3 +23,16 @@ services: ...@@ -23,3 +23,16 @@ services:
EXTRA_CA_URL: ${EXTRA_CA_URL:?err} EXTRA_CA_URL: ${EXTRA_CA_URL:?err}
cache_from: cache_from:
- ${DOCKER_REGISTRY_CACHE_PREFIX}/piacere/iec-frontend:${DOCKER_REGISTRY_CACHE_VERSION:?err} - ${DOCKER_REGISTRY_CACHE_PREFIX}/piacere/iec-frontend:${DOCKER_REGISTRY_CACHE_VERSION:?err}
iec-influxdbclient:
build:
args:
- ENABLED=1
- LISTEN_INTERVAL=60
- RANGE_START=-30m
- TELEGRAF_INTERVAL=10s
- AGGREGATE_SAMPLING=60s
context: ${IEC_BASE_PATH}git/iec-influxdbclient
dockerfile: Dockerfile
cache_from:
- ${DOCKER_REGISTRY_CACHE_PREFIX}/piacere/iec-frontend:${DOCKER_REGISTRY_CACHE_VERSION:?err}
...@@ -7,3 +7,6 @@ services: ...@@ -7,3 +7,6 @@ services:
iec-frontend: iec-frontend:
image: ${DOCKER_REGISTRY_CACHE_PREFIX}/piacere/iec-frontend:${DOCKER_REGISTRY_CACHE_VERSION:?err} image: ${DOCKER_REGISTRY_CACHE_PREFIX}/piacere/iec-frontend:${DOCKER_REGISTRY_CACHE_VERSION:?err}
iec-influxdbclient:
image: ${DOCKER_REGISTRY_CACHE_PREFIX}/piacere/iec-influxdbclient:${DOCKER_REGISTRY_CACHE_VERSION:?err}
...@@ -13,3 +13,8 @@ services: ...@@ -13,3 +13,8 @@ services:
build: build:
args: args:
BUILDKIT_INLINE_CACHE: 1 # For multistage docker BUILDKIT_INLINE_CACHE: 1 # For multistage docker
iec-influxdbclient:
build:
args:
BUILDKIT_INLINE_CACHE: 1 # For multistage docker
...@@ -11,4 +11,8 @@ services: ...@@ -11,4 +11,8 @@ services:
build: build:
labels: labels:
com.jfrog.artifactory.retention.maxCount: 6 com.jfrog.artifactory.retention.maxCount: 6
iec-influxdbclient:
build:
labels:
com.jfrog.artifactory.retention.maxCount: 6
...@@ -5,7 +5,7 @@ services: ...@@ -5,7 +5,7 @@ services:
volumes: volumes:
- iec-mysql_data:/var/lib/mysql - iec-mysql_data:/var/lib/mysql
networks: networks:
default: traefik_network:
iec-backend: iec-backend:
restart: always restart: always
...@@ -17,8 +17,7 @@ services: ...@@ -17,8 +17,7 @@ services:
# SPRING_R2DBC_URL: r2dbc:mysql://iec-mysql:3306/iecBackend?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true # SPRING_R2DBC_URL: r2dbc:mysql://iec-mysql:3306/iecBackend?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true
# SPRING_LIQUIBASE_URL: jdbc:mysql://iec-mysql:3306/iecBackend?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true # SPRING_LIQUIBASE_URL: jdbc:mysql://iec-mysql:3306/iecBackend?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true
networks: networks:
default: traefik_network:
jhipster_network:
iec-frontend: iec-frontend:
restart: always restart: always
...@@ -26,8 +25,6 @@ services: ...@@ -26,8 +25,6 @@ services:
GLOBAL_PASSWORD: ${ADMIN_PASSWORD} GLOBAL_PASSWORD: ${ADMIN_PASSWORD}
JHIPSTER_CORS_ALLOWEDORIGINS: "https://iec.${SERVER_HOST:?err}:${HTTPS_PORT}" JHIPSTER_CORS_ALLOWEDORIGINS: "https://iec.${SERVER_HOST:?err}:${HTTPS_PORT}"
networks: networks:
default:
jhipster_network:
traefik_network: traefik_network:
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
...@@ -35,8 +32,22 @@ services: ...@@ -35,8 +32,22 @@ services:
- "traefik.http.routers.iec-frontend.entrypoints=websecure" - "traefik.http.routers.iec-frontend.entrypoints=websecure"
- "traefik.http.routers.iec-frontend.rule=Host(`iec.${SERVER_HOST:?err}`)" - "traefik.http.routers.iec-frontend.rule=Host(`iec.${SERVER_HOST:?err}`)"
# PIACERE InfluxDB Client
iec-influxdbclient:
restart: always
environment:
- INFLUXDB_URL=https://influxdb.pm.ci.piacere.digital.tecnalia.dev
- INFLUXDB_TOKEN=Fu7iwOeqhYOd6A_1Fg9GKSUNKBwl-FEAWn8cUTXuMUwAXXge4WETVAxg4iRh_l9vdYZN9klkf3aY250h6wyNKg==
- INFLUXDB_ORGANIZATION=piacere
- INFLUXDB_BUCKET=bucket
- INFLUXDB_MEASUREMENT=psl
- INFLUXDB_FIELD=input_system_availability_percent
- MYSQL_HOST=iec-mysql
- MYSQL_USER=root
- MYSQL_PASSWORD=
- MYSQL_DB=iecbackend
networks:
traefik_network:
volumes: volumes:
iec-mysql_data: iec-mysql_data:
networks:
default:
FROM python:3.9-slim-bullseye
ARG ENABLED
ARG LISTEN_INTERVAL
ARG RANGE_START
ARG TELEGRAF_INTERVAL
ARG AGGREGATE_SAMPLING
RUN mkdir -p /piacere_influxdb_client
WORKDIR /piacere_influxdb_client
COPY . /piacere_influxdb_client
RUN apt-get update && \
pip3 install --no-cache-dir -r requirements.txt && \
sed -i "s|\"ENABLED\"|$ENABLED|g" /piacere_influxdb_client/config/config.ini && \
sed -i "s|\"LISTEN_INTERVAL\"|$LISTEN_INTERVAL|g" /piacere_influxdb_client/config/config.ini && \
sed -i "s|\"RANGE_START\"|$RANGE_START|g" /piacere_influxdb_client/config/config.ini && \
sed -i "s|\"TELEGRAF_INTERVAL\"|$TELEGRAF_INTERVAL|g" /piacere_influxdb_client/config/config.ini && \
sed -i "s|\"AGGREGATE_SAMPLING\"|$AGGREGATE_SAMPLING|g" /piacere_influxdb_client/config/config.ini
ENV PATH /piacere_influxdb_client:$PATH
ENTRYPOINT ["sh", "./init.sh"]
\ No newline at end of file
[PIACERE-INFLUXDB-CLIENT]
piacere.influxdb.enabled = "ENABLED"
piacere.influxdb.sleep = "LISTEN_INTERVAL"
piacere.influxdb.range.start = "RANGE_START"
piacere.influxdb.telegraf.interval = "TELEGRAF_INTERVAL"
piacere.influxdb.aggregate.sampling = "AGGREGATE_SAMPLING"
\ No newline at end of file
#!/bin/bash
python piacere_influxdb_client.py
\ No newline at end of file
import configparser
import influxdb_client
import json
import logging
import os
import pymysql
import time
from datetime import datetime
from influxdb_client import InfluxDBClient, Point, WritePrecision
from influxdb_client.client.write_api import SYNCHRONOUS
import templates.influxdb_query_templates as influxdb_query_templates
import templates.mysql_query_templates as mysql_query_templates
# Configure the logging level
logging.basicConfig(level = logging.INFO)
# Create the config object and read config.ini file
config = configparser.ConfigParser()
config.read('config/config.ini')
# Function: commitToDatabase
def commitToDatabase(query_result):
# logging.info(json.dumps(query_result, indent = 4))
conn = None
try:
# Connect to the database
conn = pymysql.connect(
host = os.environ.get("MYSQL_HOST"),
user = os.environ.get("MYSQL_USER"),
password = os.environ.get("MYSQL_PASSWORD"),
db = os.environ.get("MYSQL_DB"))
# Declare the custom cursor and update the database
cursor = conn.cursor()
if query_result:
# Transform the influxdb query result, replacing the service name by the service id
# and discarding the entries whose service id is null
data_to_process = {}
cursor.execute(mysql_query_templates.mysql_select_services_query)
services = cursor.fetchall()
if services and len(services) > 0:
for key in query_result:
service_id = None
for service in services:
if query_result[key]['service'] == service[1]:
service_id = service[0]
break
if service_id:
query_result[key]['service'] = service_id
data_to_process[key] = query_result[key]
# Fetch the instances, and separate them into active and inactive
logging.info("")
logging.info(" > Data to be processed:")
logging.info(json.dumps(data_to_process, indent = 4))
cursor.execute(mysql_query_templates.mysql_select_instances_query)
instances = cursor.fetchall()
active_instances = []
inactive_instances = []
if instances and len(instances) > 0:
for instance in instances:
if instance[4]:
inactive_instances.append(instance)
else:
active_instances.append(instance)
logging.info("")
logging.info(" > Checking instances...")
logging.info(" > Active instances: " + str(len(active_instances)))
logging.info(" > Inactive instances: " + str(len(inactive_instances)))
# Set all the active instances to inactive
if active_instances and len(active_instances) > 0:
logging.info(" > Setting the active instances to inactive...")
cursor.execute(mysql_query_templates.mysql_update_instances_to_inactive_query % (datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
conn.commit()
# Search the result of the influxdb query in active and inactive instance lists
foundInActiveInstances = False
foundInInactiveInstances = False
for key in data_to_process:
for instance in active_instances:
if key == instance[1] and data_to_process[key]['instance'] == instance[2] and data_to_process[key]['service'] == instance[5] and data_to_process[key]['host'] == instance[3]:
foundInActiveInstances = True
break
for instance in inactive_instances:
if key == instance[1] and data_to_process[key]['instance'] == instance[2] and data_to_process[key]['service'] == instance[5] and data_to_process[key]['host'] == instance[3]:
foundInInactiveInstances = True
break
# If the instance is not found, insert into database. If the instances is found as active, update database
if foundInActiveInstances is False and foundInInactiveInstances is False:
logging.info(" > Inserting '" + data_to_process[key]['instance'] + "' instance...")
cursor.execute(mysql_query_templates.mysql_insert_instance_query % (key, data_to_process[key]['instance'], data_to_process[key]['host'], data_to_process[key]['availability'], datetime.now().strftime('%Y-%m-%d %H:%M:%S'), datetime.now().strftime('%Y-%m-%d %H:%M:%S'), data_to_process[key]['service']))
conn.commit()
logging.info(" > The instance was inserted successfully!")
logging.info("")
elif foundInActiveInstances is True:
logging.info(" > Updating '" + data_to_process[key]['instance'] + "' instance...")
cursor.execute(mysql_query_templates.mysql_update_instance_query % (data_to_process[key]['availability'], datetime.now().strftime('%Y-%m-%d %H:%M:%S'), key, data_to_process[key]['instance'], data_to_process[key]['host'], data_to_process[key]['service']))
conn.commit()
logging.info(" > The instance was updated successfully!")
logging.info("")
except Exception as error:
logging.error(str(error))
finally:
# Close the connection
if conn:
conn.close()
# Welcome message
logging.info('')
logging.info('******************************************************************************************')
logging.info('*************************** PIACERE InfluxDB Client started! ***************************')
logging.info('******************************************************************************************')
# Start the process
if int(config['PIACERE-INFLUXDB-CLIENT']['piacere.influxdb.enabled']) != 1:
logging.info('')
logging.info('******************************************************************************************')
logging.info('************************* PIACERE InfluxDB Client not enabled! *************************')
logging.info('************************* PIACERE InfluxDB Client exited! *************************')
logging.info('******************************************************************************************')
else:
try:
# Create the query result object
query_result = {}
# Create the InfluxDB client and the query API
client = influxdb_client.InfluxDBClient(
url = os.environ.get("INFLUXDB_URL"),
token = os.environ.get("INFLUXDB_TOKEN"),
org = os.environ.get("INFLUXDB_ORGANIZATION"))
query_api = client.query_api()
# Start listening
while True:
logging.info(' > Listening...')
# Execute the query and extract the data as a JSON object
tables = query_api.query(influxdb_query_templates.influxdb_query, org = os.environ.get("INFLUXDB_ORGANIZATION"))
tables_to_json = json.loads(tables.to_json(indent = 4))
# Loop through the query result (if needed)
if tables_to_json and len(tables_to_json) > 0:
# logging.info(json.dumps(tables_to_json, indent = 4))
deployments = []
for table in tables_to_json:
if table['deployment_id'] not in deployments:
deployments.append(table['deployment_id'])
if table['deployment_id'] not in query_result:
query_result[table['deployment_id']] = { 'service': None, 'instance': None, 'host': None, 'availability': None, 'time': 0 }
if deployments and len(deployments) > 0:
for deployment in deployments:
for table in tables_to_json:
if table['deployment_id'] == deployment:
result_time = datetime.strptime(table['_time'][:19], '%Y-%m-%dT%H:%M:%S').timestamp() * 1000
if result_time > query_result[deployment]['time']:
if 'doml_element_type' in table:
query_result[deployment]['service'] = table['doml_element_type']
query_result[deployment]['instance'] = table['doml_element_name']
if 'host' in table:
query_result[deployment]['host'] = table['host']
query_result[deployment]['availability'] = table['_value']
query_result[deployment]['time'] = result_time
# Commit to database
commitToDatabase(query_result)
# Wait the configured interval
time.sleep(int(config['PIACERE-INFLUXDB-CLIENT']['piacere.influxdb.sleep']))
except Exception as error:
logging.info('')
logging.info('******************************************************************************************')
logging.error(str(error))
logging.info('******************************************************************************************')
\ No newline at end of file
cryptography == 41.0.5
influxdb-client == 1.38.0
pymysql == 1.1.0
Werkzeug == 2.2.2
\ No newline at end of file
import configparser
import os
# Create the config object and read config.ini file
config = configparser.ConfigParser()
config.read('config/config.ini')
# Replacing variables
influxdb_query_data = {
"bucket": os.environ.get("INFLUXDB_BUCKET"),
"start": config['PIACERE-INFLUXDB-CLIENT']['piacere.influxdb.range.start'],
"telegraf_interval": config['PIACERE-INFLUXDB-CLIENT']['piacere.influxdb.telegraf.interval'],
"aggregate_sampling": config['PIACERE-INFLUXDB-CLIENT']['piacere.influxdb.aggregate.sampling'],
"measurement": os.environ.get("INFLUXDB_MEASUREMENT"),
"field": os.environ.get("INFLUXDB_FIELD")
}
# The query template
INFLUXDB_QUERY_TEMPLATE = """
bucket = "{bucket}"
start = {start}
telegraf_interval = {telegraf_interval}
discard_level = int(v: duration(v: uint(v: telegraf_interval) + uint(v: 5s)))/1000000000
aggregate_sampling = {aggregate_sampling}
measurement = "{measurement}"
field = "{field}"
from(bucket: bucket)
|> range(start: start)
|> filter(fn: (r) => r._measurement == measurement)
|> filter(fn: (r) => r._field == field)
|> keep(columns: ["deployment_id", "host", "doml_element_name", "doml_element_type", "_time", "_field", "_value"])
|> aggregateWindow(every: 1m, fn: mean, createEmpty: true)
|> fill(column: "_value", value: 0.0)
|> yield(name: "mean")
"""
# The final query
influxdb_query = INFLUXDB_QUERY_TEMPLATE.format(**influxdb_query_data)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment