This repository has been archived by the owner on Jul 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from floriaaan/basket
feat(basket): add basket service to dev
- Loading branch information
Showing
37 changed files
with
7,118 additions
and
14 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
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,2 @@ | ||
node_modules | ||
build |
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,2 @@ | ||
REDIS_URL=redis://localhost:6379/0 | ||
PORT=50002 |
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,6 @@ | ||
node_modules/ | ||
dist/ | ||
bin/ | ||
*.env* | ||
!*.env.example | ||
|
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 @@ | ||
v18.12.0 |
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,33 @@ | ||
FROM node:18-alpine3.17 as builder | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copy the application code | ||
COPY ./basket/ . | ||
|
||
# Install dependencies | ||
RUN npm install | ||
|
||
# Copy the proto files - TODO: fix this, proto files should be copied from goodfood/services/proto | ||
COPY ./proto ./proto/ | ||
|
||
# Build the application | ||
RUN npm run build | ||
|
||
|
||
# Create a new image with the application | ||
FROM node:18-alpine3.17 as runner | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copy the application package | ||
COPY --from=builder /app/dist . | ||
COPY --from=builder /app/proto/ /proto/ | ||
|
||
# Expose the gRPC port | ||
EXPOSE 50002 | ||
|
||
# Start the server | ||
CMD [ "node", "index.js"] |
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,27 @@ | ||
# Basket Microservice | ||
|
||
| Informations | | ||
|-------------------------------------------| | ||
| **Port:** 50002 | | ||
| **Developer:** @Anatole-Godard | | ||
| **Status:** In progress | | ||
| **Last update:** 2023-08-14 | | ||
| **Language:** NodeJS | | ||
| **Dependencies:** TypeScript, gRPC, Redis | | ||
|
||
## gRPC Methods | ||
|
||
- Basket model: | ||
|
||
- `GetBasket`: Retrieves a basket by its user ID. | ||
- `AddProduct`: Adds a product to a basket. | ||
- `DeleteProduct`: Deletes a product from a basket. | ||
- `Reset`: Resets a basket. | ||
- `UpdateRestaurant`: Sets a restaurant to a basket. | ||
|
||
## Requirements | ||
|
||
To run this microservice, you will need to have the following installed on your system: | ||
|
||
- NodeJS (v18.12.0 or higher) (dev. with v18.12.0) | ||
- Redis (v6.2.6 or higher) (dev. with docker image `redis:6.2.6`) |
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,19 @@ | ||
services: | ||
basket-redis: | ||
image: redis:latest | ||
ports: | ||
- "6379:6379" | ||
volumes: | ||
- goodfood-basket-volume:/data | ||
networks: | ||
- goodfood-basket-network | ||
command: redis-server --appendonly yes | ||
environment: | ||
REDIS_USERNAME: redis | ||
REDIS_PASSWORD: password | ||
|
||
volumes: | ||
goodfood-basket-volume: | ||
|
||
networks: | ||
goodfood-basket-network: |
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,8 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: goodfood-basket-configmap | ||
labels: | ||
app: goodfood-basket | ||
data: | ||
port: "50002" |
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,31 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: goodfood-basket | ||
labels: | ||
app: goodfood-basket | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: goodfood-basket | ||
template: | ||
metadata: | ||
labels: | ||
app: goodfood-basket | ||
spec: | ||
containers: | ||
- name: goodfood-basket | ||
image: floriaaan/goodfood-basket:1.0.0 | ||
imagePullPolicy: Always | ||
resources: | ||
limits: | ||
memory: "128Mi" | ||
cpu: "200m" | ||
env: | ||
- name: PORT | ||
valueFrom: | ||
configMapKeyRef: | ||
name: goodfood-basket-configmap | ||
key: port | ||
ports: | ||
- containerPort: 50002 |
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,18 @@ | ||
apiVersion: autoscaling/v2 | ||
kind: HorizontalPodAutoscaler | ||
metadata: | ||
name: goodfood-basket-hpa | ||
spec: | ||
scaleTargetRef: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: goodfood-basket | ||
minReplicas: 1 | ||
maxReplicas: 3 | ||
metrics: | ||
- type: Resource | ||
resource: | ||
name: cpu | ||
target: | ||
type: Utilization | ||
averageUtilization: 50 |
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,17 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: goodfood-basket | ||
spec: | ||
ingressClassName: nginx | ||
rules: | ||
- host: basket.localdev.me | ||
http: | ||
paths: | ||
- pathType: Prefix | ||
backend: | ||
service: | ||
name: goodfood-basket | ||
port: | ||
number: 50002 | ||
path: / |
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,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: goodfood-basket | ||
spec: | ||
selector: | ||
app: goodfood-basket | ||
ports: | ||
- name: "grpc" | ||
port: 50002 | ||
targetPort: 50002 | ||
status: | ||
loadBalancer: {} |
Oops, something went wrong.