-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
afaaebd
commit 18a59c4
Showing
139 changed files
with
26,629 additions
and
380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
schemaVersion: 2.2.2 | ||
metadata: | ||
name: coolstore-demo-node | ||
components: | ||
- name: tools | ||
container: | ||
image: registry.redhat.io/devspaces/udi-rhel8:3.13 | ||
endpoints: | ||
- exposure: public | ||
name: inventory-index | ||
targetPort: 8080 | ||
- exposure: none | ||
name: debug | ||
targetPort: 5858 | ||
memoryLimit: 6Gi | ||
memoryRequest: 4Gi | ||
cpuLimit: 2000m | ||
cpuRequest: 500m | ||
mountSources: true | ||
volumeMounts: | ||
- name: npm | ||
path: /home/user/.npm | ||
- name: npm | ||
volume: | ||
size: 1G |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,113 @@ | ||
# coolstore | ||
This is an example demo showing a retail store consisting of several microservices based on NodeJS. Project is an effort to demonstrate different NodeShift features. | ||
This is an example demo showing a retail store consisting of several microservices based on NodeJS. | ||
|
||
 | ||
A Coolstore app where users can buy some cool merchandise. | ||
|
||
|
||
- The UI is built with NodeJS and Angular. And the backend includes multiple Node.js services, such as | ||
- *Inventory* , The stores inventory, how much items are available etc. | ||
- *Catalog* , The products API | ||
- *Cart*, Stores all users carts and intiates the order process by sending a message to Orders | ||
- *Orders*, Completion and checking of orders | ||
- *Payments*, Checks whether an payment is successfull given a certain Credit Card. | ||
|
||
The demo is simple. Add an item to the cart. Checkout the item by going to the `Cart` tab. Add payment details. If the Card number starts with 4 the payment is successful else it will show status failed. this is a hard check in the payment service. | ||
|
||
Once done, goto the `Orders` tab. The Order status should be `In Progress`, refresh after a couple of seconds and the status will appear as `COMPLETED` or `FAILED`. It takes a couple of seconds as their is a wait timer in Payment service + the whole process is done in a reactive and event driven way using Kafka and Quarkus. | ||
|
||
 | ||
|
||
## Run Locally | ||
|
||
The whole demo application can be run locally for those using docker/podman. | ||
|
||
Run the docker-compose.yml file in the `deploy` directory | ||
|
||
``` | ||
podman compose up | ||
``` | ||
|
||
## Cluster Setup | ||
|
||
* Pre-Req: Have an Openshift cluster and log in using the `oc` client | ||
|
||
* Change into the deploy directory | ||
|
||
``` | ||
cd deploy | ||
``` | ||
|
||
### Create Project/Namespace | ||
|
||
oc new-project coolstore-dev | ||
|
||
### Kafka Related | ||
|
||
#### Install Kafka Operator | ||
|
||
oc apply -f kafka-operator.yaml | ||
|
||
|
||
#### Create instance | ||
|
||
#### NEED TO WAIT ON THE OPERATOR READINESS FIRST | ||
|
||
oc apply -f kafka-cluster-creation.yaml -n coolstore-dev | ||
|
||
#### create topics | ||
|
||
oc apply -f kafka-topics.yaml -n coolstore-dev | ||
|
||
### Redis Cache | ||
|
||
#### Create Redis Cache | ||
|
||
oc create -f redis-deployment.yaml -n coolstore-dev | ||
|
||
#### Create Service for Deployment | ||
|
||
oc apply -f redis-service.yaml -n coolstore-dev | ||
|
||
|
||
|
||
### Mongo DB Service | ||
|
||
#### Create Configmap to hold init.js | ||
|
||
oc create configmap mongo-db-init --from-file ./mongo-init.js -n coolstore-dev | ||
|
||
#### Create the MongoDB Instance | ||
|
||
oc create -f mongo-deployment.yaml -n coolstore-dev | ||
|
||
#### Create MongoDB Service | ||
oc apply -f mongo-service.yaml -n coolstore-dev | ||
|
||
|
||
## Node.s Service Deployment | ||
|
||
Each Node.js service has a npm script named `deploy` that uses the [Nodeshift cli](https://www.npmjs.com/package/nodeshift) to easily deploy your services to the cluster. | ||
|
||
In each node application directory, run with: | ||
|
||
``` | ||
npm run deploy | ||
``` | ||
|
||
There is also a runnable script in the `deploy` directory that will deploy all the Node.js services in the correct order. | ||
|
||
``` | ||
cd deploy/ | ||
./deploy-node-services.sh | ||
``` | ||
|
||
## Run Locally | ||
|
||
The whole demo application can be run locally for those using docker/podman. | ||
|
||
Run the docker-compose.yml file in the `deploy` directory | ||
|
||
``` | ||
podman compose up | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
./node_modules | ||
|
||
Dockerfile | ||
|
||
.dockerignore | ||
|
||
docker-compose.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
redis_host: 'localhost' | ||
redis_port: '6379' | ||
|
||
kafka_host: 'localhost' | ||
kafka_port: '9092' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Install the app dependencies in a full UBI Node docker image | ||
FROM registry.access.redhat.com/ubi8/nodejs-20:latest | ||
|
||
# Copy package.json | ||
COPY package*.json tsconfig.json .env ./ | ||
COPY src/ ./src | ||
|
||
USER 0 | ||
|
||
# Install npm packages | ||
RUN npm install | ||
|
||
# Run the build command becuase Typescript | ||
RUN npm run build | ||
|
||
# PRUNE DEV Deps | ||
RUN npm prune --omit=dev | ||
|
||
# Copy the dependencies into a Slim Node docker image | ||
FROM registry.access.redhat.com/ubi8/nodejs-20-minimal:latest | ||
|
||
# Install app dependencies from the other container | ||
COPY --from=0 /opt/app-root/src/node_modules /opt/app-root/src/node_modules | ||
COPY --from=0 /opt/app-root/src/dist /opt/app-root/src/dist | ||
COPY --from=0 /opt/app-root/src/package.json /opt/app-root/src/.env /opt/app-root/src/ | ||
|
||
ENV NODE_ENV production | ||
EXPOSE 7074 | ||
|
||
CMD ["npm", "start"] |
Oops, something went wrong.