Skip to content

Commit

Permalink
fix(apis-engagement): Minor updates around docker files and api spec
Browse files Browse the repository at this point in the history
  • Loading branch information
sullivanp-fxl committed Jan 3, 2023
1 parent ddde068 commit 649a2ce
Show file tree
Hide file tree
Showing 12 changed files with 192 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ jobs:
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- uses: nrwl/nx-set-shas@v3
- run: npm ci
- run: npm install --legacy-peer-deps
# - run: npx nx reset

- run: npm run build:tools

Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<NodeModulesRelativePath>$([System.IO.Path]::GetRelativePath($(MSBuildProjectDirectory), $(RepoRoot)))</NodeModulesRelativePath>
</PropertyGroup>
<Target Name="CheckNxModuleBoundaries" BeforeTargets="Build">
<Exec Command="node $(NodeModulesRelativePath)/node_modules\@nx-dotnet\core\src\tasks\check-module-boundaries.js --project-root $(MSBuildProjectDirRelativePath)"/>
<Exec Command="node $(NodeModulesRelativePath)/node_modules/@nx-dotnet/core/src/tasks/check-module-boundaries.js --project-root $(MSBuildProjectDirRelativePath)"/>
</Target>
</Project>
2 changes: 1 addition & 1 deletion apps/apis/engagement/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RUN npm install --legacy-peer-deps
RUN npx nx reset

RUN npm run build:tools
RUN npm run restore
RUN npx run restore

