Browse Source

+ nodejs applications support with pm2 manager

* use dockerhost in xdebug3 config for php8 in workspace
* set local docker resolver for nginx
* refactored base configs (join in one base config) and better separate examples for third party services
* set default web port for inbucket to 82 instead of 9090, because last use for cockpit
master
dimti 10 months ago
parent
commit
a3f7465955
  1. 6
      .gitignore
  2. 22
      bash/pm2-restart.sh
  3. 9
      bash/tail-nginx-access-log.sh
  4. 9
      bash/tail-nginx-error-log.sh
  5. 2
      config/nginx/conf.d/vhosts.conf.example
  6. 20
      config/nginx/conf.d/z-nodejs.conf.example
  7. 29
      docker-compose.base.yml
  8. 18
      docker-compose.elastic.base.yml
  9. 2
      docker-compose.elastic.yml.example
  10. 10
      docker-compose.minio.base.yml
  11. 2
      docker-compose.minio.yml
  12. 12
      docker-compose.minio.yml.example
  13. 15
      docker-compose.nodejs.yml.example
  14. 0
      docker-compose.postgres-ui.yml.example
  15. 0
      docker-compose.redis-ui.yml.example
  16. 11
      docker-compose.redis.yml.example
  17. 0
      docker-compose.sphinxsearch.yml.example
  18. 13
      docker-compose.yml.example
  19. 5
      dockerfiles/pm2/Dockerfile
  20. 11
      dockerfiles/pm2/ecosystem.config.js
  21. 7
      dockerfiles/workspace/workspace81.Dockerfile
  22. 3
      dockerfiles/workspace/xdebug3.ini
  23. 1
      src/dockerfiles/workspace/xdebug3.ini

6
.gitignore

@ -1,6 +1,8 @@
/.idea
/dockerfiles/ypt-encoder
/docker-compose.yml
/docker-compose.elastic.yml
/docker-compose*
!/docker-compose.base.yml
!/docker-compose*.example
/docker-compose.nodejs.yml
/.env
/*.komodoproject

22
bash/pm2-restart.sh

@ -0,0 +1,22 @@
#!/bin/bash
DIR="$(realpath $(dirname "$(readlink -f "$0")")/..)"
. $DIR/bash/_docker-cmd.sh || {
echo "no docker cmd is presented" && exit 1
}
PM2_SERVICE=$1
if [[ -z "${PM2_SERVICE}" ]]; then
echo "Usage: $(basename $0) NODEJS_PROJECT_NAME"
exit 1
fi
CONTAINER=$(docker ps | grep "pm2-${PM2_SERVICE}" | awk '{print $1}')
if [[ -z "${CONTAINER}" ]]; then
echo "Unable to find container: db"
exit 1
fi
$DOCKER_CMD restart ${CONTAINER}

9
bash/tail-nginx-access-log.sh

@ -0,0 +1,9 @@
#!/bin/bash
# Not working on windows symlinks
DIR="$(realpath $(dirname "$(readlink -f "$0")")/..)"
LOG_FILE_PATH="${DIR}/log/nginx/access.log"
clear
tail -f $LOG_FILE_PATH

9
bash/tail-nginx-error-log.sh

@ -0,0 +1,9 @@
#!/bin/bash
# Not working on windows symlinks
DIR="$(realpath $(dirname "$(readlink -f "$0")")/..)"
LOG_FILE_PATH="${DIR}/log/nginx/error.log"
clear
tail -f $LOG_FILE_PATH

2
config/nginx/conf.d/vhosts.conf.example

@ -21,7 +21,7 @@ map $http_accept $webp_suffix {
"~*webp" ".webp";
}
resolver 8.8.8.8;
resolver 127.0.0.11;
map $http_host $uploads_upstream {
wordpress.local.wpstudio.ru "https://somewp.site";

20
config/nginx/conf.d/z-nodejs.conf.example

@ -0,0 +1,20 @@
map $http_host $pm2 {
someprojectone.build.local.wpstudio.ru pm2-someprojectone;
someprojecttwo.build.local.wpstudio.ru pm2-someprojecttwo;
}
server {
listen 80;
server_name
someprojectone.build.local.wpstudio.ru
someprojecttwo.build.local.wpstudio.ru
;
location / {
resolver 127.0.0.11;
proxy_pass http://$pm2:3000;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}

29
docker-compose.base.yml

@ -71,10 +71,37 @@ services:
restart: always
ports:
- "2500:2500"
- "9090:9000"
- "82:9000"
redis:
image: redis
restart: always
command: [ "redis-server", "/usr/local/etc/redis/redis.conf" ]
volumes:
- ./config/redis/redis.conf:/usr/local/etc/redis/redis.conf
elastic:
build:
context: ./dockerfiles/elastic
restart: on-failure
environment:
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
expose:
- "9200"
- "9300"
minio:
image: minio/minio:RELEASE.2020-06-12T00-06-19Z
restart: always
environment:
MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY}
MINIO_SECRET_KEY: ${MINIO_SECRET_KEY}
command: server /minio
pm2:
build:
context: ./dockerfiles/pm2
restart: always
expose:
- 3000

18
docker-compose.elastic.base.yml

@ -1,18 +0,0 @@
version: '3.6'
services:
elastic:
build:
context: ./dockerfiles/elastic
restart: on-failure
environment:
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
mem_limit: 2g
expose:
- "9200"
- "9300"

2
docker-compose.elastic.yml.example

@ -3,7 +3,7 @@ version: '3.6'
services:
elastic:
extends:
file: docker-compose.elastic.base.yml
file: docker-compose.base.yml
service: elastic
restart: always
build:

10
docker-compose.minio.base.yml

@ -1,10 +0,0 @@
version: '3.6'
services:
minio:
image: minio/minio:RELEASE.2020-06-12T00-06-19Z
restart: always
environment:
MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY}
MINIO_SECRET_KEY: ${MINIO_SECRET_KEY}
command: server /minio

2
docker-compose.minio.yml

@ -3,7 +3,7 @@ version: '3.6'
services:
minio:
extends:
file: docker-compose.minio.base.yml
file: docker-compose.base.yml
service: minio
volumes:
- minio:/minio

12
docker-compose.minio.yml.example

@ -0,0 +1,12 @@
version: '3.6'
services:
minio:
extends:
file: docker-compose.base.yml
service: minio
volumes:
- minio:/minio
volumes:
minio:

15
docker-compose.nodejs.yml.example

@ -0,0 +1,15 @@
version: '3.6'
services:
pm2-someprojectone:
extends:
file: docker-compose.base.yml
service: pm2
volumes:
- ${PROJECTS_DIR}/someprojectone/.output:/.output
pm2-someprojecttwo:
extends:
file: docker-compose.base.yml
service: pm2
volumes:
- ${PROJECTS_DIR}/someprojecttwo/.output:/.output

0
docker-compose.postgres.yml → docker-compose.postgres-ui.yml.example

0
docker-compose.redis.yml → docker-compose.redis-ui.yml.example

11
docker-compose.redis.yml.example

@ -0,0 +1,11 @@
version: '3.6'
services:
redis-someprojectone:
extends:
file: docker-compose.base.yml
service: redis
redis-someprojecttwo:
extends:
file: docker-compose.base.yml
service: redis

0
docker-compose.sphinx.yml → docker-compose.sphinxsearch.yml.example

13
docker-compose.yml.example

@ -8,7 +8,10 @@ services:
networks:
default:
aliases:
- loc.yoursite.ru
- someproject.local.wpstudio.ru
depends_on:
- php74
- php81
php74:
extends:
file: docker-compose.base.yml
@ -45,14 +48,6 @@ services:
extends:
file: docker-compose.base.yml
service: inbucket
redis:
extends:
file: docker-compose.base.yml
service: redis
redis-some:
extends:
file: docker-compose.base.yml
service: redis
volumes:
database:

5
dockerfiles/pm2/Dockerfile

@ -0,0 +1,5 @@
FROM keymetrics/pm2:18-buster
COPY ./ecosystem.config.js /ecosystem.config.js
CMD ["pm2-runtime", "start", "ecosystem.config.js"]

11
dockerfiles/pm2/ecosystem.config.js

@ -0,0 +1,11 @@
module.exports = {
apps: [
{
name: 'NuxtAppName',
port: '3000',
exec_mode: 'cluster',
instances: '2',
script: './.output/server/index.mjs',
},
],
};

7
dockerfiles/workspace/workspace81.Dockerfile

@ -70,13 +70,6 @@ ENV COMPOSER_VERSION ${COMPOSER_VERSION}
RUN composer self-update --${COMPOSER_VERSION}
###########################################################################
# xDebug (termporary):
###########################################################################
# Copy xdebug configuration for remote debugging
COPY ./xdebug3.ini /etc/php/${PHP_VERSION}/cli/conf.d/xdebug.ini
###########################################################################
# Laradock Aliases
###########################################################################

3
dockerfiles/workspace/xdebug3.ini

@ -1,3 +0,0 @@
xdebug.mode=debug
xdebug.client_host=172.18.0.1
xdebug.start_with_request=yes

1
src/dockerfiles/workspace/xdebug3.ini

@ -1,2 +1,3 @@
xdebug.mode=debug
xdebug.client_host=dockerhost
xdebug.start_with_request=yes
Loading…
Cancel
Save