Skip to content

Commit e2d4cde

Browse files
authored
chore: add card-service and pos-service image build steps in CI (#3657)
* Added card-service and point-of-sale images when pushing to registry * Added dockerfile.prod for card-service * Added spectral to validate card-service open api specs * Fix on building the packages * Fixed dockerfile * Added token-introspection * trying to fix crypto issue * Another try to fix card-service pipeline * Still trying * Testing if crypto is actually the issue here * Trying to debug * Added @types/node so it can see the crypto package * Updated yaml for card-service, removed unnecessary changes * Fix format * Updated axios version of pos * Added tags to card-service.yaml * Removed token-introspection from pos and card services * Added command to run pos and card services in docker file
1 parent f49eaa9 commit e2d4cde

File tree

7 files changed

+163
-75
lines changed

7 files changed

+163
-75
lines changed

.github/workflows/node-build.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ jobs:
9292
- uses: actions/checkout@v4
9393
- uses: ./.github/workflows/rafiki/env-setup
9494
- run: pnpm --filter card-service test:ci
95+
- run: pnpm --filter card-service build
96+
- name: AsyncAPI extension
97+
run: |
98+
echo "{\"extends\":[\"spectral:oas\",\"spectral:asyncapi\"]}" >> .spectral.json
99+
- name: Validate Open API specs
100+
run: |
101+
npx @stoplight/spectral-cli lint ./packages/card-service/src/openapi/specs/*.yaml
95102
96103
point-of-sale:
97104
runs-on: ubuntu-latest
@@ -100,7 +107,7 @@ jobs:
100107
steps:
101108
- uses: actions/checkout@v4
102109
- uses: ./.github/workflows/rafiki/env-setup
103-
- run: pnpm --filter point-of-sale build:deps
110+
- run: pnpm --filter point-of-sale build
104111
- run: pnpm --filter point-of-sale test:ci
105112

106113
mock-account-servicing-entity:
@@ -426,6 +433,8 @@ jobs:
426433
- auth
427434
- backend
428435
- frontend
436+
- card-service
437+
- point-of-sale
429438
steps:
430439
- name: Checkout code
431440
uses: actions/checkout@v4
@@ -461,6 +470,8 @@ jobs:
461470
- auth
462471
- backend
463472
- frontend
473+
- card-service
474+
- point-of-sale
464475
steps:
465476
- uses: actions/checkout@v4
466477
- name: Fetch docker image from cache
@@ -497,6 +508,8 @@ jobs:
497508
- auth
498509
- backend
499510
- frontend
511+
- card-service
512+
- point-of-sale
500513
steps:
501514
- uses: actions/checkout@v4
502515
- name: Fetch docker image from cache
@@ -529,6 +542,8 @@ jobs:
529542
- auth
530543
- backend
531544
- frontend
545+
- card-service
546+
- point-of-sale
532547
steps:
533548
- uses: actions/checkout@v4
534549
- uses: ./.github/actions/image-push
@@ -550,6 +565,8 @@ jobs:
550565
- auth
551566
- backend
552567
- frontend
568+
- card-service
569+
- point-of-sale
553570
steps:
554571
- uses: actions/checkout@v4
555572
- name: Push manifest list
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
FROM node:20-alpine3.20 AS base
2+
3+
WORKDIR /home/rafiki
4+
5+
ENV PNPM_HOME="/pnpm"
6+
ENV PATH="$PNPM_HOME:$PATH"
7+
8+
RUN corepack enable
9+
RUN corepack prepare [email protected] --activate
10+
11+
COPY pnpm-lock.yaml ./
12+
13+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
14+
pnpm fetch \
15+
| grep -v "cross-device link not permitted\|Falling back to copying packages from store"
16+
17+
FROM base AS prod-deps
18+
19+
COPY package.json pnpm-workspace.yaml .npmrc ./
20+
COPY packages/card-service/knexfile.js ./packages/card-service/knexfile.js
21+
COPY packages/card-service/package.json ./packages/card-service/package.json
22+
RUN pnpm clean
23+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
24+
pnpm install \
25+
--recursive \
26+
--prefer-offline \
27+
--frozen-lockfile \
28+
--prod \
29+
| grep -v "cross-device link not permitted\|Falling back to copying packages from store"
30+
31+
FROM base AS builder
32+
33+
COPY package.json pnpm-workspace.yaml .npmrc tsconfig.json tsconfig.build.json ./
34+
COPY packages/card-service ./packages/card-service
35+
36+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
37+
pnpm install \
38+
--recursive \
39+
--offline \
40+
--frozen-lockfile
41+
RUN pnpm --filter card-service build
42+
43+
FROM node:20-alpine3.20 AS runner
44+
45+
# Since this is from a fresh image, we need to first create the Rafiki user
46+
RUN adduser -D rafiki
47+
WORKDIR /home/rafiki
48+
49+
COPY --from=prod-deps /home/rafiki/node_modules ./node_modules
50+
COPY --from=prod-deps /home/rafiki/packages/card-service/node_modules ./packages/card-service/node_modules
51+
COPY --from=prod-deps /home/rafiki/packages/card-service/package.json ./packages/card-service/package.json
52+
COPY --from=prod-deps /home/rafiki/packages/card-service/knexfile.js ./packages/card-service/knexfile.js
53+
54+
COPY --from=builder /home/rafiki/packages/card-service/migrations/ ./packages/card-service/migrations
55+
COPY --from=builder /home/rafiki/packages/card-service/dist ./packages/card-service/dist
56+
COPY --from=builder /home/rafiki/packages/card-service/knexfile.js ./packages/card-service/knexfile.js
57+
58+
USER root
59+
60+
# For additional paranoia, we make it so that the Rafiki user has no write access to the packages
61+
RUN chown -R :rafiki /home/rafiki/packages
62+
RUN chmod -R 750 /home/rafiki/packages
63+
64+
USER rafiki
65+
CMD ["node", "/home/rafiki/packages/card-service/dist/index.js"]

packages/card-service/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
{
22
"name": "card-service",
3-
"main": "dist/index.js",
4-
"types": "dist/index.d.ts",
5-
"files": [
6-
"dist/**/*"
7-
],
3+
"main": "index.js",
84
"scripts": {
95
"build": "pnpm clean && tsc --build tsconfig.json",
106
"clean": "rm -fr dist/",
@@ -37,6 +33,7 @@
3733
"@types/koa-bodyparser": "^4.3.12",
3834
"@types/koa__cors": "^5.0.0",
3935
"@types/koa__router": "^12.0.4",
36+
"@types/node": "^20.14.15",
4037
"@types/uuid": "^9.0.8",
4138
"jest-environment-node": "^29.7.0",
4239
"nock": "14.0.0-beta.19",

packages/card-service/src/openapi/specs/card-server.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ openapi: 3.0.3
22
info:
33
title: Card Service API
44
version: 1.0.0
5+
description: Card Service API specs
6+
contact:
7+
8+
tags:
9+
- name: payment
10+
description: Operations related to payments
511
paths:
612
/payment:
713
post:
@@ -96,6 +102,9 @@ paths:
96102
type: string
97103
'500':
98104
description: Internal server error
105+
description: 'POS service calls this endpoint to initiate a payment request.'
106+
tags:
107+
- payment
99108
/payment-event:
100109
post:
101110
summary: Handle payment event result from backend
@@ -158,3 +167,8 @@ paths:
158167
description: Payment event accepted
159168
'400':
160169
description: Malformed request body
170+
'404':
171+
description: Request not found
172+
description: 'Rafiki backend calls this endpoint to send the payment result.'
173+
tags:
174+
- payment

packages/point-of-sale/Dockerfile.prod

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ FROM base AS prod-deps
1919
COPY package.json pnpm-workspace.yaml .npmrc ./
2020
COPY packages/point-of-sale/knexfile.js ./packages/point-of-sale/knexfile.js
2121
COPY packages/point-of-sale/package.json ./packages/point-of-sale/package.json
22-
COPY packages/token-introspection/package.json ./packages/token-introspection/package.json
2322

2423
RUN pnpm clean
2524
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
@@ -34,7 +33,6 @@ FROM base AS builder
3433

3534
COPY package.json pnpm-workspace.yaml .npmrc tsconfig.json tsconfig.build.json ./
3635
COPY packages/point-of-sale ./packages/point-of-sale
37-
COPY packages/token-introspection ./packages/token-introspection
3836

3937
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
4038
pnpm install \
@@ -52,17 +50,17 @@ WORKDIR /home/rafiki
5250
COPY --from=prod-deps /home/rafiki/node_modules ./node_modules
5351
COPY --from=prod-deps /home/rafiki/packages/point-of-sale/node_modules ./packages/point-of-sale/node_modules
5452
COPY --from=prod-deps /home/rafiki/packages/point-of-sale/package.json ./packages/point-of-sale/package.json
55-
COPY --from=prod-deps /home/rafiki/packages/token-introspection/node_modules ./packages/token-introspection/node_modules
56-
COPY --from=prod-deps /home/rafiki/packages/token-introspection/package.json ./packages/token-introspection/package.json
5753
COPY --from=prod-deps /home/rafiki/packages/point-of-sale/knexfile.js ./packages/point-of-sale/knexfile.js
5854

5955
COPY --from=builder /home/rafiki/packages/point-of-sale/migrations/ ./packages/point-of-sale/migrations
6056
COPY --from=builder /home/rafiki/packages/point-of-sale/dist ./packages/point-of-sale/dist
61-
COPY --from=builder /home/rafiki/packages/token-introspection/dist ./packages/token-introspection/dist
6257
COPY --from=builder /home/rafiki/packages/point-of-sale/knexfile.js ./packages/point-of-sale/knexfile.js
6358

6459
USER root
6560

6661
# For additional paranoia, we make it so that the Rafiki user has no write access to the packages
6762
RUN chown -R :rafiki /home/rafiki/packages
6863
RUN chmod -R 750 /home/rafiki/packages
64+
65+
USER rafiki
66+
CMD ["node", "/home/rafiki/packages/point-of-sale/dist/index.js"]

packages/point-of-sale/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
"generate": "graphql-codegen --config codegen.yml",
1313
"knex": "knex",
1414
"dev": "ts-node-dev --inspect=0.0.0.0:9229 --respawn --transpile-only src/index.ts",
15-
"build": "pnpm build:deps && pnpm clean && tsc --build tsconfig.json",
16-
"build:deps": "pnpm --filter token-introspection build",
15+
"build": "pnpm clean && tsc --build tsconfig.json",
1716
"clean": "rm -fr dist/"
1817
},
1918
"keywords": [],
@@ -25,7 +24,7 @@
2524
"@faker-js/faker": "^8.4.1",
2625
"@koa/cors": "^5.0.0",
2726
"@koa/router": "^12.0.2",
28-
"axios": "1.8.2",
27+
"axios": "1.12.0",
2928
"dotenv": "^16.4.7",
3029
"graphql": "^16.11.0",
3130
"json-canonicalize": "^1.0.6",

0 commit comments

Comments
 (0)