From 5c1f2592716bee225a9d6ce790fe66a8c6b3d906 Mon Sep 17 00:00:00 2001 From: Daniel Gillespie Date: Sat, 6 Jan 2018 11:15:07 -0800 Subject: [PATCH 1/4] added docker and docker compose to project. updated readme. --- Dockerfile | 18 ++++++++++++++++++ README.md | 19 +++++++++++++++---- docker-compose.yml | 12 ++++++++++++ 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..089a15b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +# Official image w/ LTS support +FROM node:8 + +EXPOSE 53 +EXPOSE 80 +EXPOSE 8100 + +WORKDIR /opt/app + +COPY . /opt/app/. + +RUN rm -rf /opt/app/node_modules/ +RUN mkdir -p /opt/node_modules +RUN ln -s /opt/node_modules/ /opt/app/. + +RUN npm install + +CMD ["npm", "start"] diff --git a/README.md b/README.md index 77d9ccf..bee7f1f 100644 --- a/README.md +++ b/README.md @@ -12,15 +12,18 @@ Installation ============ -1. Install the latest version of node from [nodejs.org](https://nodejs.org) +1. Install Docker +2. Install Docker-Compose +3. Ensure Docker Has Minimum 4GB of Resources (Default 2GB) 2. Clone this repository -3. Run `npm install` +3. Run `docker-compose up` Usage ===== 1. Ensure port 53, 80, and 8100 are open on the computer running pegaswitch. -2. Start pegaswitch with `sudo node start.js` +2. PegaSwitch will start automatically when you start the docker container. +3. To run PegaSwitch natively without a container install NodeJS and run `npm install`. 3. Configure your Switch DNS settings to point to the IP of your computer. 4. Run a connection test to trigger the Captive Portal. (Likewise, going into an update page will do the same.) @@ -37,6 +40,12 @@ To view locally: `npm run docs:serve` then visit `http://localhost:4001` To generate to `docs` folder: `npm run docs:generate` +Why Docker? +=============== + +Docker allows the app to run in the same environment, regardless of what OS the host computer is running. This +simplifies development as well as reduces bugs and improves overall performance. + Troubleshooting =============== @@ -60,7 +69,9 @@ ex: C:\pegaswitch\> node start.js --logfile log.txt ``` -If you encounter problems using pegaswitch on Windows, we suggest installing through WSL. +If you encounter problems using pegaswitch on Windows, we suggest using Docker. + +NOTE: If running inside docker container inside Windows, this does not apply. License ======= diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7808dda --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3' +services: + pegaswitch: + container_name: pegaswitch + build: . + volumes: + - .:/opt/app + ports: + - 80:80 + - 53:53 + - 8100:8100 + restart: always From 792c17b1a601a7238cade93f121bd777b60ea043 Mon Sep 17 00:00:00 2001 From: Daniel Gillespie Date: Sat, 6 Jan 2018 12:25:17 -0800 Subject: [PATCH 2/4] minor addition to dockerfile --- Dockerfile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 089a15b..ca24d83 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ -# Official image w/ LTS support -FROM node:8 +FROM node:latest EXPOSE 53 EXPOSE 80 @@ -9,10 +8,7 @@ WORKDIR /opt/app COPY . /opt/app/. -RUN rm -rf /opt/app/node_modules/ -RUN mkdir -p /opt/node_modules -RUN ln -s /opt/node_modules/ /opt/app/. - RUN npm install +RUN npm install pty.js CMD ["npm", "start"] From d2cf6184143d54b797d878875f188f60872e5c06 Mon Sep 17 00:00:00 2001 From: Daniel Gillespie Date: Sat, 6 Jan 2018 12:48:04 -0800 Subject: [PATCH 3/4] compose add volume comment out --- docker-compose.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7808dda..9b3f5e2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,8 +3,9 @@ services: pegaswitch: container_name: pegaswitch build: . - volumes: - - .:/opt/app + # Uncomment only if you want to devleop on app locally and within container. If just running app no need to do anything. # + # volumes: + # - .:/opt/app ports: - 80:80 - 53:53 From 8ba81b6fac9202671fbd2a92f5dec8efd0aad1f0 Mon Sep 17 00:00:00 2001 From: Daniel Gillespie Date: Sat, 6 Jan 2018 12:51:39 -0800 Subject: [PATCH 4/4] minor readme updates --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index bee7f1f..1ac48af 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,8 @@ Installation 1. Install Docker 2. Install Docker-Compose -3. Ensure Docker Has Minimum 4GB of Resources (Default 2GB) -2. Clone this repository -3. Run `docker-compose up` +3. Clone this repository +4. Run `docker-compose up` Usage ===== @@ -24,8 +23,8 @@ Usage 1. Ensure port 53, 80, and 8100 are open on the computer running pegaswitch. 2. PegaSwitch will start automatically when you start the docker container. 3. To run PegaSwitch natively without a container install NodeJS and run `npm install`. -3. Configure your Switch DNS settings to point to the IP of your computer. -4. Run a connection test to trigger the Captive Portal. (Likewise, going into an update page will do the same.) +4. Configure your Switch DNS settings to point to the IP of your computer. +5. Run a connection test to trigger the Captive Portal. (Likewise, going into an update page will do the same.) It should no longer be necessary to run `usefulscripts/SetupNew.js`, since PegaSwitch will now do it automatically.