Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalize local dev env setup #4

Merged
merged 14 commits into from
Jul 23, 2024
Merged
9 changes: 5 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
"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": {}

},
"postCreateCommand": "./docker/manage build",
"customizations": {
"vscode": {
"extensions": [
Expand All @@ -33,5 +31,8 @@
}
}
},
"remoteUser": "root"
"remoteUser": "root",
"containerEnv": {
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
*.json text eol=lf
**/s2i/bin/* text eol=lf
**/root/**/* text eol=lf
/docker/manage text eol=lf
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"configurations": [
{
"name": ".NET Core Docker Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickRemoteProcess}",
"pipeTransport": {
"pipeProgram": "docker",
"pipeArgs": ["exec", "-i", "jasper-api-1"],
"debuggerPath": "/vsdbg/vsdbg",
"pipeCwd": "${workspaceRoot}",
"quoteArgs": false
},
"sourceFileMap": {
"/opt/app-root/src": "${workspaceRoot}/"
}
}
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions api/Controllers/LocationController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
Expand Down Expand Up @@ -50,4 +50,4 @@ public async Task<ActionResult<List<Location>>> GetLocationsAndCourtRooms()
return Ok(locationList);
}
}
}
}
55 changes: 49 additions & 6 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,50 @@
# 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.

## 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. Building the project.

```
./manage build
```

4. Starting the project.

```
./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
```

## Using the Application

- 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

## Management Script

The `manage` script wraps the Docker process in easy to use commands.

To get full usage information on the script, run:

```
./manage -h
```
Expand All @@ -14,34 +54,37 @@ 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
```

## 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/
- 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/
2 changes: 1 addition & 1 deletion docker/api/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -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
RUN curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l /vsdbg
41 changes: 29 additions & 12 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -15,9 +15,26 @@ services:
depends_on:
- api

web-dev:
image: "${COMPOSE_PROJECT_NAME}-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:
- "${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

api:
image: scv-api
environment:
image: "${COMPOSE_PROJECT_NAME}-api"
environment:
- ASPNETCORE_URLS=${ASPNETCORE_URLS}
- FileServicesClient__Username=${FileServicesClientUsername}
- FileServicesClient__Password=${FileServicesClientPassword}
Expand Down Expand Up @@ -53,12 +70,12 @@ 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
- scv-api-dev-bin:/opt/app-root/src/api/bin
- scv-api-dev-obj:/opt/app-root/src/api/obj
- ./seed:/opt/app-root/data
- ${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
- ${LOCAL_WORKSPACE_FOLDER-.}/seed:/opt/app-root/data
depends_on:
- db
command: >
Expand All @@ -77,8 +94,8 @@ services:
ports:
- 5432:5432
volumes:
- ./tmp:/tmp2
- ${LOCAL_WORKSPACE_FOLDER-.}/tmp:/tmp2

volumes:
scv-api-dev-bin:
scv-api-dev-obj:
api-dev-bin:
api-dev-obj:
Loading
Loading