Commit 8bf42768 authored by Guy Thouret's avatar Guy Thouret

(feat) Alterations to local dev stack to support Angular Hot Module Reload - front#2099

parent 8b7f0c0b
FROM nginx:1.13-alpine
WORKDIR /var/www/Minds
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/nginx.conf
COPY ./dev.conf /etc/nginx/conf.d/dev.conf
COPY dev.conf /etc/nginx/conf.d/dev.conf
COPY nginx_entrypoint_dev.sh /nginx_entrypoint_dev.sh
ENTRYPOINT /nginx_entrypoint_dev.sh
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen [::]:80 default ipv6only=on;
......@@ -98,4 +103,22 @@ server {
log_not_found off;
deny all;
}
}
\ No newline at end of file
# Proxy to Angular dev server (hmr websocket)
location ^~ /sockjs-node/ {
proxy_pass http://host.docker.internal:4200;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_max_temp_file_size 0;
}
# Proxy to Angular dev server (assets)
location ^~ /en/ {
proxy_pass http://host.docker.internal:4200;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_max_temp_file_size 0;
}
}
#!/bin/sh
#
# "Docker For Mac" and "Docker For Windows" resolve 'host.docker.internal' to the host IP.
# On other platforms we need to get the default route IP and add a resolvable entry for this
# so that we can reverse proxy to Angular Dev Server running on the host machine.
#
add_host_entry() {
ip -4 route list match 0/0 | awk '{print $3" host.docker.internal"}' >> /etc/hosts
}
echo -n "Checking if host.docker.internal resolves..."
nslookup host.docker.internal > /dev/null 2>&1
if [ $? == 0 ]; then
echo " OK"
else
echo " FAIL"
echo -n "Adding host.docker.internal to /etc/hosts..."
add_host_entry
if [ $? == 0 ]; then
echo " OK";
else
echo " FAIL";
fi
fi
echo "Starting Nginx..."
nginx -g "daemon off;"
......@@ -94,15 +94,14 @@ services:
- elasticsearch
- rabbitmq
- redis
- sync-front
- sync-engine
networks:
- app
volumes:
## The following is for development environments only. Comment out on production. ##
- front-dir:/var/www/Minds/front:delegated
- engine-dir:/var/www/Minds/engine:delegated
- keys:/.dev:delegated
- ./front/:/var/www/Minds/front:delegated
- engine-dir:/var/www/Minds/engine
- keys:/.dev
runners:
build:
......@@ -117,7 +116,7 @@ services:
networks:
- app
volumes:
- front-dir:/var/www/Minds/front:delegated
- ./front/:/var/www/Minds/front:delegated
- "./plugins/:/var/www/Minds/plugins"
- "./languages/:/var/www/Minds/languages"
- engine-dir:/var/www/Minds/engine:delegated
......@@ -134,22 +133,7 @@ services:
networks:
- app
volumes:
## The following is for development environments only. Comment out on production. ##
- front-dir:/var/www/Minds/front:delegated
sync-front:
build:
context: ./containers/alpine-rsync
command: [
'watch',
'-n5',
'rsync -avz --no-perms --progress /front-dir-host/dist/ /front-dir/dist/'
]
networks:
- app
volumes:
- front-dir:/front-dir
- ./front:/front-dir-host
- ./front/:/var/www/Minds/front:delegated
sync-engine:
build:
......@@ -200,17 +184,6 @@ services:
depends_on:
- elasticsearch
front-build:
image: markharding/minds-front-base
networks:
- app
entrypoint:
- sh
- -c
- "cd /var/www/Minds/front && echo 'Building frontend, please wait...(this can take a long time)' && npm install && npm run postinstall && npm rebuild node-sass && npm run build-dev && touch /var/www/Minds/front/dist/index.php"
volumes:
- "./front/:/var/www/Minds/front"
sockets:
image: minds/sockets
environment:
......@@ -232,7 +205,6 @@ volumes:
cassandra-data:
elasticsearch-data:
keys:
front-dir:
engine-dir:
networks:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment