Skip to content

Commit

Permalink
Backport preprod docker files into main
Browse files Browse the repository at this point in the history
Signed-off-by: Raphaël Tournoy <[email protected]>
  • Loading branch information
rtournoy committed Sep 24, 2024
1 parent 236f651 commit ada5f36
Show file tree
Hide file tree
Showing 19 changed files with 2,131 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ assets/node_modules/

#PHPunit
/.phpunit.result.cache
/tmp/
/docker-compose.override.yml
/.user.ini
/logs/
76 changes: 76 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
DOCKER_COMPOSE:= docker compose
CNTR_NAME_SOLR := solr
CNTR_NAME_PHP := php-fpm
CNTR_APP_DIR := /var/www/htdocs
CNTR_APP_USER := www-data

SOLR_COLLECTION_CONFIG := /opt/configsets/episciences
MYSQL_CONNECT_EPISCIENCES:= mysql -u root -proot -h 127.0.0.1 -P 33060 episciences
MYSQL_CONNECT_AUTH:= mysql -u root -proot -h 127.0.0.1 -P 33062 cas_users

.PHONY: build up down collection index clean help

help: ## Display this help
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*##' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf "%-30s %s\n", $$1, $$2}'

build: ## Build the docker containers
$(DOCKER_COMPOSE) build

up: ## Start all the docker containers
$(DOCKER_COMPOSE) up -d
@echo "Make sure you have [127.0.0.1 localhost dev.episciences.org oai-dev.episciences.org data-dev.episciences.org] in /etc/hosts"
@echo "Journal : http://dev.episciences.org/"
@echo "OAI-PMH : http://oai-dev.episciences.org/"
@echo "Data : http://data-dev.episciences.org/"
@echo "PhpMyAdmin : http://localhost:8001/"
@echo "Apache Solr : http://localhost:8983/solr"


down: ## Stop the docker containers and remove orphans
$(DOCKER_COMPOSE) down --remove-orphans

collection: up ## Create the Solr collection after starting the containers
@echo "Waiting for Solr container to be ready..."
@docker exec $(CNTR_NAME_SOLR) bash -c "until curl -s http://localhost:8983/solr; do sleep 1; done"
@echo "Solr container is ready. Creating 'episciences' collection..."
@docker exec $(CNTR_NAME_SOLR) solr create_collection -c episciences -d $(SOLR_COLLECTION_CONFIG)

index: ## Index the content into Solr
@echo "Indexing all content"
$(DOCKER_COMPOSE) exec -u $(CNTR_APP_USER) -w $(CNTR_APP_DIR) php-fpm php scripts/solr/solrJob.php -D % -v

clean: down ## Clean up unused docker resources
#docker stop $(docker ps -a -q)
docker system prune -f

load-db-episciences: ## Load an SQL dump from ./tmp/episciences.sql
$(MYSQL_CONNECT_EPISCIENCES) < ./tmp/episciences.sql

load-db-auth: ## Load an SQL dump from ./tmp/cas_users.sql
$(MYSQL_CONNECT_AUTH) < ./tmp/cas_users.sql

send-mails:
$(DOCKER_COMPOSE) exec -u $(CNTR_APP_USER) -w $(CNTR_APP_DIR) $(CNTR_NAME_PHP) php scripts/send_mails.php

composer-install: ## Install composer dependencies
$(DOCKER_COMPOSE) exec -w $(CNTR_APP_DIR) $(CNTR_NAME_PHP) composer install --no-interaction --prefer-dist --optimize-autoloader

composer-update: ## Update composer dependencies
$(DOCKER_COMPOSE) exec -w $(CNTR_APP_DIR) $(CNTR_NAME_PHP) composer update --no-interaction --prefer-dist --optimize-autoloader

yarn-encore-production: ## yarn encore production
$(DOCKER_COMPOSE) exec -w $(CNTR_APP_DIR) $(CNTR_NAME_PHP) yarn encore production

