-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from tutorcruncher/nginx-simplification
simplifying deploy with one fewer container
- Loading branch information
Showing
11 changed files
with
143 additions
and
173 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,21 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
THIS_DIR=$(dirname "$0") | ||
eval "${THIS_DIR}/compose pull js backend web" | ||
# NOTICE: by default this doesn't build nginx/prod, you need to add --build for that | ||
|
||
echo "" | ||
echo "================================================================================" | ||
echo "copying nginx and js files to machine..." | ||
|
||
docker-machine scp -r -d $THIS_DIR/../nginx/prod/ $DOCKER_MACHINE_NAME:/home/ubuntu/nginx-conf/ | ||
docker-machine scp -r -d $THIS_DIR/../js/build/ $DOCKER_MACHINE_NAME:/home/ubuntu/js-src/ | ||
|
||
echo "" | ||
echo "================================================================================" | ||
echo "pulling new images..." | ||
|
||
eval "${THIS_DIR}/compose pull backend web" | ||
|
||
echo "" | ||
echo "================================================================================" | ||
echo "deploying new build..." | ||
eval "${THIS_DIR}/compose up -d $@" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
echo "================================================================================" | ||
echo "building js..." | ||
cd js | ||
yarn build | ||
cd .. | ||
echo "================================================================================" | ||
echo "building js done" | ||
|
||
echo "" | ||
echo "================================================================================" | ||
echo "copying js files to machine..." | ||
|
||
docker-machine scp -r -d js/build/ $DOCKER_MACHINE_NAME:/home/ubuntu/js-src/ | ||
|
||
echo "" | ||
echo "================================================================================" | ||
echo "restarting nginx..." | ||
docker-compose $(docker-machine config $DOCKER_MACHINE_NAME) restart nginx |
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
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,47 @@ | ||
worker_processes 1; | ||
|
||
user nobody nogroup; | ||
pid /tmp/nginx.pid; | ||
error_log /dev/stdout crit; | ||
|
||
events { | ||
worker_connections 1024; # increase if you have lots of clients | ||
accept_mutex off; # set to 'on' if nginx worker_processes > 1 | ||
use epoll; | ||
log_format custom '$remote_addr request="$request" status=$status time=${request_time}s ' | ||
'request_size=$request_length response_size=$body_bytes_sent ' | ||
'referrer="$http_referer"'; | ||
access_log /dev/stdout custom; | ||
|
||
upstream app_server { | ||
# fail_timeout=0 means we always retry an upstream event if it failed | ||
# to return a good HTTP response | ||
# for a TCP configuration | ||
server web:8000 fail_timeout=0; | ||
} | ||
|
||
http { | ||
include mime.types; | ||
# fallback in case we can't determine a type | ||
default_type application/octet-stream; | ||
|
||
log_format custom '$remote_addr request="$request" status=$status time=${request_time}s ' | ||
'request_size=$request_length response_size=$body_bytes_sent ' | ||
'referrer="$http_referer"'; | ||
access_log /dev/stdout custom; | ||
sendfile on; | ||
|
||
upstream app_server { | ||
# fail_timeout=0 means we always retry an upstream event if it failed | ||
# to return a good HTTP response | ||
# for a TCP configuration | ||
server web:8000 fail_timeout=0; | ||
} | ||
|
||
upstream js_server { | ||
server js:80 fail_timeout=0; | ||
} | ||
|
||
server { | ||
listen 80 default_server; | ||
server { | ||
listen 80 default_server; | ||
|
||
client_max_body_size 4G; | ||
client_max_body_size 1G; | ||
|
||
keepalive_timeout 5; | ||
keepalive_timeout 5; | ||
|
||
location /api/ { | ||
proxy_set_header Host $http_host; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_http_version 1.1; | ||
proxy_set_header Connection "upgrade"; | ||
proxy_redirect off; | ||
location /api/ { | ||
proxy_set_header Host $http_host; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_http_version 1.1; | ||
proxy_set_header Connection "upgrade"; | ||
proxy_redirect off; | ||
|
||
# 30 will mean websocket connections disconnect, | ||
# this is intentional, ws clients should be resilient enough to reconnect | ||
# less than in prod to easier testing | ||
proxy_send_timeout 30; | ||
proxy_read_timeout 30; | ||
proxy_connect_timeout 3; | ||
# 30 will mean websocket connections disconnect, | ||
# this is intentional, ws clients should be resilient enough to reconnect | ||
# less than in prod to easier testing | ||
proxy_send_timeout 30; | ||
proxy_read_timeout 30; | ||
proxy_connect_timeout 3; | ||
|
||
proxy_pass http://app_server; | ||
} | ||
proxy_pass http://app_server; | ||
} | ||
|
||
location /pgweb/ { | ||
access_log off; | ||
rewrite /pgweb(/.*) $1 break; | ||
proxy_pass http://pgweb; | ||
} | ||
location /pgweb/ { | ||
access_log off; | ||
rewrite /pgweb(/.*) $1 break; | ||
proxy_pass http://pgweb; | ||
} | ||
|
||
location / { | ||
proxy_redirect off; | ||
proxy_pass http://js_server; | ||
} | ||
location / { | ||
alias /js-src/; | ||
try_files $uri /index.html =404; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.