The DevOps Knowledge Share UI is a React application containing a simple form and table which allows users to submit links to articles, blogs, or sites containing knowledge they would like to share with others. The application works in conjunction with the DevOps Knowledge Share API, a simple Spring Boot application that provides a RESTful API for the DevOps Knowledge Share application. The purpose of DKS UI is to act as an example of a simple React application allowing us to demonstrate how one might build, test, and deploy a React application.
Note: Please note that the contents of this repo were sanitized and some links/references may no longer function
- nvm (
brew install nvm
) - Node 20.x (
nvm install
&nvm use
- These commands will read the.nvmrc
file included in the project)- npm 10.x
- Docker
-
Change your working directory to application root folder
-
Install dependencies using below command
npm install
-
Start the DevOps Knowledge Share API locally following the instructions in that project.
-
Set the
DKS_API_BASE_URL
environment variable for API communication.# if running on Host machine export DKS_API_BASE_URL=http://localhost:8080 # if running on Remote Container with VS Code export DKS_API_BASE_URL=<your host machine ip>
-
To run the application with hot reloading, run the below command
npm run dev
-
Navigate to
http://localhost:3000
to view your application -
To execute testcases, run the below command
npm run test
-
To execute contract tests, run the below command
⚠️ NOTE: Not currently functional
npm run testContract
- To execute functional tests, run the below command.
⚠️ NOTE: Not currently functional
npm run wdio-local
-
Make sure that you have Docker installed and running
-
Use the
dockerBuild
npm script to build your Docker imagenpm run dockerBuild
-
Use the
dockerRun
npm script to start a container with port3000
forwarded to your local machinenpm run dockerRun
-
Navigate to
http://localhost:3000
to view your application
-
Get VSCode
-
Add Remote Code - Containers Extension to VSCode
-
Make sure you have Docker Desktop installed and running
-
Make sure to setup your SSH Agent. Follow this guide
-
When opening the project with VSCode it should automatically startup your remote container environment
- If not, go to View -> Command Palette and search for Remote-Container: Open Folder in Container
-
Now that you have your environment up and running follow the above Run Locally steps to get your app up and running.
The Remote Container environment is codified according to the
.devcontainer/devcontainer.json
specifications. This definition is shared across the team via Git to produce a consistent development environment.
More info on Remote Containers
We currently have an example feature flag that is set via the environment variable ENABLE_IMAGE_URL
.
When set, the application will render a new Image Url
field as an input. This is meant to serve as an example of
merging in code that is not ready to be released and delivering work in small batches.
- If running locally
- Prior to starting the app make sure you have ran
export ENABLE_IMAGE_URL=true
- Prior to starting the app make sure you have ran
- If deploying via the Helm Chart
npm run helm -- --set featureFlags.enableImageUrl=true
-
Open http://localhost:3000 with your browser to see the result.
-
API routes can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in
pages/api/hello.ts
. -
The
pages/api
directory is mapped to/api/*
. Files in this directory are treated as API routes instead of React pages.