restart-httpd: ## Restart Apache httpd
$(DOCKER_COMPOSE) restart httpd

restart-php: ## Restart PHP-FPM Container
$(DOCKER_COMPOSE) restart $(CNTR_NAME_PHP)

merge-pdf-volume: ## merge all pdf from a vid into one pdf
$(DOCKER_COMPOSE) exec -u $(CNTR_APP_USER) -w $(CNTR_APP_DIR) $(CNTR_NAME_PHP) php scripts/mergePdfVol.php --rvcode=$(rvcode) --ignorecache=$(or $(ignorecache),0) --removecache=$(or $(removecache),0)


can-i-use-update: ## To be launched when Browserslist: caniuse-lite is outdated.
npx update-browserslist-db@latest
126 changes: 126 additions & 0 deletions docker-compose.override.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
services:
solr:
image: solr:9.6
container_name: solr
ports:
- "8983:8983"
networks:
- search
environment:
ZK_HOST: "zoo:2181"
depends_on:
- zoo
volumes:
- solr_data:/var/solr
- type: bind
source: ./src/solr
target: /opt/configsets
read_only: true

zoo:
image: zookeeper:3.9
container_name: zoo
networks:
- search
environment:
ZOO_4LW_COMMANDS_WHITELIST: "mntr,conf,ruok"

db-episciences:
image: "mysql:8.4"
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
container_name: 'db-episciences'
expose:
- "3306"
ports:
- "33060:3306"
volumes:
- /var/lib/mysql
- type: bind
source: ./src/mysql/docker/episciences/episciences.sql
target: /docker-entrypoint-initdb.d/init.sql
env_file:
- src/mysql/docker/episciences/mysql.env
networks:
- search

db-indexing:
image: "mysql:8.4"
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
container_name: 'db-indexing'
expose:
- "3306"
ports:
- "33061:3306"
volumes:
- mysql-db-indexing:/var/lib/mysql
- type: bind
source: ./src/mysql/docker/solr/solr_index_queue.sql
target: /docker-entrypoint-initdb.d/init.sql
env_file:
- src/mysql/docker/solr/mysql.env
networks:
- search

db-auth:
image: "mysql:8.4"
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
container_name: 'db-auth'
expose:
- "3306"
ports:
- "33062:3306"
volumes:
- mysql-db-auth:/var/lib/mysql
- type: bind
source: ./src/mysql/docker/auth/cas_users.sql
target: /docker-entrypoint-initdb.d/init.sql
env_file:
- src/mysql/docker/auth/mysql.env
networks:
- search

pma:
container_name: 'db-phpmyadmin'
image: "phpmyadmin:latest"
environment:
- "PMA_PMADB=pma"
- "PMA_CONTROLUSER=root"
- "PMA_CONTROLPASS=root"
- "PMA_QUERYHISTORYDB=true"
- "PMA_USER=root"
- "PMA_PASSWORD=root"
- "PMA_ARBITRARY=1"
- "PMA_HOSTS=db-episciences,db-indexing,db-auth"
- "PMA_VERBOSES=episciences,indexing,auth"
- "UPLOAD_LIMIT=2G"
- "MEMORY_LIMIT=1G"
ports:
- "8001:80"
depends_on:
- db-episciences
- db-indexing
- db-auth
links:
- db-episciences
- db-indexing
- db-auth
networks:
- search


networks:
search:
driver: bridge

volumes:
mysql-db-episciences:
mysql-db-indexing:
mysql-db-auth:
solr_data:

