Skip to content

Instantly share code, notes, and snippets.

@prince-neres
Created September 17, 2024 18:39
Show Gist options
  • Select an option

  • Save prince-neres/7238a629fd3fe78452c4ba003eeccf8e to your computer and use it in GitHub Desktop.

Select an option

Save prince-neres/7238a629fd3fe78452c4ba003eeccf8e to your computer and use it in GitHub Desktop.
liferay-with-loadbalancer-docker-compose
POSTGRES_USER=liferay_user
POSTGRES_PASSWORD=liferay_password
POSTGRES_DB=liferay_db
version: "3.9"
services:
postgres:
image: postgres:15.1
container_name: postgres
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
- postgres-data:/var/lib/postgresql/data
networks:
- liferay-network
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5
liferay-node1:
image: liferay/portal:latest
container_name: liferay-node1
environment:
- LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_DRIVER_UPPERCASEC_LASS_UPPERCASEN_AME=org.postgresql.Driver
- LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_URL=jdbc:postgresql://postgres:5432/${POSTGRES_DB}?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
- LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_USERNAME=${POSTGRES_USER}
- LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_PASSWORD=${POSTGRES_PASSWORD}
- LIFERAY_CLUSTER_PERIOD_LINK_PERIOD_ENABLED=true
- LIFERAY_CLUSTER_PERIOD_LINK_PERIOD_CHANNEL_PERIOD_LOGIC_PERIOD_NAME_PERIOD_CONTROL=control-channel-logic-name-1
- LIFERAY_CLUSTER_PERIOD_LINK_PERIOD_CHANNEL_PERIOD_LOGIC_PERIOD_NAME_PERIOD_TRANSPORT_PERIOD_NUMBER0=transport-channel-logic-name-1
- LIFERAY_CLUSTER_PERIOD_LINK_PERIOD_AUTODETECT_PERIOD_ADDRESS=postgres:5432
- LIFERAY_WEB_PERIOD_SERVER_PERIOD_DISPLAY_PERIOD_NODE=true
volumes:
- liferay-node1-data:/opt/liferay/data
- ./configs:/opt/liferay/osgi/configs
networks:
- liferay-network
ports:
- "8080:8080"
depends_on:
postgres:
condition: service_healthy
es-node1:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8080 || exit 1"]
interval: 30s
timeout: 10s
retries: 5
start_period: 120s
deploy:
resources:
limits:
cpus: "1.0"
memory: 2G
liferay-node2:
image: liferay/portal:latest
container_name: liferay-node2
environment:
- LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_DRIVER_UPPERCASEC_LASS_UPPERCASEN_AME=org.postgresql.Driver
- LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_URL=jdbc:postgresql://postgres:5432/${POSTGRES_DB}?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
- LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_USERNAME=${POSTGRES_USER}
- LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_PASSWORD=${POSTGRES_PASSWORD}
- LIFERAY_CLUSTER_PERIOD_LINK_PERIOD_ENABLED=true
- LIFERAY_CLUSTER_PERIOD_LINK_PERIOD_CHANNEL_PERIOD_LOGIC_PERIOD_NAME_PERIOD_CONTROL=control-channel-logic-name-2
- LIFERAY_CLUSTER_PERIOD_LINK_PERIOD_CHANNEL_PERIOD_LOGIC_PERIOD_NAME_PERIOD_TRANSPORT_PERIOD_NUMBER0=transport-channel-logic-name-2
- LIFERAY_CLUSTER_PERIOD_LINK_PERIOD_AUTODETECT_PERIOD_ADDRESS=postgres:5432
- LIFERAY_WEB_PERIOD_SERVER_PERIOD_DISPLAY_PERIOD_NODE=true
volumes:
- liferay-node2-data:/opt/liferay/data
- ./configs:/opt/liferay/osgi/configs
networks:
- liferay-network
ports:
- "9080:8080"
depends_on:
postgres:
condition: service_healthy
es-node1:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:9080 || exit 1"]
interval: 30s
timeout: 10s
retries: 5
start_period: 120s
deploy:
resources:
limits:
cpus: "1.0"
memory: 2G
nginx:
image: nginx:latest
container_name: nginx
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
ports:
- "80:80"
depends_on:
- liferay-node1
- liferay-node2
networks:
- liferay-network
es-node1:
image: "elasticsearch:7.17.16"
container_name: es-node1
environment:
- node.name=es-node1
- cluster.name=es-cluster
- node.max_local_storage_nodes=2
- discovery.seed_hosts=es-node2
- cluster.initial_master_nodes=es-node1,es-node2
- xpack.security.enabled=false
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
init: true
volumes:
- es-node1-data:/usr/share/elasticsearch/data
command: >
sh -c "
cd /usr/share/elasticsearch/bin;
if [ ! -d '/usr/share/elasticsearch/plugins/analysis-icu' ]; then ./elasticsearch-plugin install analysis-icu; fi;
if [ ! -d '/usr/share/elasticsearch/plugins/analysis-kuromoji' ]; then ./elasticsearch-plugin install analysis-kuromoji; fi;
if [ ! -d '/usr/share/elasticsearch/plugins/analysis-smartcn' ]; then ./elasticsearch-plugin install analysis-smartcn; fi;
if [ ! -d '/usr/share/elasticsearch/plugins/analysis-stempel' ]; then ./elasticsearch-plugin install analysis-stempel; fi;
/usr/local/bin/docker-entrypoint.sh;
"
healthcheck:
test:
[
"CMD-SHELL",
"curl http://localhost:9200/_cluster/health | grep -qiE 'green|yellow'",
]
interval: 30s
timeout: 10s
start_period: 30s
retries: 5
ports:
- "9200:9200"
deploy:
resources:
limits:
cpus: "1.0"
memory: 1G
networks:
- liferay-network
es-node2:
image: "elasticsearch:7.17.16"
container_name: es-node2
environment:
- node.name=es-node2
- cluster.name=es-cluster
- node.max_local_storage_nodes=2
- discovery.seed_hosts=es-node1
- cluster.initial_master_nodes=es-node1,es-node2
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- xpack.security.enabled=false
init: true
volumes:
- es-node2-data:/usr/share/elasticsearch/data
command: >
sh -c "
cd /usr/share/elasticsearch/bin;
if [ ! -d '/usr/share/elasticsearch/plugins/analysis-icu' ]; then ./elasticsearch-plugin install analysis-icu; fi;
if [ ! -d '/usr/share/elasticsearch/plugins/analysis-kuromoji' ]; then ./elasticsearch-plugin install analysis-kuromoji; fi;
if [ ! -d '/usr/share/elasticsearch/plugins/analysis-smartcn' ]; then ./elasticsearch-plugin install analysis-smartcn; fi;
if [ ! -d '/usr/share/elasticsearch/plugins/analysis-stempel' ]; then ./elasticsearch-plugin install analysis-stempel; fi;
/usr/local/bin/docker-entrypoint.sh;
"
networks:
- liferay-network
deploy:
resources:
limits:
cpus: "1.0"
memory: 1G
networks:
liferay-network:
driver: bridge
volumes:
postgres-data:
liferay-node1-data:
liferay-node2-data:
es-node1-data:
es-node2-data:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment