Skip to content

Commit fa2f02a

Browse files
committedAug 9, 2021
wire up ui and edge servers
1 parent bafa998 commit fa2f02a

File tree

4 files changed

+135
-11207
lines changed

4 files changed

+135
-11207
lines changed
 

‎api/package-lock.json

+20-11,207
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docker-compose.yml

+27
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,30 @@ services:
4646
command: ["/wait-for-it.sh", "db:5432", "--", "npm", "run", "develop"]
4747
ports:
4848
- 8080:8080
49+
50+
ui:
51+
image: node:14-buster
52+
hostname: ui
53+
tty: true
54+
environment:
55+
TERM: "xterm-256color"
56+
NODE_ENV: "development"
57+
volumes:
58+
- ./ui:/srv/ui:delegated
59+
- .git:/srv/ui/.git:delegated
60+
- ui_node_modules:/srv/ui/node_modules:delegated
61+
working_dir: /srv/ui
62+
command: ["npm", "run", "develop"]
63+
64+
edge:
65+
image: nginx:latest
66+
hostname: edge
67+
tty: true
68+
environment:
69+
TERM: "xterm-256color"
70+
volumes:
71+
- ./nginx.conf:/etc/nginx/conf.d/default.conf
72+
- ./scripts/wait-for-it.sh:/wait-for-it.sh
73+
command: ["/wait-for-it.sh", "app:8080", "-t", "10", "--", "nginx", "-g", "daemon off;"]
74+
ports:
75+
- 9000:9000

‎nginx.conf

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
upstream api_socket_nodes {
2+
ip_hash;
3+
server api:8080;
4+
}
5+
server {
6+
resolver 127.0.0.11 valid=30s;
7+
listen 9000;
8+
listen [::]:9000;
9+
server_name localhost;
10+
error_log off;
11+
access_log off;
12+
13+
gzip on;
14+
gzip_min_length 1000;
15+
gzip_proxied any;
16+
gzip_types text/plain application/json;
17+
18+
19+
set $ui ui;
20+
set $api api;
21+
22+
#charset koi8-r;
23+
#access_log /var/log/nginx/host.access.log main;
24+
25+
location / {
26+
# add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
27+
proxy_pass_header Content-Type;
28+
proxy_set_header X-Forwarded-For $remote_addr;
29+
proxy_set_header X-Real-IP $remote_addr;
30+
proxy_set_header Host $host;
31+
proxy_redirect off;
32+
proxy_http_version 1.1;
33+
proxy_set_header Upgrade $http_upgrade;
34+
proxy_set_header Connection "upgrade";
35+
proxy_pass http://$ui:9000;
36+
}
37+
38+
location ~ ^/api/(.*) {
39+
add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
40+
proxy_set_header X-Forwarded-For $remote_addr;
41+
proxy_set_header X-Real-IP $remote_addr;
42+
proxy_set_header Host $host;
43+
proxy_redirect off;
44+
proxy_http_version 1.1;
45+
proxy_set_header Upgrade $http_upgrade;
46+
proxy_set_header Connection "upgrade";
47+
proxy_send_timeout 120;
48+
proxy_read_timeout 120;
49+
send_timeout 120;
50+
proxy_pass http://$api:8080/$1$is_args$args;
51+
}
52+
53+
location /socket.io/ {
54+
proxy_http_version 1.1;
55+
proxy_redirect off;
56+
proxy_set_header Upgrade $http_upgrade;
57+
proxy_set_header Connection "upgrade";
58+
proxy_set_header Host $host;
59+
proxy_set_header X-Real-IP $remote_addr;
60+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
61+
proxy_pass http://api_socket_nodes/socket.io/;
62+
}
63+
64+
#error_page 404 /404.html;
65+
66+
# redirect server error pages to the static page /50x.html
67+
#
68+
error_page 500 502 503 504 /50x.html;
69+
location = /50x.html {
70+
root /usr/share/nginx/html;
71+
}
72+
}

‎scripts/wait-for-postgres.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
if [ "$(which psql)" != 0 ] ; then
6+
apt-get update && apt-get install -y postgresql-client
7+
fi
8+
cmd="$@"
9+
10+
until PGPASSWORD=$DB_PASSWORD psql -h "$DB_HOST" -U "$DB_USER" postgres -c '\q'; do
11+
>&2 echo "Postgres is unavailable - sleeping"
12+
sleep 1
13+
done
14+
15+
>&2 echo "Postgres is up - executing command"
16+
exec $cmd

0 commit comments

Comments
 (0)
Please sign in to comment.