Last active
May 10, 2017 11:51
-
-
Save yelizariev/a359cea062a1579c5e34bfd0c40f1201 to your computer and use it in GitHub Desktop.
How to deploy SaaS Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
#rewrite ^/.*$ https://$host$request_uri? permanent; #Uncomment this line in case you want to use https only | |
server_name NGINX_SERVER_DOMAIN; | |
include odoo_params; | |
location /longpolling { | |
proxy_pass http://SERVER_HOST:8072; | |
} | |
location / { | |
proxy_pass http://SERVER_HOST:8069; | |
} | |
location ~* /web/static/ { | |
proxy_cache_valid 200 90m; | |
proxy_buffering on; | |
expires 864000; | |
proxy_pass http://SERVER_HOST:8069; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
charset utf-8; | |
## increase proxy buffer to handle some OpenERP web requests | |
proxy_buffers 16 64k; | |
proxy_buffer_size 128k; | |
## set headers | |
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-Proto $scheme; | |
proxy_read_timeout 600s; #set centrally in nginx.conf | |
client_max_body_size 200m; | |
#general proxy settings | |
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503; | |
# by default, do not forward anything | |
proxy_redirect off; | |
proxy_buffering off; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Shared Docker Network | |
docker network create saas-demo-network | |
# ============================================= | |
# Configs | |
ODOO_MASTER_PASS=`< /dev/urandom tr -dc A-Za-z0-9 | head -c16;echo;` | |
ODOO_DOMAIN="saas-demo.local" | |
PORTAL_DB="${ODOO_DOMAIN}" | |
# ============================================= | |
# Nginx | |
# docker | |
# It uses 8080 port on host. It means, that you need another (non-docker) nginx on your server. | |
# If you don't need to have another nginx, replace 8080 to 80 | |
docker run \ | |
-p 8080:80 \ | |
--name odoo-nginx \ | |
--network=saas-demo-network \ | |
-t nginx | |
# remove default config | |
docker exec -i -t odoo-nginx rm /etc/nginx/conf.d/default.conf | |
# upload nginx_odoo_params | |
curl -s https://gist.githubusercontent.com/yelizariev/a359cea062a1579c5e34bfd0c40f1201/raw/nginx_odoo_params > odoo_params | |
docker cp odoo_params odoo-nginx:/etc/nginx/odoo_params | |
# ============================================= | |
# SaaS Portal | |
# db | |
docker run --network=saas-demo-network -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo --name db-portal postgres:9.5 | |
# local repositories | |
DOCKER_PARAMS="" | |
# local saas repo. Optional. Path before colons depends on your system. | |
DOCKER_PARAMS="$DOCKER_PARAMS -v /mnt/files/odoo/odoo-8.0/odoo-saas-tools:/mnt/addons/it-projects-llc/odoo-saas-tools" | |
# run docker | |
# TODO: switch portal version to latest | |
# TODO: don't expose ports ( requests are handled via nginx) | |
docker run \ | |
-p 8069:8069 \ | |
-p 8072:8072 \ | |
-e ODOO_MASTER_PASS=$ODOO_MASTER_PASS \ | |
-e DB_PORT_5432_TCP_ADDR=db-portal \ | |
$DOCKER_PARAMS \ | |
--name odoo-portal \ | |
--network=saas-demo-network \ | |
-t itprojectsllc/install-odoo:8.0 | |
# press Ctrl-C | |
# init saas | |
# TODO use /mnt/odoo-source/odoo-bin for odoo-10 portal | |
INIT_SAAS_TOOLS_VALUE="\ | |
--portal-create \ | |
--odoo-script=/mnt/odoo-source/openerp-server \ | |
--odoo-config=/mnt/config/odoo-server.conf \ | |
--admin-password=${ODOO_MASTER_PASS} \ | |
--portal-db-name=${PORTAL_DB} \ | |
--install-modules=saas_portal_demo \ | |
" | |
docker exec -i -u root -t odoo-portal /bin/bash -c "export INIT_SAAS_TOOLS='$INIT_SAAS_TOOLS_VALUE'; bash /install-odoo-saas.sh" | |
# nginx | |
curl -s https://gist.githubusercontent.com/yelizariev/a359cea062a1579c5e34bfd0c40f1201/raw/nginx_odoo.conf > portal.conf | |
sed -i "s/NGINX_SERVER_DOMAIN/${ODOO_DOMAIN}/g" portal.conf | |
sed -i "s/SERVER_HOST/odoo-portal/g" portal.conf | |
docker cp portal.conf odoo-nginx:/etc/nginx/conf.d/portal.conf | |
# ============================================= | |
# SaaS Server | |
# Select only one value | |
SERVER_NAME="odoo-8" ODOO_BRANCH="8.0" | |
SERVER_NAME="odoo-9" ODOO_BRANCH="9.0" | |
SERVER_NAME="odoo-10" ODOO_BRANCH="10.0" | |
# Then execute commands below. After that repeat it with another odoo version. | |
# db | |
docker run --network=saas-demo-network -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo --name db-$SERVER_NAME postgres:9.5 | |
# odoo | |
docker run \ | |
--name $SERVER_NAME \ | |
-e DB_PORT_5432_TCP_ADDR=db-$SERVER_NAME \ | |
$DOCKER_PARAMS \ | |
--network=saas-demo-network \ | |
-t itprojectsllc/install-odoo:$ODOO_BRANCH | |
# press Ctrl-C | |
# update dbfilter | |
docker exec -u root -i -t $SERVER_NAME /bin/bash -c "sed -i 's/dbfilter.*/dbfilter = ^%h$/' /mnt/config/odoo-server.conf" | |
docker restart $SERVER_NAME | |
# saas | |
# Note. For odoo 10.0+ use | |
# --odoo-script=/mnt/odoo-source/odoo-bin \ | |
INIT_SAAS_TOOLS_VALUE="\ | |
--server-create \ | |
--odoo-script=/mnt/odoo-source/openerp-server \ | |
--odoo-config=/mnt/config/odoo-server.conf \ | |
--admin-password=${ODOO_MASTER_PASS} \ | |
--portal-db-name=${PORTAL_DB} \ | |
--server-db-name=${SERVER_NAME}.${ODOO_DOMAIN} \ | |
--local-portal-host=odoo-portal \ | |
--local-server-host=${SERVER_NAME} \ | |
--install-modules=saas_server_demo \ | |
--demo-repositories=\ | |
/mnt/addons/it-projects-llc/misc-addons,\ | |
/mnt/addons/it-projects-llc/pos-addons \ | |
" | |
docker exec -u root -i -t $SERVER_NAME /bin/bash -c "export INIT_SAAS_TOOLS='$INIT_SAAS_TOOLS_VALUE'; bash /install-odoo-saas.sh" | |
# call "create demo templates" on PORTAL | |
INIT_SAAS_TOOLS_VALUE="\ | |
--odoo-script=/mnt/odoo-source/openerp-server \ | |
--odoo-config=/mnt/config/odoo-server.conf \ | |
--admin-password=${ODOO_MASTER_PASS} \ | |
--portal-db-name=${PORTAL_DB} \ | |
--server-db-name=${SERVER_NAME}.${ODOO_DOMAIN} \ | |
--create-demo-templates \ | |
" | |
docker exec -u root -i -t odoo-portal /bin/bash -c "export INIT_SAAS_TOOLS='$INIT_SAAS_TOOLS_VALUE'; bash /install-odoo-saas.sh" | |
# nginx proxing | |
curl -s https://gist.githubusercontent.com/yelizariev/a359cea062a1579c5e34bfd0c40f1201/raw/nginx_odoo.conf > nginx-${SERVER_NAME}.conf | |
sed -i "s/NGINX_SERVER_DOMAIN/.${SERVER_NAME}.${ODOO_DOMAIN}/g" nginx-${SERVER_NAME}.conf | |
sed -i "s/SERVER_HOST/${SERVER_NAME}/g" nginx-${SERVER_NAME}.conf | |
docker cp nginx-${SERVER_NAME}.conf odoo-nginx:/etc/nginx/conf.d/${SERVER_NAME}.conf | |
# ============================================= | |
# Final | |
# nginx | |
docker restart odoo-nginx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment