From 1a597f674dabe7f0089a62ffc664c42442a06e36 Mon Sep 17 00:00:00 2001 From: wood ape Date: Sun, 17 Mar 2024 19:22:53 -0700 Subject: [PATCH 1/4] Add env var override for backend URL Supports the docker development environment. --- src/setupProxy.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/setupProxy.js b/src/setupProxy.js index 66186556a..56c3f3992 100644 --- a/src/setupProxy.js +++ b/src/setupProxy.js @@ -3,11 +3,13 @@ const { createProxyMiddleware } = require("http-proxy-middleware"); +const backendUrl = process.env.BACKEND_URL || "http://127.0.0.1:8080" + module.exports = function (app) { app.use( "/ims/api", createProxyMiddleware({ - target: "http://127.0.0.1:8080", + target: backendUrl, changeOrigin: true, }), ); @@ -16,21 +18,21 @@ module.exports = function (app) { app.use( "/ims/auth", createProxyMiddleware({ - target: "http://127.0.0.1:8080", + target: backendUrl, changeOrigin: true, }), ); app.use( "/ims/ext", createProxyMiddleware({ - target: "http://127.0.0.1:8080", + target: backendUrl, changeOrigin: true, }), ); app.use( "/ims/static", createProxyMiddleware({ - target: "http://127.0.0.1:8080", + target: backendUrl, changeOrigin: true, }), ); From 8d9195acb698278138f8d392d44f2d6642213de1 Mon Sep 17 00:00:00 2001 From: wood ape Date: Sun, 17 Mar 2024 19:24:02 -0700 Subject: [PATCH 2/4] Add docker & docker compose dev configs Supports faster development environment provisioning. --- README.md | 28 +++++++++++++++++++++++++++- docker-compose.yml | 20 ++++++++++++++++++++ docker-dev-sample.env | 3 +++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 docker-compose.yml create mode 100644 docker-dev-sample.env diff --git a/README.md b/README.md index 67c47349e..ae369adcf 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,9 @@ The application is implemented using [React](https://reactjs.org/). ## Development -### Install dependencies +### Without Docker + +#### Install dependencies You'll need to install the project's dependencies before you can run the server: @@ -24,6 +26,30 @@ You'll need to install the project's dependencies before you can run the server: npm install ``` +### Docker + +#### Create required docker network + +```console +docker network create rangers +``` + +#### Install dependencies + +You'll need to install the project's dependencies before you can run the server: + +```console +docker compose run --rm app npm install +``` + +#### Start the frontend server + +First [start your backend server](https://github.com/burningmantech/ranger-ims-server#development) with `docker-compose`, then start your frontend server. + +```console +docker compose up app -d +``` + ### Running the Test Suite To run all of the tests: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..3e469dc76 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +version: "3.7" + +services: + app: + container_name: "ranger_ims_web" + image: "${NODE_IMG_TAG:-node:18.18.2-alpine3.17}" + user: ":${NODE_GROUP_ID:-1420}" + ports: + - "${NODE_PORT:-3000}:3000" + environment: + - "BACKEND_URL=${BACKEND_URL:-http://ranger_ims_server:8080}" + volumes: + - "./:/app:cached" + command: "npm start" + working_dir: "/app" + +networks: + default: + external: true + name: "${DOCKER_RANGERS_NETWORK:-rangers}" diff --git a/docker-dev-sample.env b/docker-dev-sample.env new file mode 100644 index 000000000..bbb47129c --- /dev/null +++ b/docker-dev-sample.env @@ -0,0 +1,3 @@ +# BACKEND_URL="http://ranger_ims_server:8080" +# NODE_PORT=3000 +# DOCKER_RANGERS_NETWORK="rangers" \ No newline at end of file From 2ad2f0a00ec5c2bd1ca76488dd2da15821d0aa5a Mon Sep 17 00:00:00 2001 From: wood ape Date: Sun, 17 Mar 2024 19:34:23 -0700 Subject: [PATCH 3/4] Explain docker network order in README --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ae369adcf..4917a0c74 100644 --- a/README.md +++ b/README.md @@ -28,11 +28,7 @@ npm install ### Docker -#### Create required docker network - -```console -docker network create rangers -``` +First [start your backend server](https://github.com/burningmantech/ranger-ims-server#development) with `docker-compose`, then start your frontend server. This will create the required docker network. #### Install dependencies @@ -44,12 +40,18 @@ docker compose run --rm app npm install #### Start the frontend server -First [start your backend server](https://github.com/burningmantech/ranger-ims-server#development) with `docker-compose`, then start your frontend server. - ```console docker compose up app -d ``` +#### Troubleshooting + +##### Network error with all docker commands + +`Error response from daemon: network rangers not found` + +If you see this error you did not start the backend server in docker first. + ### Running the Test Suite To run all of the tests: From 3d9fe888e8970d5b69f42e375aa102f3c17baaf6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 13 Apr 2024 20:10:33 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docker-dev-sample.env | 2 +- src/setupProxy.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-dev-sample.env b/docker-dev-sample.env index bbb47129c..4bc488b6d 100644 --- a/docker-dev-sample.env +++ b/docker-dev-sample.env @@ -1,3 +1,3 @@ # BACKEND_URL="http://ranger_ims_server:8080" # NODE_PORT=3000 -# DOCKER_RANGERS_NETWORK="rangers" \ No newline at end of file +# DOCKER_RANGERS_NETWORK="rangers" diff --git a/src/setupProxy.js b/src/setupProxy.js index 56c3f3992..ed44b6b45 100644 --- a/src/setupProxy.js +++ b/src/setupProxy.js @@ -3,7 +3,7 @@ const { createProxyMiddleware } = require("http-proxy-middleware"); -const backendUrl = process.env.BACKEND_URL || "http://127.0.0.1:8080" +const backendUrl = process.env.BACKEND_URL || "http://127.0.0.1:8080"; module.exports = function (app) { app.use(