Skip to content

Commit

Permalink
Merge pull request #13 from Shift3/jr-windows-hot-reload
Browse files Browse the repository at this point in the history
Windows hot reload fix
  • Loading branch information
Fleury14 committed Sep 13, 2021
2 parents fe80402 + daaf5c3 commit 0e68f0f
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ This is a multi-container docker environment that utilizes Docker to create thre

## Running the project

- After cloning the repo, go into the project's root directory and run `docker-compose up`. The first time running this the server and client will both go through the build process, but this should only happen once.
- After cloning the repo, go into the project's root directory. There are two ways to run the project. Docker Desktop on Windows has some outstanding issues with file updating, so by default, the hot reloading features on the server and client will not work. The solution is to enable polling which is more CPU intensive. The two ways to run the app are:
- If you have bash installed, running `bash start.sh` will run a script that calls the correct docker command.
- If you prefer not to use bash, the correct docker command is:
- On Mac: `docker compose up`
- On Windows: `docker compose -f ./docker-compose.yml -f ./docker-compose.windows.yml up`
- The first time running this the server and client will both go through the build process, but this should only happen once.
- Your connection target on Mac and Linux is `localhost://`. For Windows users on Docker Toolbox, you will need to run `docker-machine ip` to find your address to connect to, default is `192.168.99.100:`. You will also need to edit `/application/src/private.js` and replace the `SERVER_IP` export with either the commented out line, or your own.
- Database can be found at `(target):27017`, server at `(target):4000`, client at `(target):3000`.

Expand Down
9 changes: 9 additions & 0 deletions docker-compose.windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
client:
environment:
CHOKIDAR_USEPOLLING: "true"

server:
build:
context: "./server"
dockerfile: "Dockerfile.windows"
15 changes: 15 additions & 0 deletions server/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:11

RUN ln -fs /usr/share/zoneinfo/US/Pacific-New /etc/localtime && dpkg-reconfigure -f noninteractive tzdata

WORKDIR /home/node/server

ADD "./package.json" "/home/node/server/package.json"

RUN ["npm", "install", "nodemon", "-g"]

RUN ["npm", "install", "opencollective-postinstall", "--save"]

RUN ["npm", "install", "--no-bin-links", "--no-optional"]

CMD ["npm", "run", "windows"]
1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "index.js",
"scripts": {
"start": "nodemon index.js",
"windows": "nodemon --legacy-watch index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
Expand Down
26 changes: 26 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
esac
echo ${machine}

case ${machine} in
Mac)
echo "Running Mac Startup"
docker compose up
;;
Cygwin)
echo "Running Windows Startup"
docker compose -f "./docker-compose.yml" -f "./docker-compose.windows.yml" up
;;
MinGw)
echo "Running Windows Startup"
docker compose -f "./docker-compose.yml" -f "./docker-compose.windows.yml" up
;;
esac

0 comments on commit 0e68f0f

Please sign in to comment.