# Build the API
FROM setup AS build
Expand Down
9 changes: 4 additions & 5 deletions apps/apis/engagement/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
},
"docker": {
"configuration": "Debug",
"noDependencies": false,
"configFile": "../../../NuGet.Config"
"noDependencies": false
}
}
},
Expand All @@ -41,7 +40,7 @@
"publish": {
"executor": "@nx-dotnet/core:publish",
"selfContained": true,
"outputs": ["dist/apps/apis/engagement/publish"],
"output": ["dist/apps/apis/engagement/publish"],
"options": {
"configuration": "Debug",
"noDependencies": true
Expand All @@ -52,7 +51,7 @@
},
"docker": {
"configuration": "Debug",
"outputs": "/app/publish"
"output": "/app/publish"
}
}
},
Expand All @@ -70,7 +69,7 @@
"lint": {
"executor": "@nx-dotnet/core:format"
},
"server-api-sync": {
"server-api-sync": {
"executor": "@open-system/executors-dotnet:server-api-sync",
"options": {
"domainName": "engagement",
Expand Down
15 changes: 15 additions & 0 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "3.9"

services:
apis-engagement:
environment:
- NODE_ENV=development
- ASPNETCORE_ENVIRONMENT=Development
- ServiceConfig__Id=EngagementService.Api-9100
- ServiceConfig__Name=EngagementService
- ServiceConfig__DiscoveryAddress=http://consul:8500
- ServiceConfig__Address=apis-engagement
- ServiceConfig__Port=80
- ServiceConfig__HealthCheckEndPoint=health-check
ports:
- 9100:80
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3.9"

services:
apis-engagement:
container_name: apis-engagement
image: apis-engagement:latest
restart: on-failure
hostname: apis-engagement
build:
context: .
dockerfile: apps/apis/engagement/Dockerfile
environment:
NODE_ENV: development
networks:
- common_network

networks:
common_network:
driver: bridge
105 changes: 105 additions & 0 deletions libs/engagement/config/src/engagement.amqp-spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"asyncapi": "2.5.0",
"info": {
"title": "Engagement Service",
"version": "1.0.0",
"description": "This service is in charge of processing system engagement data",
"termsOfService": "https://sullivanpj.com/terms",
"contact": {
"name": "Patrick Sullivan",
"url": "https://sullivanpj.com",
"email": "Patrick.Joseph.Sullivan@ProtonMail.com"
},
"license": {
"name": "BSD 2-Clause License",
"url": "https://opensource.org/licenses/BSD-2-Clause"
}
},
"defaultContentType": "json",
"servers": {
"development": {
"url": "http://localhost:5100/services/engagement",
"description": "Local development server",
"protocol": "amqp",
"protocolVersion": "0.9.1"
},
"production": {
"url": "https://sullivanpj.com/services/engagement",
"description": "Cloud-based production environment",
"protocol": "amqp",
"protocolVersion": "0.9.1"
}
},
"channels": {
"reaction/add": {
"subscribe": {
"operationId": "onAddReactionReceived",
"message": {
"name": "ReactionModel",
"payload": {
"type": "object",
"additionalProperties": false,
"properties": {
"userId": {
"type": "string",
"example": "A unique Id used to identify the the current user"
},
"contentId": {
"type": "string",
"example": "A unique Id used to identify the content the user is reacting to"
},
"contentType": {
"type": "string",
"enum": ["article", "comment"]
},
"reactionType": {
"type": "string",
"enum": ["like", "dislike", "happy", "sad", "laugh", "cry"]
}
}
}
},
"bindings": {
"amqp": {
"is": "routingKey",
"exchange": { "name": "reaction", "type": "topic", "vhost": "/" },
"queue": { "name": "engagement" }
}
}
},
"publish": {
"operationId": "sendAddReaction",
"message": {
"name": "ReactionModel",
"payload": {
"type": "object",
"additionalProperties": false,
"properties": {
"userId": {
"type": "string",
"example": "A unique Id used to identify the the current user"
},
"contentId": {
"type": "string",
"example": "A unique Id used to identify the content the user is reacting to"
},
"contentType": {
"type": "string",
"enum": ["article", "comment"]
},
"reactionType": {
"type": "string",
"enum": ["like", "dislike", "happy", "sad", "laugh", "cry"]
}
}
}
},
"bindings": {
"amqp": {
"ack": false
}
}
}
}
}
}
43 changes: 36 additions & 7 deletions libs/engagement/config/src/engagement.api-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
}
],
"paths": {
"/article/{id}": {
"/articles/{articleId}/reactions": {
"parameters": [
{
"schema": {
"type": "string"
},
"name": "id",
"name": "articleId",
"in": "path",
"required": true,
"description": "The id of the article/page"
Expand Down Expand Up @@ -136,19 +136,34 @@
]
}
},
"/article/{id}/reaction/{type}": {
"/articles/{articleId}/reactions/{reactionType}": {
"parameters": [
{
"schema": {
"type": "string"
},
"name": "id",
"name": "articleId",
"in": "path",
"required": true,
"description": "The id of the article/page"
},
{
"$ref": "#/components/parameters/type"
"name": "reactionType",
"in": "path",
"required": true,
"schema": {
"type": "string",
"enum": [
"like",
"dislike",
"happy",
"sad",
"laugh",
"cry"
],
"example": "like"
},
"description": "The type of reaction the user had"
}
],
"get": {
Expand Down Expand Up @@ -621,8 +636,8 @@
}
},
"parameters": {
"type": {
"name": "type",
"reactionType": {
"name": "reactionType",
"in": "path",
"required": true,
"schema": {
Expand All @@ -647,6 +662,20 @@
"type": "string"
},
"description": "The id of the article/page"
},
"contentType": {
"name": "contentType",
"in": "path",
"required": true,
"schema": {
"type": "string",
"example": "article",
"enum": [
"article",
"comment"
]
},
"description": "The type of content the user is engaging with"
}
},
"securitySchemes": {}
Expand Down
2 changes: 1 addition & 1 deletion libs/engagement/config/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./lib/engagement-config";
export * from "./engagement.amqp-spec.json";
3 changes: 2 additions & 1 deletion libs/engagement/config/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"clean:libs": "rimraf dist/libs",
"clean:tools": "rimraf dist/tools",
"clean": "rimraf dist",
"restore": "nx g @nx-dotnet/core:restore",
"build:tools-executors-typescript": "npx nx run tools-executors-typescript:build:client-api-sync && npx nx run tools-executors-typescript:build:design-tokens-clean && npx nx run tools-executors-typescript:build:design-tokens-build",
"build:tools-generators-typescript": "npx nx run tools-generators-typescript:build:client-api",
"build:tools-executors-dotnet": "npx nx run tools-executors-dotnet:build:async-api-sync && npx nx run tools-executors-dotnet:build:server-api-sync && npx nx run tools-executors-dotnet:build:build",
Expand Down
11 changes: 5 additions & 6 deletions tools/asyncapi/rabbitmq/template/src/docker.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { File } from '@asyncapi/generator-react-sdk';
import { File } from "@asyncapi/generator-react-sdk";

export default function({ asyncapi, params }) {
export default function ({ asyncapi, params }) {
if (!asyncapi.hasComponents()) {
return null;
}

return (
<File name="Dockerfile">
{`FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
{`FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /app
Expand All @@ -30,8 +30,7 @@ FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "${params.namespace}.dll"]`
}
ENTRYPOINT ["dotnet", "${params.namespace}.dll"]`}
</File>
);
}

0 comments on commit 649a2ce

Please sign in to comment.