Skip to content

Commit 3cd2b9d

Browse files
committed
chore(auth): add dockerfile and gateway guard
1 parent c1ffcc7 commit 3cd2b9d

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { loadConfig } from '@services/auth/src/config/env';
2+
import { createAuthMiddleware } from '@services/auth/src/middleware/auth.middleware';
3+
4+
type Middleware = (req: unknown, res: unknown, next: () => void) => void;
5+
6+
let guard: Middleware | null = null;
7+
8+
/**
9+
* Provides the auth middleware from the auth service so the API gateway can
10+
* reuse the same JWT verification logic.
11+
*/
12+
export function getAuthGuard(): Middleware {
13+
if (!guard) {
14+
const { authenticate } = createAuthMiddleware(loadConfig());
15+
guard = authenticate;
16+
}
17+
return guard;
18+
}

services/auth/Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# syntax=docker/dockerfile:1.5
2+
3+
FROM node:20-alpine AS base
4+
WORKDIR /app
5+
6+
RUN corepack enable
7+
8+
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json ./
9+
COPY packages/tooling/package.json packages/tooling/package.json
10+
COPY packages/logging/package.json packages/logging/package.json
11+
COPY packages/database/package.json packages/database/package.json
12+
COPY services/auth/package.json services/auth/package.json
13+
14+
RUN pnpm fetch --filter @scribemed/auth-service...
15+
16+
COPY . .
17+
18+
RUN pnpm install --filter @scribemed/auth-service... --prod --offline \
19+
&& pnpm --filter @scribemed/auth-service run build
20+
21+
EXPOSE 8085
22+
23+
CMD ["node", "services/auth/dist/index.js"]

0 commit comments

Comments
 (0)