175 changes: 175 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
services:
httpd:
image: httpd:2.4-bookworm
container_name: httpd
build:
context: .
dockerfile: src/apache/Dockerfile
restart: always
volumes:
- ./src/apache/vhost.conf:/usr/local/apache2/conf/extra/episciences.conf
- .:/var/www/htdocs
- ./data:/var/www/data
- ./cache:/var/www/cache
- ./logs:/var/www/logs
ports:
- "80:80" # Apache listens on port 80 internally, mapped to 8888 on the host
depends_on:
- php-fpm
- db-episciences
- db-indexing
- db-auth
networks:
- epi-network
command: >
/bin/sh -c "chown -R www-data:www-data /var/www/data /var/www/cache /var/www/logs && httpd-foreground"
php-fpm:
container_name: php-fpm
build:
context: .
dockerfile: src/php-fpm/Dockerfile
ports:
- "9003:9003" # Xdebug
restart: always
volumes:
- .:/var/www/htdocs
- ./data:/var/www/data
- ./cache:/var/www/cache
- ./logs:/var/www/logs
- ./src/php-fpm/php-fpm.conf:/usr/local/etc/php-fpm.d/zz-custom.conf
- ./logs/xdebug.log:/var/www/logs
environment:
- PHP_FPM_LISTEN_PORT=9000
- XDEBUG_MODE=debug
- XDEBUG_CONFIG=client_host=host.docker.internal client_port=9003
expose:
- "9000" # Expose internal port 9000
networks:
- epi-network

solr:
image: solr:9.6
container_name: solr
ports:
- "8983:8983"
networks:
- epi-network
environment:
ZK_HOST: "zoo:2181"
depends_on:
- zoo
volumes:
- solr_data:/var/solr
- type: bind
source: ./src/solr
target: /opt/configsets
read_only: true

zoo:
image: zookeeper:3.9
container_name: zoo
networks:
- epi-network
environment:
ZOO_4LW_COMMANDS_WHITELIST: "mntr,conf,ruok"

db-episciences:
image: "mysql:8.4"
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
container_name: 'db-episciences'
expose:
- "3306"
ports:
- "33060:3306"
volumes:
- mysql-db-episciences:/var/lib/mysql
- type: bind
source: ./src/mysql/docker/episciences/episciences.sql
target: /docker-entrypoint-initdb.d/init.sql
env_file:
- src/mysql/docker/episciences/mysql.env
networks:
- epi-network

db-indexing:
image: "mysql:8.4"
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
container_name: 'db-indexing'
expose:
- "3306"
ports:
- "33061:3306"
volumes:
- mysql-db-indexing:/var/lib/mysql
- type: bind
source: ./src/mysql/docker/solr/solr_index_queue.sql
target: /docker-entrypoint-initdb.d/init.sql
env_file:
- src/mysql/docker/solr/mysql.env
networks:
- epi-network

db-auth:
image: "mysql:8.4"
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
container_name: 'db-auth'
expose:
- "3306"
ports:
- "33062:3306"
volumes:
- mysql-db-auth:/var/lib/mysql
- type: bind
source: ./src/mysql/docker/auth/cas_users.sql
target: /docker-entrypoint-initdb.d/init.sql
env_file:
- src/mysql/docker/auth/mysql.env
networks:
- epi-network

pma:
container_name: 'db-phpmyadmin'
image: "phpmyadmin:latest"
environment:
- "PMA_PMADB=pma"
- "PMA_CONTROLUSER=root"
- "PMA_CONTROLPASS=root"
- "PMA_QUERYHISTORYDB=true"
- "PMA_USER=root"
- "PMA_PASSWORD=root"
- "PMA_ARBITRARY=1"
- "PMA_HOSTS=db-episciences,db-indexing,db-auth"
- "PMA_VERBOSES=episciences,indexing,auth"
- "UPLOAD_LIMIT=2G"
- "MEMORY_LIMIT=1G"
ports:
- "8001:80"
depends_on:
- db-episciences
- db-indexing
- db-auth
links:
- db-episciences
- db-indexing
- db-auth
networks:
- epi-network

networks:
epi-network:
driver: bridge

volumes:
mysql-db-episciences:
mysql-db-indexing:
mysql-db-auth:
solr_data:

Loading

0 comments on commit ada5f36

Please sign in to comment.