diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ca24d83 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM node:latest + +EXPOSE 53 +EXPOSE 80 +EXPOSE 8100 + +WORKDIR /opt/app + +COPY . /opt/app/. + +RUN npm install +RUN npm install pty.js + +CMD ["npm", "start"] diff --git a/README.md b/README.md index 77d9ccf..1ac48af 100644 --- a/README.md +++ b/README.md @@ -12,17 +12,19 @@ Installation ============ -1. Install the latest version of node from [nodejs.org](https://nodejs.org) -2. Clone this repository -3. Run `npm install` +1. Install Docker +2. Install Docker-Compose +3. Clone this repository +4. 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` -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.) +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`. +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. @@ -37,6 +39,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 +68,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..9b3f5e2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: '3' +services: + pegaswitch: + container_name: pegaswitch + build: . + # 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 + - 8100:8100 + restart: always