-
Couldn't load subscription status.
- Fork 101
feat: initialize POS service #3509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
8038fca
c9954de
6b71cbb
2df8131
726074b
0d4a2ba
1d0b5d1
8b297e8
28d60f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ services: | |
| read_only: true | ||
| environment: | ||
| NODE_ENV: ${NODE_ENV:-development} | ||
| INSTANCE_NAME: CLOUD-NINE | ||
| INSTANCE_NAME: HAPPY-LIFE | ||
| TRUST_PROXY: ${TRUST_PROXY} | ||
| LOG_LEVEL: debug | ||
| CARD_SERVICE_PORT: 3007 | ||
|
|
@@ -32,6 +32,38 @@ services: | |
| interval: 30s | ||
| retries: 1 | ||
| timeout: 3s | ||
| happy-life-bank-point-of-sale: | ||
| hostname: happy-life-bank-point-of-sale | ||
| image: rafiki-point-of-sale | ||
| build: | ||
| context: ../.. | ||
| dockerfile: ./packages/point-of-sale/Dockerfile.dev | ||
| restart: always | ||
| networks: | ||
| - rafiki | ||
| ports: | ||
| - '3007:3007' | ||
|
||
| volumes: | ||
| - type: bind | ||
| source: ../../packages/point-of-sale/src | ||
| target: /home/rafiki/packages/point-of-sale/src | ||
| read_only: true | ||
| environment: | ||
| NODE_ENV: ${NODE_ENV:-development} | ||
| INSTANCE_NAME: HAPPY-LIFE | ||
| TRUST_PROXY: ${TRUST_PROXY} | ||
| LOG_LEVEL: debug | ||
| CARD_SERVICE_PORT: 3007 | ||
|
||
| DATABASE_URL: postgresql://happy_life_bank_point_of_sale:happy_life_bank_point_of_sale@shared-database/happy_life_bank_point_of_sale | ||
| depends_on: | ||
| - shared-database | ||
| healthcheck: | ||
| test: ["CMD", "wget", "--spider", "http://localhost:3007/healthz"] | ||
| start_period: 60s | ||
| start_interval: 5s | ||
| interval: 30s | ||
| retries: 1 | ||
| timeout: 3s | ||
| happy-life-mock-ase: | ||
| hostname: happy-life-bank | ||
| image: rafiki-mock-ase | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| FROM node:20-alpine3.20 | ||
|
|
||
| RUN adduser -D rafiki | ||
| WORKDIR /home/rafiki | ||
|
|
||
| # Install Corepack and pnpm as the Rafiki user | ||
| USER rafiki | ||
| RUN mkdir -p /home/rafiki/.local/bin | ||
| ENV PATH="/home/rafiki/.local/bin:$PATH" | ||
| RUN corepack enable --install-directory ~/.local/bin | ||
| RUN corepack prepare [email protected] --activate | ||
| COPY pnpm-lock.yaml package.json pnpm-workspace.yaml .npmrc tsconfig.json tsconfig.build.json ./ | ||
|
|
||
| # Fetch the pnpm dependencies, but use a local cache. | ||
| RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ | ||
| pnpm fetch \ | ||
| | grep -v "cross-device link not permitted\|Falling back to copying packages from store" | ||
|
|
||
| # Copy the source code and chown the relevant folders back to the Rafiki user | ||
| USER root | ||
| COPY . ./ | ||
| RUN chown -v -R rafiki:rafiki /home/rafiki/localenv | ||
| RUN chown -v -R rafiki:rafiki /home/rafiki/packages | ||
| RUN chown -v -R rafiki:rafiki /home/rafiki/test | ||
|
|
||
| # As the Rafiki user, install the rest of the dependencies and build the source code | ||
| USER rafiki | ||
| RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ | ||
| pnpm install \ | ||
| --recursive \ | ||
| --offline \ | ||
| --frozen-lockfile | ||
| RUN pnpm --filter point-of-sale build:deps | ||
|
|
||
| CMD pnpm --filter point-of-sale dev |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| FROM node:20-alpine3.20 AS base | ||
|
|
||
| WORKDIR /home/rafiki | ||
|
|
||
| ENV PNPM_HOME="/pnpm" | ||
| ENV PATH="$PNPM_HOME:$PATH" | ||
|
|
||
| RUN corepack enable | ||
| RUN corepack prepare [email protected] --activate | ||
|
|
||
| COPY pnpm-lock.yaml ./ | ||
|
|
||
| RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ | ||
| pnpm fetch \ | ||
| | grep -v "cross-device link not permitted\|Falling back to copying packages from store" | ||
|
|
||
| FROM base AS prod-deps | ||
|
|
||
| COPY package.json pnpm-workspace.yaml .npmrc ./ | ||
| COPY packages/point-of-sale/knexfile.js ./packages/point-of-sale/knexfile.js | ||
| COPY packages/point-of-sale/package.json ./packages/point-of-sale/package.json | ||
| COPY packages/token-introspection/package.json ./packages/token-introspection/package.json | ||
|
|
||
| RUN pnpm clean | ||
| RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ | ||
| pnpm install \ | ||
| --recursive \ | ||
| --prefer-offline \ | ||
| --frozen-lockfile \ | ||
| --prod \ | ||
| | grep -v "cross-device link not permitted\|Falling back to copying packages from store" | ||
|
|
||
| FROM base AS builder | ||
|
|
||
| COPY package.json pnpm-workspace.yaml .npmrc tsconfig.json tsconfig.build.json ./ | ||
| COPY packages/point-of-sale ./packages/point-of-sale | ||
| COPY packages/token-introspection ./packages/token-introspection | ||
|
|
||
| RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ | ||
| pnpm install \ | ||
| --recursive \ | ||
| --offline \ | ||
| --frozen-lockfile | ||
| RUN pnpm --filter point-of-sale build | ||
|
|
||
| FROM node:20-alpine3.20 AS runner | ||
|
|
||
| # Since this is from a fresh image, we need to first create the Rafiki user | ||
| RUN adduser -D rafiki | ||
| WORKDIR /home/rafiki | ||
|
|
||
| COPY --from=prod-deps /home/rafiki/node_modules ./node_modules | ||
| COPY --from=prod-deps /home/rafiki/packages/point-of-sale/node_modules ./packages/point-of-sale/node_modules | ||
| COPY --from=prod-deps /home/rafiki/packages/point-of-sale/package.json ./packages/point-of-sale/package.json | ||
| COPY --from=prod-deps /home/rafiki/packages/token-introspection/node_modules ./packages/token-introspection/node_modules | ||
| COPY --from=prod-deps /home/rafiki/packages/token-introspection/package.json ./packages/token-introspection/package.json | ||
| COPY --from=prod-deps /home/rafiki/packages/point-of-sale/knexfile.js ./packages/point-of-sale/knexfile.js | ||
|
|
||
| COPY --from=builder /home/rafiki/packages/point-of-sale/migrations/ ./packages/point-of-sale/migrations | ||
| COPY --from=builder /home/rafiki/packages/point-of-sale/dist ./packages/point-of-sale/dist | ||
| COPY --from=builder /home/rafiki/packages/token-introspection/dist ./packages/token-introspection/dist | ||
| COPY --from=builder /home/rafiki/packages/point-of-sale/knexfile.js ./packages/point-of-sale/knexfile.js | ||
|
|
||
| USER root | ||
|
|
||
| # For additional paranoia, we make it so that the Rafiki user has no write access to the packages | ||
| RUN chown -R :rafiki /home/rafiki/packages | ||
| RUN chmod -R 750 /home/rafiki/packages |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Update with your config settings. | ||
|
|
||
| /** | ||
| * @type { Object.<string, import("knex").Knex.Config> } | ||
| */ | ||
| module.exports = { | ||
| development: { | ||
| client: 'postgresql', | ||
| connection: { | ||
| database: 'pos', | ||
| user: 'postgres', | ||
| password: 'password' | ||
| } | ||
| }, | ||
|
|
||
| testing: { | ||
| client: 'postgresql', | ||
| connection: { | ||
| database: 'pos_testing', | ||
| user: 'postgres', | ||
| password: 'password' | ||
| }, | ||
| pool: { | ||
| min: 2, | ||
| max: 10 | ||
| }, | ||
| migrations: { | ||
| tableName: 'pos_knex_migrations' | ||
| } | ||
| }, | ||
|
|
||
| production: { | ||
| client: 'postgresql', | ||
| connection: process.env.POS_DATABASE_URL, | ||
| pool: { | ||
| min: 2, | ||
| max: 10 | ||
| }, | ||
| migrations: { | ||
| tableName: 'pos_knex_migrations' | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| { | ||
| "name": "point-of-sale", | ||
| "version": "1.0.0", | ||
| "description": "", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1", | ||
| "knex": "knex", | ||
| "dev": "ts-node-dev --inspect=0.0.0.0:9229 --respawn --transpile-only src/index.ts", | ||
| "build": "pnpm build:deps && pnpm clean && tsc --build tsconfig.json", | ||
| "build:deps": "pnpm --filter token-introspection build", | ||
| "clean": "rm -fr dist/" | ||
| }, | ||
| "keywords": [], | ||
| "author": "", | ||
| "license": "ISC", | ||
| "dependencies": { | ||
| "@adonisjs/fold": "^8.2.0", | ||
| "@apollo/server": "^4.11.2", | ||
| "@koa/cors": "^5.0.0", | ||
| "@koa/router": "^12.0.2", | ||
| "dotenv": "^16.4.7", | ||
| "knex": "^3.1.0", | ||
| "koa": "^3.0.0", | ||
| "koa-bodyparser": "^4.4.1", | ||
| "objection": "^3.1.5", | ||
| "objection-db-errors": "^1.1.2", | ||
| "pg": "^8.11.3", | ||
| "pino": "^8.19.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/koa": "2.15.0", | ||
| "@types/koa-bodyparser": "^4.3.12", | ||
| "@types/koa__cors": "^5.0.0", | ||
| "@types/koa__router": "^12.0.4" | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto with the happy-life-bank comment, need to update the env var name and port number.