From 982e5604915028ab5475b2bbf741387a25f46435 Mon Sep 17 00:00:00 2001 From: Aytac Ozkan Date: Tue, 28 Jul 2020 14:33:21 +0200 Subject: [PATCH] bug fixing , reducing unnecessary codes --- .env | 36 +++++++++++++++- build.sh | 6 +-- docker-compose.yml | 93 +++++++++++++++++++++-------------------- portal/.env | 6 +-- portal/nginx/nginx.conf | 2 +- postgresql/Dockerfile | 2 + search.api/Dockerfile | 6 +++ search/.env | 10 ++--- search/nginx/nginx.conf | 2 +- 9 files changed, 104 insertions(+), 59 deletions(-) diff --git a/.env b/.env index 83c0256..618ff24 100644 --- a/.env +++ b/.env @@ -1,3 +1,37 @@ COMPOSE_PROJECT_NAME=es CERTS_DIR=/usr/share/elasticsearch/config/certificates/ -VERSION=7.8.0 \ No newline at end of file +VERSION=7.8.0 + +ELASTICSEARCH_USERNAME=elastic +ELASTICSEARCH_PASSWORD=InSylva1465441881 + +ME_CONFIG_MONGODB_ADMINUSERNAME=in_sylva_mongoc +ME_CONFIG_MONGODB_ADMINPASSWORD=v2kGBDUaGjXK2VuPyf5R64VS + +PGADMIN_DEFAULT_EMAIL=aytac.ozkan@inra.fr +PGADMIN_DEFAULT_PASSWORD=v2kGBDUaGjXK2VuPyf5R64VS + +DB_USER=insylva_admin_pg +DB_SCHEMA=public +DB_PASSWORD=v2kGBDUaGjXK2VuPyf5R64VS + +KEYCLOAK_USER=insylva_admin +KEYCLOAK_PASSWORD=v2kGBDUaGjXK2VuPyf5R64VS + +POSTGRES_USER=insylva_admin_pg +POSTGRES_PASSWORD=v2kGBDUaGjXK2VuPyf5R64VS + +MONGO_INITDB_ROOT_USERNAME=in_sylva_mongoc +MONGO_INITDB_ROOT_PASSWORD=v2kGBDUaGjXK2VuPyf5R64VS +MONGO_INITDB_DATABASE=insylva + +KEYCLOAK_REALM=in-sylva +KEYCLOAK_SERVER_URL=http://keycloak:8080/keycloak/auth +KEYCLOAK_SERVER_PUBLIC_KEY=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp4KOgK5s+xvmun5sbPzcRLTIvGmVyG+nNdILYKNkpjUuFGvG2KqDNZZsq5rk9EPyrEApnbPWmOZusCn1dVegoGvkfSxkyP7AtVamwZMvTBObG0Ktju47o8/KCk63NPfwdWxSNyhWWa3VV95+l4VctvwAH7MeEV6uTDjsby2+LIojJOE+IWhPoLXiINuQ/GzKrzd30pS0XpMLQdru1vJgLXBPAvcZbYMvIkK3b5zIC02x4mL7PGP2LFZBZxUTMhRoC6cTc7C3uDagF5MHPOqfVl3ycHbm7Hc4bpJGSzqYGINLQ28I59WqM5zc+Wpml0Lmyd6wv5eqUTJWQKdc92DvtQIDAQAB +KEYCLOAK_CREDENTIALS_SECRET=6d1fea7a-b803-440e-b0d7-2b551e2ff2b9 + +BOT_SERVICE_TOKEN=xoxb-791472305859-913372508932-2CcYhaCRrTLDXzKc5Df9ZMUb +BOT_SERVICE_CHANNEL=CPLTQQQ0Y + +MONGO_USERNAME=in_sylva_mongoc +MONGO_PASSWORD=v2kGBDUaGjXK2VuPyf5R64VS \ No newline at end of file diff --git a/build.sh b/build.sh index a376bc7..b5f17f5 100755 --- a/build.sh +++ b/build.sh @@ -18,11 +18,11 @@ Usage(){ echo "Args:" echo "-k : mandatory. id_rsa keyfile should exits in ~/.ssh/ user directory " echo "-t {dev|prod}: mandatory. If deployment is choosen, you must precise -d argument" - echo "-d domain_name: mandatory in production deploiement. Precise the base URL which will be use to contact application." + echo "-d domain_name: mandatory in production deployment. Precise the base URL which will be use to contact application." echo " domain_name should appear as ///" echo " Example: w3.avignon.inra.fr/bas_insylva/portal/" - echo "-s : mandatory in production deploiement. Precise the ip address of the server (used for direct access to search application in production mode)" - echo "-p : mandatory in production deploiement. Precise the port number of the server (used for direct access to login application in production mode)" + echo "-s : mandatory in production deployment. Precise the ip address of the server (used for direct access to search application in production mode)" + echo "-p : mandatory in production deployment. Precise the port number of the server (used for direct access to login application in production mode)" echo "##############################################" exit } diff --git a/docker-compose.yml b/docker-compose.yml index 117af87..0f8863a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -25,7 +25,7 @@ services: - cluster.initial_master_nodes=es01 - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - - ELASTIC_PASSWORD=InSylva1465441881 + - ELASTIC_PASSWORD=$ELASTICSEARCH_PASSWORD - xpack.security.enabled=true - xpack.security.transport.ssl.enabled=true - xpack.security.transport.ssl.verification_mode=certificate @@ -66,6 +66,7 @@ services: interval: 30s timeout: 10s retries: 5 + restart: unless-stopped networks: - insylva-net @@ -77,8 +78,8 @@ services: - SERVER_HOST=0.0.0.0 - ELASTICSEARCH_URL=http://es01:9200 - ELASTICSEARCH_HOSTS=http://es01:9200 - - ELASTICSEARCH_USERNAME=elastic - - ELASTICSEARCH_PASSWORD=InSylva1465441881 + - ELASTICSEARCH_USERNAME=$ELASTICSEARCH_USERNAME + - ELASTICSEARCH_PASSWORD=$ELASTICSEARCH_PASSWORD volumes: - type: volume source: logs @@ -109,6 +110,7 @@ services: delay: 30s max_attempts: 3 window: 120s + restart: unless-stopped networks: - insylva-net @@ -133,12 +135,12 @@ services: image: in-sylva.postgres:latest container_name: in-sylva.postgres volumes: - - ./data.sql:/docker-entrypoint-initdb.d/data.sql - - ./postgres-data:/var/lib/postgresql/data + - ./data.sql:/docker-entrypoint-initdb.d/data.sql:z + - postgres_data:/var/lib/postgresql:z environment: POSTGRES_MULTIPLE_DATABASES: insylva,keycloak - POSTGRES_USER: insylva_admin_pg - POSTGRES_PASSWORD: v2kGBDUaGjXK2VuPyf5R64VS + POSTGRES_USER: $POSTGRES_USER + POSTGRES_PASSWORD: $POSTGRES_PASSWORD POSTGRES_HOST: postgres ports: - 5432:5432 @@ -157,12 +159,12 @@ services: DB_PORT: 5432 DB_DATABASE: keycloak - DB_USER: insylva_admin_pg - DB_SCHEMA: public - DB_PASSWORD: v2kGBDUaGjXK2VuPyf5R64VS + DB_USER: $DB_USER + DB_SCHEMA: $DB_SCHEMA + DB_PASSWORD: $DB_PASSWORD - KEYCLOAK_USER: insylva_admin - KEYCLOAK_PASSWORD: v2kGBDUaGjXK2VuPyf5R64VS + KEYCLOAK_USER: $KEYCLOAK_USER + KEYCLOAK_PASSWORD: $KEYCLOAK_PASSWORD # Uncomment the line below if you want to specify JDBC parameters. The parameter below is just an example, and it shouldn't be used in production without knowledge. It is highly recommended that you read the PostgreSQL JDBC driver documentation in order to use it. # JDBC_PARAMS: useSSL=false # JGROUPS_DISCOVERY_PROTOCOL: JDBC_PING @@ -177,9 +179,10 @@ services: pgadmin: image: dpage/pgadmin4:latest + depends_on: [postgres] environment: - PGADMIN_DEFAULT_EMAIL: aytac.ozkan@inra.fr - PGADMIN_DEFAULT_PASSWORD: v2kGBDUaGjXK2VuPyf5R64VS + PGADMIN_DEFAULT_EMAIL: $PGADMIN_DEFAULT_EMAIL + PGADMIN_DEFAULT_PASSWORD: $PGADMIN_DEFAULT_PASSWORD volumes: - pgadmin:/root/.pgadmin ports: @@ -192,8 +195,8 @@ services: image: mongo:latest container_name: in-sylva.mongodb environment: - MONGO_INITDB_ROOT_USERNAME: in_sylva_mongoc - MONGO_INITDB_ROOT_PASSWORD: v2kGBDUaGjXK2VuPyf5R64VS + MONGO_INITDB_ROOT_USERNAME: $MONGO_INITDB_ROOT_USERNAME + MONGO_INITDB_ROOT_PASSWORD: $MONGO_INITDB_ROOT_PASSWORD MONGO_INITDB_DATABASE: insylva ports: - 27017:27017 @@ -208,8 +211,8 @@ services: ports: - 8881:8081 environment: - ME_CONFIG_MONGODB_ADMINUSERNAME: in_sylva_mongoc - ME_CONFIG_MONGODB_ADMINPASSWORD: v2kGBDUaGjXK2VuPyf5R64VS + ME_CONFIG_MONGODB_ADMINUSERNAME: $ME_CONFIG_MONGODB_ADMINUSERNAME + ME_CONFIG_MONGODB_ADMINPASSWORD: $ME_CONFIG_MONGODB_ADMINPASSWORD networks: - insylva-net restart: unless-stopped @@ -226,15 +229,15 @@ services: NODE_ENV: production DB_HOST: in-sylva.postgres - DB_USERNAME: insylva_admin_pg - DB_PASSWORD: v2kGBDUaGjXK2VuPyf5R64VS + DB_USERNAME: $DB_USER + DB_PASSWORD: $DB_PASSWORD DB_DATABASE: insylva DB_PORT: 5432 ELK_HOST: es01 ELK_PORT: 9200 - ELK_USERNAME: elastic - ELK_PASSWORD: InSylva1465441881 + ELK_USERNAME: $ELASTICSEARCH_USERNAME + ELK_PASSWORD: $ELASTICSEARCH_PASSWORD KEYCLOAK_REALM: in-sylva KEYCLOAK_SERVER_URL: http://keycloak:7000/keycloak/auth @@ -260,15 +263,15 @@ services: DB_HOST: in-sylva.postgres DB_PORT: 5432 - DB_USER: insylva_admin_pg - DB_PASSWORD: v2kGBDUaGjXK2VuPyf5R64VS + DB_USER: $DB_USER + DB_PASSWORD: $DB_PASSWORD DB_DATABASE: insylva IN_SYLVA_KEYCLOAK_HOST: http://keycloak IN_SYLVA_KEYCLOAK_PORT: 8080 - KEYCLOAK_USERNAME: insylva_admin - KEYCLOAK_PASSWORD: v2kGBDUaGjXK2VuPyf5R64VS + KEYCLOAK_USERNAME: $KEYCLOAK_USER + KEYCLOAK_PASSWORD: $KEYCLOAK_PASSWORD KEYCLOAK_GRANT_TYPE: password KEYCLOAK_CLIENT_ID: admin-cli @@ -279,10 +282,10 @@ services: SERVICE_PORT: 4000 SERVICE_NAME: in-sylva-gatekeeper-v1 - KEYCLOAK_REALM: in-sylva - KEYCLOAK_SERVER_URL: http://keycloak:8080/keycloak/auth - KEYCLOAK_SERVER_PUBLIC_KEY: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp4KOgK5s+xvmun5sbPzcRLTIvGmVyG+nNdILYKNkpjUuFGvG2KqDNZZsq5rk9EPyrEApnbPWmOZusCn1dVegoGvkfSxkyP7AtVamwZMvTBObG0Ktju47o8/KCk63NPfwdWxSNyhWWa3VV95+l4VctvwAH7MeEV6uTDjsby2+LIojJOE+IWhPoLXiINuQ/GzKrzd30pS0XpMLQdru1vJgLXBPAvcZbYMvIkK3b5zIC02x4mL7PGP2LFZBZxUTMhRoC6cTc7C3uDagF5MHPOqfVl3ycHbm7Hc4bpJGSzqYGINLQ28I59WqM5zc+Wpml0Lmyd6wv5eqUTJWQKdc92DvtQIDAQAB - KEYCLOAK_CREDENTIALS_SECRET: 6d1fea7a-b803-440e-b0d7-2b551e2ff2b9 + KEYCLOAK_REALM: $KEYCLOAK_REALM + KEYCLOAK_SERVER_URL: $KEYCLOAK_SERVER_URL + KEYCLOAK_SERVER_PUBLIC_KEY: $KEYCLOAK_SERVER_PUBLIC_KEY + KEYCLOAK_CREDENTIALS_SECRET: $KEYCLOAK_CREDENTIALS_SECRET networks: - insylva-net @@ -296,38 +299,38 @@ services: PROCESS_TYPE: web PORT: 5000 - BOT_SERVICE_TOKEN: xoxb-791472305859-913372508932-2CcYhaCRrTLDXzKc5Df9ZMUb - BOT_SERVICE_CHANNEL: CPLTQQQ0Y + BOT_SERVICE_TOKEN: $BOT_SERVICE_TOKEN + BOT_SERVICE_CHANNEL: $BOT_SERVICE_CHANNEL IN_SYLVA_GATEKEEPER_HOST: http://in-sylva.gatekeeper IN_SYLVA_GATEKEEPER_PORT: 4000 MONGO_HOST: mongo - MONGO_USERNAME: in_sylva_mongoc - MONGO_PASSWORD: v2kGBDUaGjXK2VuPyf5R64VS + MONGO_USERNAME: $MONGO_USERNAME + MONGO_PASSWORD: $MONGO_PASSWORD MONGO_DB_NAME: insylva MONGO_PORT: 27017 DB_HOST: postgres - DB_USER: insylva_admin_pg - DB_PASSWORD: v2kGBDUaGjXK2VuPyf5R64VS + DB_USER: $DB_USER + DB_PASSWORD: $DB_PASSWORD DB_DATABASE: insylva DB_PORT: 5432 ELK_HOST: es01 ELK_PORT: 9200 - ELK_USERNAME: elastic - ELK_PASSWORD: InSylva1465441881 + ELK_USERNAME: $ELASTICSEARCH_USERNAME + ELK_PASSWORD: $ELASTICSEARCH_PASSWORD - KEYCLOAK_USERNAME: insylva_admin - KEYCLOAK_PASSWORD: v2kGBDUaGjXK2VuPyf5R64VS + KEYCLOAK_USERNAME: $KEYCLOAK_USER + KEYCLOAK_PASSWORD: $KEYCLOAK_PASSWORD KEYCLOAK_GRANT_TYPE: password KEYCLOAK_CLIENT_ID: admin-cli - KEYCLOAK_REALM: in-sylva - KEYCLOAK_SERVER_URL: http://keycloak:8080/keycloak/auth - KEYCLOAK_SERVER_PUBLIC_KEY: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp4KOgK5s+xvmun5sbPzcRLTIvGmVyG+nNdILYKNkpjUuFGvG2KqDNZZsq5rk9EPyrEApnbPWmOZusCn1dVegoGvkfSxkyP7AtVamwZMvTBObG0Ktju47o8/KCk63NPfwdWxSNyhWWa3VV95+l4VctvwAH7MeEV6uTDjsby2+LIojJOE+IWhPoLXiINuQ/GzKrzd30pS0XpMLQdru1vJgLXBPAvcZbYMvIkK3b5zIC02x4mL7PGP2LFZBZxUTMhRoC6cTc7C3uDagF5MHPOqfVl3ycHbm7Hc4bpJGSzqYGINLQ28I59WqM5zc+Wpml0Lmyd6wv5eqUTJWQKdc92DvtQIDAQAB - KEYCLOAK_CREDENTIALS_SECRET: 6d1fea7a-b803-440e-b0d7-2b551e2ff2b9 + KEYCLOAK_REALM: $KEYCLOAK_REALM + KEYCLOAK_SERVER_URL: $KEYCLOAK_SERVER_URL + KEYCLOAK_SERVER_PUBLIC_KEY: $KEYCLOAK_SERVER_PUBLIC_KEY + KEYCLOAK_CREDENTIALS_SECRET: $KEYCLOAK_CREDENTIALS_SECRET CONSUL_IP: in-sylva-consul CONSUL_PORT: 8500 @@ -427,7 +430,7 @@ services: - 35729:35729 volumes: - postgres-data: + postgres_data: pgadmin: esdata: certs: diff --git a/portal/.env b/portal/.env index e3aaf18..f156d05 100644 --- a/portal/.env +++ b/portal/.env @@ -1,6 +1,6 @@ -REACT_APP_IN_SYLVA_GATEKEEPER_HOST=/bas_insylva/portal/gatekeeper -REACT_APP_IN_SYLVA_SOURCE_MANAGER_HOST=/bas_insylva/portal/source-manager -REACT_APP_IN_SYLVA_KEYCLOAK_HOST=/bas_insylva/portal/keycloak +REACT_APP_IN_SYLVA_GATEKEEPER_HOST=/gatekeeper +REACT_APP_IN_SYLVA_SOURCE_MANAGER_HOST=/source-manager +REACT_APP_IN_SYLVA_KEYCLOAK_HOST=/keycloak REACT_APP_IN_SYLVA_CLIENT_ID=in-sylva.user.app REACT_APP_IN_SYLVA_GRANT_TYPE=password REACT_APP_IN_SYLVA_REALM=in-sylva diff --git a/portal/nginx/nginx.conf b/portal/nginx/nginx.conf index fc65f4e..bcdab21 100644 --- a/portal/nginx/nginx.conf +++ b/portal/nginx/nginx.conf @@ -34,7 +34,7 @@ server { listen 3000; listen [::]:3000; - server_name w3.avignon.inra.fr/bas_insylva/portal/; + server_name -; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; diff --git a/postgresql/Dockerfile b/postgresql/Dockerfile index 81e25a4..4d17fba 100644 --- a/postgresql/Dockerfile +++ b/postgresql/Dockerfile @@ -1,4 +1,6 @@ FROM postgres:12.3-alpine + COPY create-multiple-postgresql-databases.sh /docker-entrypoint-initdb.d/ +# RUN chown postgres:postgres /docker-entrypoint-initdb.d/ EXPOSE 5432 \ No newline at end of file diff --git a/search.api/Dockerfile b/search.api/Dockerfile index e1d4694..369ad56 100644 --- a/search.api/Dockerfile +++ b/search.api/Dockerfile @@ -1,5 +1,7 @@ FROM node:latest +ENV DOCKERIZE_VERSION v0.6.1 + RUN apt-get update && \ apt-get install -y git \ openssh-server @@ -7,6 +9,10 @@ RUN apt-get update && \ RUN apt-get update && apt-get install wget && apt-get install telnet -y RUN npm install --global pm2 +RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ + && tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ + && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz + RUN mkdir /var/run/sshd EXPOSE 22 diff --git a/search/.env b/search/.env index b2ed1ab..566ee6e 100644 --- a/search/.env +++ b/search/.env @@ -1,8 +1,8 @@ -REACT_APP_IN_SYLVA_GATEKEEPER_HOST=/bas_insylva/search/gatekeeper -REACT_APP_IN_SYLVA_SOURCE_MANAGER_HOST=/bas_insylva/search/source-manager -REACT_APP_IN_SYLVA_KEYCLOAK_HOST=/bas_insylva/search/keycloak -REACT_APP_IN_SYLVA_SEARCH_HOST=/bas_insylva/search/search-api -REACT_APP_IN_SYLVA_LOGIN_HOST=http://w3.avignon.inra.fr/bas_insylva/login/ +REACT_APP_IN_SYLVA_GATEKEEPER_HOST=/gatekeeper +REACT_APP_IN_SYLVA_SOURCE_MANAGER_HOST=/source-manager +REACT_APP_IN_SYLVA_KEYCLOAK_HOST=/keycloak +REACT_APP_IN_SYLVA_SEARCH_HOST=/search-api +REACT_APP_IN_SYLVA_LOGIN_HOST=/login REACT_APP_IN_SYLVA_CLIENT_ID=in-sylva.user.app REACT_APP_IN_SYLVA_GRANT_TYPE=password REACT_APP_IN_SYLVA_REALM=in-sylva diff --git a/search/nginx/nginx.conf b/search/nginx/nginx.conf index 5af0d8d..c965d9a 100644 --- a/search/nginx/nginx.conf +++ b/search/nginx/nginx.conf @@ -32,7 +32,7 @@ server { listen 3001; listen [::]:3001; - server_name w3.avignon.inra.fr/bas_insylva/search/; + server_name -; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr;