From 17d4c216f61b5d52494f3e869a5817e5f4f2536b Mon Sep 17 00:00:00 2001 From: Ronaldo Macapobre Date: Wed, 17 Jul 2024 15:44:45 -0700 Subject: [PATCH 01/13] - added web-dev service in docker-compose file - modified the build-web-dev - updated vue config to enable hot-reloading --- docker/docker-compose.yaml | 17 +++++++++++++++++ docker/manage | 18 +++++++++++++----- web/vue.config.js | 7 ++++++- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 36933d41..e5b087ac 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -15,6 +15,23 @@ services: depends_on: - api + web-dev: + image: "scv-web-dev" + environment: + - API_URL=${API_URL} + - WEB_BASE_HREF=${WEB_BASE_HREF} + - DEV_MODE=false + - NODE_ENV=development + - NPM_CONFIG_LOGLEVEL=notice + - NPM_RUN=serve + ports: + - 8080:1339 + volumes: + - "../web/src:/opt/app-root/src/src" + - "../web/package.json:/opt/app-root/src/package.json" + depends_on: + - api + api: image: scv-api environment: diff --git a/docker/manage b/docker/manage index 1676c04a..8e27b731 100755 --- a/docker/manage +++ b/docker/manage @@ -52,7 +52,10 @@ usage() { EOF exit 1 } - +# ----------------------------------------------------------------------------------------------------------------- +# Default Settings: +# ----------------------------------------------------------------------------------------------------------------- +DEFAULT_CONTAINERS="db api web" # ----------------------------------------------------------------------------------------------------------------- # Functions: # ----------------------------------------------------------------------------------------------------------------- @@ -130,9 +133,11 @@ build-web-dev() { echo -e "Building the scv-web-dev image using s2i ..." echo -e "----------------------------------------------------------------------------------------------------" ${S2I_EXE} build \ + --copy \ -e "DEV_MODE=true" \ + -e WEB_BASE_HREF=${WEB_BASE_HREF} \ '../web' \ - 'quay.io/centos7/nodejs-12-centos7' \ + 'centos/nodejs-12-centos7' \ 'scv-web-dev' echo -e "====================================================================================================" } @@ -165,14 +170,13 @@ configureEnvironment () { getStartupParams() { CONTAINERS="" - - ARGS="" + ARGS="--force-recreate" for arg in $@; do case "$arg" in *=*) # Skip it - ;; + ;; -*) ARGS+=" $arg";; *) @@ -180,6 +184,10 @@ getStartupParams() { esac done + if [ -z "$CONTAINERS" ]; then + CONTAINERS="$DEFAULT_CONTAINERS" + fi + echo ${ARGS} ${CONTAINERS} } diff --git a/web/vue.config.js b/web/vue.config.js index 57a5aa77..51205cc3 100644 --- a/web/vue.config.js +++ b/web/vue.config.js @@ -10,9 +10,14 @@ module.exports = { configureWebpack: { devServer: { historyApiFallback: true, - host: 'localhost', + host: '0.0.0.0', port: 1339, https: true, + watchOptions: { + ignored: /node_modules/, + aggregateTimeout: 300, + poll: 1000, + }, proxy: { //This is for WEB_BASE_HREF = '/' specifically. //If having problems connecting, try adding: netsh http add iplisten 127.0.0.1 From 225f57d0e34d3ae169200b5449e86431908e479f Mon Sep 17 00:00:00 2001 From: Ronaldo Macapobre Date: Fri, 19 Jul 2024 04:39:50 +0000 Subject: [PATCH 02/13] updates to vue.config to fix proxy error --- docker/manage | 4 ++-- web/vue.config.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/manage b/docker/manage index 8e27b731..9d1c9d0f 100755 --- a/docker/manage +++ b/docker/manage @@ -55,12 +55,12 @@ exit 1 # ----------------------------------------------------------------------------------------------------------------- # Default Settings: # ----------------------------------------------------------------------------------------------------------------- -DEFAULT_CONTAINERS="db api web" +DEFAULT_CONTAINERS="db api web-dev" # ----------------------------------------------------------------------------------------------------------------- # Functions: # ----------------------------------------------------------------------------------------------------------------- build-all() { - build-web + build-web-dev build-api } diff --git a/web/vue.config.js b/web/vue.config.js index 51205cc3..45ef4745 100644 --- a/web/vue.config.js +++ b/web/vue.config.js @@ -22,11 +22,11 @@ module.exports = { //This is for WEB_BASE_HREF = '/' specifically. //If having problems connecting, try adding: netsh http add iplisten 127.0.0.1 '^/api': { - target: "https://localhost:44369", + target: "http://host.docker.internal:5000", headers: { Connection: 'keep-alive', 'X-Forwarded-Host': 'localhost', - 'X-Forwarded-Port': '1339', + 'X-Forwarded-Port': '8080', 'X-Base-Href': '/' }, changeOrigin: true From ae47544301b9eb6ca4c0cb34806742a5a223907b Mon Sep 17 00:00:00 2001 From: Ronaldo Macapobre Date: Fri, 19 Jul 2024 16:44:03 +0000 Subject: [PATCH 03/13] update README.md to include hotreloading and debugging information --- docker/README.md | 85 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 81 insertions(+), 4 deletions(-) diff --git a/docker/README.md b/docker/README.md index ff427755..d016787a 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,3 +1,76 @@ +# Running the Application on DevContainer for Local Development + +## Pre-requisite + +Ensure `Docker` and `Dev Containers` extenion (`ms-vscode-remote.remote-containers`) is installed in your machine. + +## Steps + +1. Launch code in VSCode. +2. Hit `Ctrl + Shift + P`, select `Dev Containers: Open Folder in Container...` and wait for it to completely load. +3. [Start](#starting-the-project) the project. + +## Enabling Hot Reloading and Debugging + +Hot reloading is a feature that lets you see the effects of your code changes almost instantly without having to completely restart the application. This significantly speeds up the development process. + +### Frontend + +1. Go to `./manage` file. +2. Find the `DEFAULT_CONTAINERS` and replace `web` with `web-dev`. + +``` +DEFAULT_CONTAINERS="db api web-dev" +``` + +3. Find the `build-all` function and replace with the code below. + +``` +build-all() { + build-web-dev + build-api +} +``` + +4. [Rebuild](#building-the-images) the images. +5. [Start](#starting-the-project) the project. + +### Backend + +- The backend is automatically utilizing hot reloading. +- Add the code below to the `launch.json` to enable remote debugging. + +``` +{ + "configurations": [ + { + "name": ".NET Core Docker Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickRemoteProcess}", + "pipeTransport": { + "pipeProgram": "docker", + "pipeArgs": ["exec", "-i", "scv-api-1"], + "debuggerPath": "/vsdbg/vsdbg", + "pipeCwd": "${workspaceRoot}", + "quoteArgs": false + }, + "sourceFileMap": { + "/opt/app-root/src": "${workspaceRoot}/" + } + } + ] +} +``` + +## Notes + +- When the error below occurs, go to `manage` file and change the _Select End Line of Sequence_ (lower right hand side of VSCode) from **CRLF** to **LF**. + +``` +bash: ./manage: /bin/bash^M: bad interpreter: No such file or directory +``` + # Running the Application on Docker ## Management Script @@ -5,6 +78,7 @@ The `manage` script wraps the Docker process in easy to use commands. To get full usage information on the script, run: + ``` ./manage -h ``` @@ -14,6 +88,7 @@ To get full usage information on the script, run: The first thing you'll need to do is build the Docker images. To build the images, run: + ``` ./manage build ``` @@ -21,27 +96,29 @@ To build the images, run: ## Starting the Project To start the project, run: + ``` ./manage start ``` -This will start the project interactively; with all of the logs being written to the command line. Press `Ctrl-C` to shut down the services from the same shell window. +This will start the project interactively; with all of the logs being written to the command line. Press `Ctrl-C` to shut down the services from the same shell window. Any environment variables containing settings, configuration, or secrets can be placed in a `.env` file in the `docker` folder and they will automatically be picked up and loaded by the `./manage` script when you start the application. ## Stopping the Project To stop the project, run: + ``` ./manage stop ``` -This will shut down and clean up all of the containers in the project. This is a non-destructive process. The containers are not deleted so they will be reused the next time you run start. +This will shut down and clean up all of the containers in the project. This is a non-destructive process. The containers are not deleted so they will be reused the next time you run start. -Since the services are started interactively, you will have to issue this command from another shell window. This command can also be run after shutting down the services using the `Ctrl-C` method to clean up any services that may not have shutdown correctly. +Since the services are started interactively, you will have to issue this command from another shell window. This command can also be run after shutting down the services using the `Ctrl-C` method to clean up any services that may not have shutdown correctly. ## Using the Application - By default, the main developer UI is exposed at; https://localhost:8080/scjscv/ - The Swagger API and documentation is available at; https://localhost:8080/scjscv/api/ - - Which is also exposed directly at; http://localhost:5000/api/ \ No newline at end of file +- Which is also exposed directly at; http://localhost:5000/api/ From cf17bcb7cdd14935761bed3b8c9e2989b788c0c3 Mon Sep 17 00:00:00 2001 From: Ronaldo Macapobre Date: Sat, 20 Jul 2024 01:49:18 +0000 Subject: [PATCH 04/13] - include launch.json for BE remote debugging - updated ./manage to include start-debug and build-debug - updated README.md content --- .gitattributes | 1 + .gitignore | 2 +- .vscode/launch.json | 20 +++++++++++++++ docker/README.md | 62 ++++++++++----------------------------------- docker/manage | 44 +++++++++++++++++++++----------- 5 files changed, 65 insertions(+), 64 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.gitattributes b/.gitattributes index 2b1cd712..63d0af4e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,3 +7,4 @@ *.json text eol=lf **/s2i/bin/* text eol=lf **/root/**/* text eol=lf +/docker/manage text eol=lf \ No newline at end of file diff --git a/.gitignore b/.gitignore index 69767cb7..6079bd30 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # Visual Studio Code -.vscode +.vscode/tasks.json ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..5e8c41e7 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,20 @@ +{ + "configurations": [ + { + "name": ".NET Core Docker Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickRemoteProcess}", + "pipeTransport": { + "pipeProgram": "docker", + "pipeArgs": ["exec", "-i", "scv-api-1"], + "debuggerPath": "/vsdbg/vsdbg", + "pipeCwd": "${workspaceRoot}", + "quoteArgs": false + }, + "sourceFileMap": { + "/opt/app-root/src": "${workspaceRoot}/" + } + } + ] +} diff --git a/docker/README.md b/docker/README.md index d016787a..2a2a3d7c 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,5 +1,7 @@ # Running the Application on DevContainer for Local Development +Hot reloading is configured in both frontend and backend so developers can see the effects of the code changes almost instantly without having to completely restart the application. This significantly speeds up the development process. + ## Pre-requisite Ensure `Docker` and `Dev Containers` extenion (`ms-vscode-remote.remote-containers`) is installed in your machine. @@ -8,68 +10,32 @@ Ensure `Docker` and `Dev Containers` extenion (`ms-vscode-remote.remote-containe 1. Launch code in VSCode. 2. Hit `Ctrl + Shift + P`, select `Dev Containers: Open Folder in Container...` and wait for it to completely load. -3. [Start](#starting-the-project) the project. - -## Enabling Hot Reloading and Debugging - -Hot reloading is a feature that lets you see the effects of your code changes almost instantly without having to completely restart the application. This significantly speeds up the development process. - -### Frontend - -1. Go to `./manage` file. -2. Find the `DEFAULT_CONTAINERS` and replace `web` with `web-dev`. +3. Building the project. ``` -DEFAULT_CONTAINERS="db api web-dev" +./manage build-debug ``` -3. Find the `build-all` function and replace with the code below. +4. Starting the project. ``` -build-all() { - build-web-dev - build-api -} +./manage start-debug ``` -4. [Rebuild](#building-the-images) the images. -5. [Start](#starting-the-project) the project. - -### Backend +## Notes -- The backend is automatically utilizing hot reloading. -- Add the code below to the `launch.json` to enable remote debugging. +- DevContainer will fail to build/rebuild when connected to the BC Gov's VPN. +- You may find this command handy when wiping all unused containers, volumes, networks and images. ``` -{ - "configurations": [ - { - "name": ".NET Core Docker Attach", - "type": "coreclr", - "request": "attach", - "processId": "${command:pickRemoteProcess}", - "pipeTransport": { - "pipeProgram": "docker", - "pipeArgs": ["exec", "-i", "scv-api-1"], - "debuggerPath": "/vsdbg/vsdbg", - "pipeCwd": "${workspaceRoot}", - "quoteArgs": false - }, - "sourceFileMap": { - "/opt/app-root/src": "${workspaceRoot}/" - } - } - ] -} +docker system prune -a --volumes ``` -## Notes - -- When the error below occurs, go to `manage` file and change the _Select End Line of Sequence_ (lower right hand side of VSCode) from **CRLF** to **LF**. +## Using the Application -``` -bash: ./manage: /bin/bash^M: bad interpreter: No such file or directory -``` +- By default, the main developer UI is exposed at; https://localhost:8080/ +- The Swagger API and documentation is available at; https://localhost:8080/api/ +- Which is also exposed directly at; http://localhost:5000/api/ # Running the Application on Docker diff --git a/docker/manage b/docker/manage index 9d1c9d0f..44030223 100755 --- a/docker/manage +++ b/docker/manage @@ -19,7 +19,7 @@ export COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME-scv}" usage() { cat <<-EOF - Usage: $0 {start|stop|build} + Usage: $0 {start|stop|build|start-debug|build-debug} Options: @@ -38,28 +38,46 @@ usage() { - web - api + build-debug - Build the docker images for the project for local development. + You need to do this first, since the builds require some s2i builds. + + Containers: + - web-dev + - api + start - Creates the application containers from the built images and starts the services based on the docker-compose.yaml file. Example: $0 start + start-debug - Used for local development that enables hot reloading for FE and BE. + Creates the application containers from the built images + and starts the services based on the docker-compose.yaml file. + Example: + $0 start-debug + stop - Stops the services. This is a non-destructive process. The containers are not deleted so they will be reused the next time you run start. down - Brings down the services and removes the volumes (storage) and containers. rm - Same as down - EOF exit 1 } # ----------------------------------------------------------------------------------------------------------------- # Default Settings: # ----------------------------------------------------------------------------------------------------------------- -DEFAULT_CONTAINERS="db api web-dev" +DEFAULT_CONTAINERS="db api web" +DEFAULT_DEBUG_CONTAINERS="db api web-dev" # ----------------------------------------------------------------------------------------------------------------- # Functions: # ----------------------------------------------------------------------------------------------------------------- build-all() { + build-web + build-api +} + +build-debug() { build-web-dev build-api } @@ -121,14 +139,6 @@ build-web-dev() { # # web-dev # - echo -e "\n\n====================================================================================================" - echo -e "Building the nginx-runtime image using Docker ..." - echo -e "----------------------------------------------------------------------------------------------------" - docker build \ - -t 'nginx-runtime' \ - -f './nginx-runtime/Dockerfile' './nginx-runtime/' - echo -e "====================================================================================================" - echo -e "\n\n====================================================================================================" echo -e "Building the scv-web-dev image using s2i ..." echo -e "----------------------------------------------------------------------------------------------------" @@ -232,12 +242,12 @@ shift case "$COMMAND" in start) - _startupParams=$(getStartupParams $@) configureEnvironment $@ - docker-compose up ${_startupParams} + docker-compose up --force-recreate ${DEFAULT_CONTAINERS} ;; - web-dev) - # todo + start-debug) + configureEnvironment $@ + docker-compose up --force-recreate ${DEFAULT_DEBUG_CONTAINERS} ;; stop) docker-compose stop @@ -246,6 +256,10 @@ case "$COMMAND" in configureEnvironment deleteVolumes ;; + build-debug) + build-web-dev + build-api + ;; build) buildImage=$(toLower ${1}) shift || buildImage=all From 18eba709fc1afbf1a577428f27dee724339f41a0 Mon Sep 17 00:00:00 2001 From: Wade Barnes Date: Mon, 22 Jul 2024 06:52:09 -0700 Subject: [PATCH 05/13] Update manage script. - Simplify build - Simplify commands - Restore use of getStartupParams Signed-off-by: Wade Barnes --- docker/manage | 54 ++++++++++++++++++++++----------------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/docker/manage b/docker/manage index 44030223..9e3e2c32 100755 --- a/docker/manage +++ b/docker/manage @@ -19,7 +19,7 @@ export COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME-scv}" usage() { cat <<-EOF - Usage: $0 {start|stop|build|start-debug|build-debug} + Usage: $0 {start|debug|stop|build} Options: @@ -36,50 +36,39 @@ usage() { Containers: - web + - web-dev - api - build-debug - Build the docker images for the project for local development. - You need to do this first, since the builds require some s2i builds. - - Containers: - - web-dev - - api - start - Creates the application containers from the built images and starts the services based on the docker-compose.yaml file. Example: $0 start - start-debug - Used for local development that enables hot reloading for FE and BE. + debug - Used for local development that enables hot reloading for FE and BE. Creates the application containers from the built images and starts the services based on the docker-compose.yaml file. Example: - $0 start-debug + $0 debug stop - Stops the services. This is a non-destructive process. The containers are not deleted so they will be reused the next time you run start. - down - Brings down the services and removes the volumes (storage) and containers. - rm - Same as down + dowm | rm - Brings down the services and removes the volumes (storage) and containers. Destructive. EOF exit 1 } # ----------------------------------------------------------------------------------------------------------------- # Default Settings: # ----------------------------------------------------------------------------------------------------------------- -DEFAULT_CONTAINERS="db api web" -DEFAULT_DEBUG_CONTAINERS="db api web-dev" +RUNTIME_CONTAINERS="db api web" +DEBUG_CONTAINERS="db api web-dev" # ----------------------------------------------------------------------------------------------------------------- # Functions: # ----------------------------------------------------------------------------------------------------------------- build-all() { - build-web - build-api -} - -build-debug() { - build-web-dev - build-api + build-web + build-web-dev + build-api } build-api() { @@ -186,7 +175,7 @@ getStartupParams() { case "$arg" in *=*) # Skip it - ;; + ;; -*) ARGS+=" $arg";; *) @@ -195,7 +184,11 @@ getStartupParams() { done if [ -z "$CONTAINERS" ]; then - CONTAINERS="$DEFAULT_CONTAINERS" + if [ -z "$DEBUG_MODE" ]; then + CONTAINERS="$RUNTIME_CONTAINERS" + else + CONTAINERS="$DEBUG_CONTAINERS" + fi fi echo ${ARGS} ${CONTAINERS} @@ -242,12 +235,15 @@ shift case "$COMMAND" in start) + _startupParams=$(getStartupParams $@) configureEnvironment $@ - docker-compose up --force-recreate ${DEFAULT_CONTAINERS} + docker-compose up ${_startupParams} ;; - start-debug) + debug) + export DEBUG_MODE=1 + _startupParams=$(getStartupParams $@) configureEnvironment $@ - docker-compose up --force-recreate ${DEFAULT_DEBUG_CONTAINERS} + docker-compose up ${_startupParams} ;; stop) docker-compose stop @@ -256,10 +252,6 @@ case "$COMMAND" in configureEnvironment deleteVolumes ;; - build-debug) - build-web-dev - build-api - ;; build) buildImage=$(toLower ${1}) shift || buildImage=all @@ -281,4 +273,4 @@ case "$COMMAND" in usage esac -popd >/dev/null \ No newline at end of file +popd >/dev/null From 9d5029cded97bc1460804237d83481e6982870ed Mon Sep 17 00:00:00 2001 From: Wade Barnes Date: Mon, 22 Jul 2024 07:10:09 -0700 Subject: [PATCH 06/13] Labeling updates - Relabel from `scv` and `scjscv` to `jasper`. Signed-off-by: Wade Barnes --- README.md | 2 +- docker/README.md | 4 ++-- docker/api/Dockerfile.dev | 2 +- docker/docker-compose.yaml | 16 ++++++++-------- docker/manage | 30 +++++++++++++++--------------- web/.devcontainer/Dockerfile | 4 ++-- web/src/main.ts | 8 ++++---- web/vue.config.js | 6 +++--- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 0f85681d..7cf68603 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ The OpenShift build and deployment configurations for the project can be found h For high level View API documentation refer to the diagram above. For details, refer to the [router](./web/src/router/index.ts) and [view components](./web/src/components/) source code. -For backend API documentation refer to the Swagger API documentation page available at the `api/` endpoint of the running application. For example, if you are running the application locally in docker, the Swagger page can be found at https://localhost:8080/scjscv/api/. Refer to [Running in Docker](#running-in-docker) section for details. +For backend API documentation refer to the Swagger API documentation page available at the `api/` endpoint of the running application. For example, if you are running the application locally in docker, the Swagger page can be found at https://localhost:8080/jasper/api/. Refer to [Running in Docker](#running-in-docker) section for details. ## Getting Help or Reporting an Issue diff --git a/docker/README.md b/docker/README.md index 2a2a3d7c..9c88bd57 100644 --- a/docker/README.md +++ b/docker/README.md @@ -85,6 +85,6 @@ Since the services are started interactively, you will have to issue this comman ## Using the Application -- By default, the main developer UI is exposed at; https://localhost:8080/scjscv/ -- The Swagger API and documentation is available at; https://localhost:8080/scjscv/api/ +- By default, the main developer UI is exposed at; https://localhost:8080/jasper/ +- The Swagger API and documentation is available at; https://localhost:8080/jasper/api/ - Which is also exposed directly at; http://localhost:5000/api/ diff --git a/docker/api/Dockerfile.dev b/docker/api/Dockerfile.dev index fc735a31..0d4f88c3 100644 --- a/docker/api/Dockerfile.dev +++ b/docker/api/Dockerfile.dev @@ -6,4 +6,4 @@ ENV CORS_DOMAIN='http://localhost:8080' ENV DOTNET_STARTUP_PROJECT='./api/api.csproj' ENV DOTNET_USE_POLLING_FILE_WATCHER 1 -RUN curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l /vsdbg \ No newline at end of file +RUN curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l /vsdbg diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index e5b087ac..d4ca2069 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -2,7 +2,7 @@ version: "3.4" services: web: - image: scv-web + image: "${COMPOSE_PROJECT_NAME}-web" environment: - API_URL=${API_URL} - USE_SELF_SIGNED_SSL=${USE_SELF_SIGNED_SSL} @@ -16,7 +16,7 @@ services: - api web-dev: - image: "scv-web-dev" + image: "${COMPOSE_PROJECT_NAME}-web-dev" environment: - API_URL=${API_URL} - WEB_BASE_HREF=${WEB_BASE_HREF} @@ -33,8 +33,8 @@ services: - api api: - image: scv-api - environment: + image: "${COMPOSE_PROJECT_NAME}-api" + environment: - ASPNETCORE_URLS=${ASPNETCORE_URLS} - FileServicesClient__Username=${FileServicesClientUsername} - FileServicesClient__Password=${FileServicesClientPassword} @@ -73,8 +73,8 @@ services: - ../api/:/opt/app-root/src/api - ../db/:/opt/app-root/src/db - ../jc-interface-client/:/opt/app-root/src/jc-interface-client - - scv-api-dev-bin:/opt/app-root/src/api/bin - - scv-api-dev-obj:/opt/app-root/src/api/obj + - api-dev-bin:/opt/app-root/src/api/bin + - api-dev-obj:/opt/app-root/src/api/obj - ./seed:/opt/app-root/data depends_on: - db @@ -97,5 +97,5 @@ services: - ./tmp:/tmp2 volumes: - scv-api-dev-bin: - scv-api-dev-obj: \ No newline at end of file + api-dev-bin: + api-dev-obj: diff --git a/docker/manage b/docker/manage index 9e3e2c32..e79546e7 100755 --- a/docker/manage +++ b/docker/manage @@ -11,7 +11,7 @@ if [ -z "$(type -P "$S2I_EXE")" ]; then fi SCRIPT_HOME="$(cd "$(dirname "$0")" && pwd)" -export COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME-scv}" +export COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME-jasper}" # ================================================================================================================= # Usage: @@ -79,7 +79,7 @@ build-api() { echo -e "Building api image using docker ..." echo -e "----------------------------------------------------------------------------------------------------" docker build \ - -t 'scv-api' \ + -t "${COMPOSE_PROJECT_NAME}-api" \ -f './api//Dockerfile.dev' '..' echo -e "====================================================================================================" @@ -90,14 +90,14 @@ build-web() { # web # # The web-runtime image is used for the final runtime image. - # The scv-app image is used to build the artifacts for the vue distribution. + # The artifacts image is used to build the artifacts for the vue distribution. # The vue-on-nginx image is copy of the nginx-runtime image complete with a copy of the build artifacts. # echo -e "\n\n====================================================================================================" - echo -e "Building the scv-web-runtime (nginx-runtime) image using Docker ..." + echo -e "Building the ${COMPOSE_PROJECT_NAME}-web-runtime (nginx-runtime) image using Docker ..." echo -e "----------------------------------------------------------------------------------------------------" docker build \ - -t 'scv-web-runtime' \ + -t "${COMPOSE_PROJECT_NAME}-web-runtime" \ -f './nginx-runtime/Dockerfile' './nginx-runtime/' echo -e "====================================================================================================" @@ -105,20 +105,20 @@ build-web() { # I tried using __webpack_public_path__, but the CSS file path and JS file path weren't correctly updated. # Also note we don't load in environment variables from the arguments here. echo -e "\n\n====================================================================================================" - echo -e "Building the scv-web-artifacts image using s2i ..." + echo -e "Building the ${COMPOSE_PROJECT_NAME}-web-artifacts image using s2i ..." echo -e "----------------------------------------------------------------------------------------------------" ${S2I_EXE} build \ --copy \ '../web' \ 'quay.io/centos7/nodejs-12-centos7:master' \ - 'scv-web-artifacts' + "${COMPOSE_PROJECT_NAME}-web-artifacts" echo -e "====================================================================================================" echo -e "\n\n====================================================================================================" - echo -e "Building the scv-web image using Docker ..." + echo -e "Building the ${COMPOSE_PROJECT_NAME}-web image using Docker ..." echo -e "----------------------------------------------------------------------------------------------------" docker build \ - -t 'scv-web' \ + -t "${COMPOSE_PROJECT_NAME}-web" \ --build-arg IMAGE_PREFIX=${COMPOSE_PROJECT_NAME}- \ -f './vue-on-nginx/Dockerfile' './vue-on-nginx/' echo -e "====================================================================================================" @@ -129,7 +129,7 @@ build-web-dev() { # web-dev # echo -e "\n\n====================================================================================================" - echo -e "Building the scv-web-dev image using s2i ..." + echo -e "Building the ${COMPOSE_PROJECT_NAME}-web-dev image using s2i ..." echo -e "----------------------------------------------------------------------------------------------------" ${S2I_EXE} build \ --copy \ @@ -137,7 +137,7 @@ build-web-dev() { -e WEB_BASE_HREF=${WEB_BASE_HREF} \ '../web' \ 'centos/nodejs-12-centos7' \ - 'scv-web-dev' + "${COMPOSE_PROJECT_NAME}-web-dev" echo -e "====================================================================================================" } @@ -156,15 +156,15 @@ configureEnvironment () { esac done - # scv-db + # Default database startup parameters export POSTGRESQL_DATABASE=${POSTGRESQL_DATABASE:-appdb} - export POSTGRESQL_USER=${POSTGRESQL_USER:-scv} + export POSTGRESQL_USER=${POSTGRESQL_USER:-${COMPOSE_PROJECT_NAME}} export POSTGRESQL_PASSWORD=${POSTGRESQL_PASSWORD:-jeKEumGzuRVY4EJyfcUk} export POSTGRESQL_ADMIN_PASSWORD=${POSTGRESQL_ADMIN_PASSWORD:-yM%J]7RZgY@!zb=*#4kB} - # scv-web + # Default web startup parameters export API_URL=${API_URL-http://api:5000/api/} - export WEB_BASE_HREF=${WEB_BASE_HREF-/scjscv/} + export WEB_BASE_HREF=${WEB_BASE_HREF-/jasper/} } getStartupParams() { diff --git a/web/.devcontainer/Dockerfile b/web/.devcontainer/Dockerfile index 6c965bfa..1cd01b6c 100644 --- a/web/.devcontainer/Dockerfile +++ b/web/.devcontainer/Dockerfile @@ -3,7 +3,7 @@ FROM nginx:stable ENV STI_SCRIPTS_PATH=/usr/libexec/s2i ENV USE_SELF_SIGNED_SSL='usss' -ENV WEB_BASE_HREF='/scjscv/' +ENV WEB_BASE_HREF='/jasper/' ENV API_URL='http://host.docker.internal:5000/api/' ENV RealIpFrom='172.17.0.1' ENV NODE_ENV='development' @@ -35,7 +35,7 @@ COPY nginx.conf.template /tmp/ # - The application artifacts live in /tmp # --------------------------------------------------------------------------------- RUN chmod -R g+rwx $STI_SCRIPTS_PATH -RUN chmod og+rw /var/cache/nginx \ +RUN chmod og+rw /var/cache/nginx \ /var/run \ /etc/nginx/nginx.conf \ /tmp diff --git a/web/src/main.ts b/web/src/main.ts index c0f31aed..64550432 100644 --- a/web/src/main.ts +++ b/web/src/main.ts @@ -21,7 +21,7 @@ Vue.component('loading-spinner', LoadingSpinner); Vue.http.interceptors.push(function () { return function (response) { - if (response.status == 401) { + if (response.status == 401) { location.replace(`${process.env.BASE_URL}api/auth/login?redirectUri=${window.location}`); } }; @@ -29,7 +29,7 @@ Vue.http.interceptors.push(function () { Vue.http.options.root = process.env.BASE_URL; -//Redirect from / to /scjscv/ +// Redirect from / to /jasper/ if (location.pathname == "/") history.pushState({ page: "home" }, "", process.env.BASE_URL); @@ -42,5 +42,5 @@ const router = new VueRouter({ new Vue({ router, store, - render: h => h(App) -}).$mount('#app'); \ No newline at end of file + render: h => h(App) +}).$mount('#app'); diff --git a/web/vue.config.js b/web/vue.config.js index 45ef4745..24cc6d6a 100644 --- a/web/vue.config.js +++ b/web/vue.config.js @@ -2,8 +2,8 @@ const path = require("path"); const vueSrc = "src"; //I noticed when we don't have publicPath set to /, it becomes problematic using vue-cli-tools - it doesn't seem to respect history paths. -//EX. scjscv/civil-files/5555 wont work when you navigate directly to it with vue-cli-tools versus NGINX it works fine. -//When deployed over NGINX this problem seems to go away. So I've left it as / for now in local development environments. +//EX. jasper/civil-files/5555 wont work when you navigate directly to it with vue-cli-tools versus NGINX it works fine. +//When deployed over NGINX this problem seems to go away. So I've left it as / for now in local development environments. module.exports = { publicPath: process.env.NODE_ENV == 'production' ? '/S2I_INJECT_PUBLIC_PATH/' : '/', //chainWebpack: config => config.optimization.minimize(false), Disable minification. @@ -19,7 +19,7 @@ module.exports = { poll: 1000, }, proxy: { - //This is for WEB_BASE_HREF = '/' specifically. + //This is for WEB_BASE_HREF = '/' specifically. //If having problems connecting, try adding: netsh http add iplisten 127.0.0.1 '^/api': { target: "http://host.docker.internal:5000", From b90428bb58573314e329868b3720abdd2fb74ed7 Mon Sep 17 00:00:00 2001 From: Wade Barnes Date: Mon, 22 Jul 2024 07:26:36 -0700 Subject: [PATCH 07/13] Update documentation - to reflect updates to the `./manage` script. Signed-off-by: Wade Barnes --- docker/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docker/README.md b/docker/README.md index 9c88bd57..e45dc7f7 100644 --- a/docker/README.md +++ b/docker/README.md @@ -13,23 +13,23 @@ Ensure `Docker` and `Dev Containers` extenion (`ms-vscode-remote.remote-containe 3. Building the project. ``` -./manage build-debug +./manage build ``` 4. Starting the project. ``` -./manage start-debug +./manage debug ``` ## Notes - DevContainer will fail to build/rebuild when connected to the BC Gov's VPN. -- You may find this command handy when wiping all unused containers, volumes, networks and images. -``` -docker system prune -a --volumes -``` +- You may find this command handy when wiping all unused containers, volumes, networks and images. + ``` + docker system prune -a --volumes + ``` ## Using the Application From 3237d715c00b7c2a4b0d8cf49f168b224828ed08 Mon Sep 17 00:00:00 2001 From: Ronaldo Macapobre Date: Mon, 22 Jul 2024 16:51:59 +0000 Subject: [PATCH 08/13] changed scv to jasper --- .vscode/launch.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 5e8c41e7..db6372ff 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,7 +7,7 @@ "processId": "${command:pickRemoteProcess}", "pipeTransport": { "pipeProgram": "docker", - "pipeArgs": ["exec", "-i", "scv-api-1"], + "pipeArgs": ["exec", "-i", "jasper-api-1"], "debuggerPath": "/vsdbg/vsdbg", "pipeCwd": "${workspaceRoot}", "quoteArgs": false From 55a4fa0a265e35f02baaea4860f1e9fe1b88d81b Mon Sep 17 00:00:00 2001 From: Ronaldo Macapobre Date: Mon, 22 Jul 2024 17:18:16 +0000 Subject: [PATCH 09/13] Removed command in postCreateCommand --- .devcontainer/devcontainer.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 884ef874..9c5c72b0 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -10,9 +10,7 @@ "ghcr.io/devcontainers/features/terraform:1": {}, "ghcr.io/devcontainers/features/docker-in-docker:2": {}, "ghcr.io/devcontainers-contrib/features/aws-cdk:2": {} - }, - "postCreateCommand": "./docker/manage build", "customizations": { "vscode": { "extensions": [ From 5e11f9728cc01e9a853688dd54583f29533a5c3e Mon Sep 17 00:00:00 2001 From: Wade Barnes Date: Mon, 22 Jul 2024 12:37:05 -0700 Subject: [PATCH 10/13] Switch to docker-from-docker - Allows the dev container to share the host's docker instance, allowing the host to see any containers launched in the dev container. Signed-off-by: Wade Barnes --- .devcontainer/devcontainer.json | 7 +++++-- docker/docker-compose.yaml | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9c5c72b0..f94e143c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -8,7 +8,7 @@ "ghcr.io/devcontainers/features/dotnet:2": {}, "ghcr.io/devcontainers/features/aws-cli:1": {}, "ghcr.io/devcontainers/features/terraform:1": {}, - "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/devcontainers/features/docker-from-docker:1.5.0": {}, "ghcr.io/devcontainers-contrib/features/aws-cdk:2": {} }, "customizations": { @@ -31,5 +31,8 @@ } } }, - "remoteUser": "root" + "remoteUser": "root", + "containerEnv": { + "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}" + } } diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index d4ca2069..feb94b7e 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -27,8 +27,8 @@ services: ports: - 8080:1339 volumes: - - "../web/src:/opt/app-root/src/src" - - "../web/package.json:/opt/app-root/src/package.json" + - "${LOCAL_WORKSPACE_FOLDER-..}/web/src:/opt/app-root/src/src" + - "${LOCAL_WORKSPACE_FOLDER-..}/web/package.json:/opt/app-root/src/package.json" depends_on: - api From ae05ff83ac8210fca07161b5753a66a8769a55ef Mon Sep 17 00:00:00 2001 From: Ronaldo Macapobre Date: Tue, 23 Jul 2024 00:24:54 +0000 Subject: [PATCH 11/13] - use ${LOCAL_WORKSPACE_FOLDER-..} for api - changed host.docker.interal to container name --- api/Controllers/LocationController.cs | 7 +++++-- docker/docker-compose.yaml | 6 +++--- web/vue.config.js | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/api/Controllers/LocationController.cs b/api/Controllers/LocationController.cs index 3a42896b..9ba70a33 100644 --- a/api/Controllers/LocationController.cs +++ b/api/Controllers/LocationController.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; @@ -31,6 +32,8 @@ public async Task>> GetLocationsAndCourtRooms() { var locations = await _locationService.GetLocations(); + Console.WriteLine("123"); + var locationList = locations.Select(location => new Location { Name = location.LongDesc, @@ -44,7 +47,7 @@ public async Task>> GetLocationsAndCourtRooms() foreach (var location in locationList) { location.CourtRooms = courtRooms.Where(cr => cr.Flex == location.LocationId && (cr.ShortDesc == "CRT" || cr.ShortDesc == "HGR")) - .Select(cr => new CourtRoom {LocationId = cr.Flex, Room = cr.Code, Type = cr.ShortDesc}).ToList(); + .Select(cr => new CourtRoom { LocationId = cr.Flex, Room = cr.Code, Type = cr.ShortDesc }).ToList(); } return Ok(locationList); diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index feb94b7e..8d2db1e4 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -70,9 +70,9 @@ services: ports: - 5000:5000 volumes: - - ../api/:/opt/app-root/src/api - - ../db/:/opt/app-root/src/db - - ../jc-interface-client/:/opt/app-root/src/jc-interface-client + - ${LOCAL_WORKSPACE_FOLDER-..}/api/:/opt/app-root/src/api + - ${LOCAL_WORKSPACE_FOLDER-..}/db/:/opt/app-root/src/db + - ${LOCAL_WORKSPACE_FOLDER-..}/jc-interface-client/:/opt/app-root/src/jc-interface-client - api-dev-bin:/opt/app-root/src/api/bin - api-dev-obj:/opt/app-root/src/api/obj - ./seed:/opt/app-root/data diff --git a/web/vue.config.js b/web/vue.config.js index 24cc6d6a..7f2781d4 100644 --- a/web/vue.config.js +++ b/web/vue.config.js @@ -22,7 +22,7 @@ module.exports = { //This is for WEB_BASE_HREF = '/' specifically. //If having problems connecting, try adding: netsh http add iplisten 127.0.0.1 '^/api': { - target: "http://host.docker.internal:5000", + target: "http://api:5000", headers: { Connection: 'keep-alive', 'X-Forwarded-Host': 'localhost', From 0dd53773a470418ddb9784ef191983b9c22e251e Mon Sep 17 00:00:00 2001 From: Ronaldo Macapobre Date: Mon, 22 Jul 2024 17:40:16 -0700 Subject: [PATCH 12/13] revert code changes --- api/Controllers/LocationController.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/api/Controllers/LocationController.cs b/api/Controllers/LocationController.cs index 9ba70a33..ff2db7c9 100644 --- a/api/Controllers/LocationController.cs +++ b/api/Controllers/LocationController.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; @@ -32,8 +31,6 @@ public async Task>> GetLocationsAndCourtRooms() { var locations = await _locationService.GetLocations(); - Console.WriteLine("123"); - var locationList = locations.Select(location => new Location { Name = location.LongDesc, @@ -47,10 +44,10 @@ public async Task>> GetLocationsAndCourtRooms() foreach (var location in locationList) { location.CourtRooms = courtRooms.Where(cr => cr.Flex == location.LocationId && (cr.ShortDesc == "CRT" || cr.ShortDesc == "HGR")) - .Select(cr => new CourtRoom { LocationId = cr.Flex, Room = cr.Code, Type = cr.ShortDesc }).ToList(); + .Select(cr => new CourtRoom {LocationId = cr.Flex, Room = cr.Code, Type = cr.ShortDesc}).ToList(); } return Ok(locationList); } } -} +} \ No newline at end of file From e32d0fc4200eb7f85ba4594ab2d707f750e852f2 Mon Sep 17 00:00:00 2001 From: Wade Barnes Date: Tue, 23 Jul 2024 05:14:11 -0700 Subject: [PATCH 13/13] Update local folder mounts in docker-compose configuration - We missed switching a couple local folder mounts over to using `LOCAL_WORKSPACE_FOLDER`. Signed-off-by: Wade Barnes --- docker/docker-compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 8d2db1e4..3e51565f 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -75,7 +75,7 @@ services: - ${LOCAL_WORKSPACE_FOLDER-..}/jc-interface-client/:/opt/app-root/src/jc-interface-client - api-dev-bin:/opt/app-root/src/api/bin - api-dev-obj:/opt/app-root/src/api/obj - - ./seed:/opt/app-root/data + - ${LOCAL_WORKSPACE_FOLDER-.}/seed:/opt/app-root/data depends_on: - db command: > @@ -94,7 +94,7 @@ services: ports: - 5432:5432 volumes: - - ./tmp:/tmp2 + - ${LOCAL_WORKSPACE_FOLDER-.}/tmp:/tmp2 volumes: api-dev-bin: