Commit a0815dd9 authored by Mark Harding's avatar Mark Harding

Merge branch 'feat/angular-hmr' into 'master'

Alterations to local dev stack to support Angular Hot Module Reload

See merge request !171
parents 8b7f0c0b 8bf42768
FROM nginx:1.13-alpine FROM nginx:1.13-alpine
WORKDIR /var/www/Minds
RUN rm /etc/nginx/conf.d/default.conf RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/nginx.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 { server {
listen 80; listen 80;
listen [::]:80 default ipv6only=on; listen [::]:80 default ipv6only=on;
...@@ -98,4 +103,22 @@ server { ...@@ -98,4 +103,22 @@ server {
log_not_found off; log_not_found off;
deny all; 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: ...@@ -94,15 +94,14 @@ services:
- elasticsearch - elasticsearch
- rabbitmq - rabbitmq
- redis - redis
- sync-front
- sync-engine - sync-engine
networks: networks:
- app - app
volumes: volumes:
## The following is for development environments only. Comment out on production. ## ## The following is for development environments only. Comment out on production. ##
- front-dir:/var/www/Minds/front:delegated - ./front/:/var/www/Minds/front:delegated
- engine-dir:/var/www/Minds/engine:delegated - engine-dir:/var/www/Minds/engine
- keys:/.dev:delegated - keys:/.dev
runners: runners:
build: build:
...@@ -117,7 +116,7 @@ services: ...@@ -117,7 +116,7 @@ services:
networks: networks:
- app - app
volumes: volumes:
- front-dir:/var/www/Minds/front:delegated - ./front/:/var/www/Minds/front:delegated
- "./plugins/:/var/www/Minds/plugins" - "./plugins/:/var/www/Minds/plugins"
- "./languages/:/var/www/Minds/languages" - "./languages/:/var/www/Minds/languages"
- engine-dir:/var/www/Minds/engine:delegated - engine-dir:/var/www/Minds/engine:delegated
...@@ -134,22 +133,7 @@ services: ...@@ -134,22 +133,7 @@ services:
networks: networks:
- app - app
volumes: volumes:
## The following is for development environments only. Comment out on production. ## - ./front/:/var/www/Minds/front:delegated
- 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
sync-engine: sync-engine:
build: build:
...@@ -200,17 +184,6 @@ services: ...@@ -200,17 +184,6 @@ services:
depends_on: depends_on:
- elasticsearch - 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: sockets:
image: minds/sockets image: minds/sockets
environment: environment:
...@@ -232,7 +205,6 @@ volumes: ...@@ -232,7 +205,6 @@ volumes:
cassandra-data: cassandra-data:
elasticsearch-data: elasticsearch-data:
keys: keys:
front-dir:
engine-dir: engine-dir:
networks: 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