build: move worker to different process

This commit is contained in:
pablohashescobar 2022-12-09 21:09:54 +05:30
parent b081c36a97
commit 9afe196024
6 changed files with 36 additions and 122 deletions

View File

@ -2,5 +2,4 @@
set -e
python manage.py migrate
python manage.py rqworker &
exec gunicorn plane.wsgi -k gthread --workers 8 --bind 0.0.0.0:8000 --config gunicorn.config.py --max-requests 10000 --max-requests-jitter 1000 --access-logfile -

View File

@ -17,8 +17,9 @@ services:
restart: on-failure
command: redis-server --maxmemory-policy allkeys-lru --maxmemory 200mb
plane_web:
container_name: plane_web
plane-web:
image: plane-web
container_name: plane-frontend
build:
context: .
dockerfile: ./apps/app/Dockerfile.web
@ -31,8 +32,9 @@ services:
- 3000:3000
plane_api:
container_name: plane_api
plane-api:
image: plane-api
container_name: plane-backend
build:
context: ./apiserver
dockerfile: Dockerfile.api
@ -65,16 +67,31 @@ services:
- db
- redis
nginx:
build:
context: ./nginx
dockerfile: Dockerfile
restart: unless-stopped
ports:
- 80:80
plane-worker:
image: plane-api
depends_on:
- plane_api
- plane_web
- redis
command: python manage.py rqworker
links:
- redis
environment:
SENTRY_DSN: $SENTRY_DSN
WEB_URL: $WEB_URL
PGUSER: plane
PGPASSWORD: plane
PGHOST: db
REDIS_URL: 'redis://redis:6379/'
REDIS_HOST: redis
REDIS_PORT: 6379
SECRET_KEY: $SECRET_KEY
AWS_REGION: $AWS_REGION
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_S3_BUCKET_NAME: $AWS_S3_BUCKET_NAME
EMAIL_HOST: $EMAIL_HOST
EMAIL_HOST_USER: $EMAIL_HOST_USER
EMAIL_HOST_PASSWORD: $EMAIL_HOST_PASSWORD
volumes:
postgres-data:

View File

@ -8,12 +8,13 @@ setup:
env_file: .env
build:
docker:
plane_web: ./apps/app/Dockerfile.web
plane_api: ./apiserver/Dockerfile.api
plane-frontend: ./apps/app/Dockerfile.web
plane-backend: ./apiserver/Dockerfile.api
release:
plane_api: python manage.py migrate
plane-backend: python manage.py migrate
run:
plane_web: node apps/app/server.js
plane_api: ./apiserver/bin/takeoff
plane-frontend: node apps/app/server.js
plane-backend: ./apiserver/bin/takeoff
plane-worker: python manage.py rqworker

View File

@ -1,4 +0,0 @@
FROM nginx:1.23.2-alpine
RUN rm /etc/nginx/conf.d/default.conf
COPY /dev.conf /etc/nginx/conf.d

View File

@ -1,27 +0,0 @@
server {
listen 80;
location / {
proxy_pass http://plane_web:3000;
proxy_redirect default;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /api {
proxy_pass http://plane_api:8000;
proxy_redirect default;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

View File

@ -1,72 +0,0 @@
## Version 2018/04/07 - Changelog: https://github.com/linuxserver/docker-letsencrypt/commits/master/root/defaults/nginx.conf
user abc;
worker_processes 4;
pid /run/nginx.pid;
include /etc/nginx/modules/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
variables_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
client_max_body_size 0;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /config/log/nginx/access.log;
error_log /config/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 32 16k;
gzip_http_version 1.1;
gzip_min_length 250;
gzip_types image/jpeg image/bmp image/svg+xml text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon;
# security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
ssl_prefer_server_ciphers on;
include /etc/nginx/conf.d/*.conf;
include /config/nginx/site-confs/*;
}
daemon off;