Deploy notification service #1

Merged
boutmoun merged 4 commits from deploy-notification-service into main 2026-11-02 08:39:59 +00:00
4 changed files with 65 additions and 79 deletions
+8 -1
View File
@@ -4,7 +4,10 @@ NODE_ENV=development
PORT=4000
HOST=0.0.0.0
PUBLIC_BASE_URL=http://localhost:4000
PUBLIC_APP_URL=https://oudelaa.com
# Browser/deep-link origin used for user-facing web links.
PUBLIC_WEB_URL=https://oudelaa.com
# Optional separate origin for share links; defaults to PUBLIC_WEB_URL.
SHARE_BASE_URL=https://oudelaa.com
RESPONSE_ENVELOPE_ENABLED=false
SWAGGER_ENABLED=true
GLOBAL_PREFIX=api/v1
@@ -120,6 +123,8 @@ NOTIFICATION_RMQ_PREFETCH=10
STORAGE_PROVIDER=local
MEDIA_ACCESS_MODE=direct
# Expiration for presigned S3 URLs (1 second to 7 days).
SIGNED_URL_EXPIRES_SECONDS=86400
STORAGE_BASE_PATH=uploads
# In Docker/production with local storage, mount a persistent volume to /app/uploads
# or to the runtime path resolved from STORAGE_BASE_PATH.
@@ -130,6 +135,8 @@ S3_REGION=auto
S3_ENDPOINT=
S3_ACCESS_KEY_ID=
S3_SECRET_ACCESS_KEY=
# Public CDN/bucket origin used to construct direct object URLs (no trailing slash).
S3_PUBLIC_BASE_URL=
S3_FORCE_PATH_STYLE=false
# Optional: writes then deletes a tiny health object when GET /media/health runs.
# Keep false unless you explicitly want to verify S3 write permissions.
+30 -57
View File
@@ -1,22 +1,22 @@
name: Deploy To Ghaymah
name: API Gateway CI
on:
pull_request:
branches: [main]
push:
branches: [main, deploy-notification-service]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: oudelaa-production-${{ github.ref }}
group: oudelaa-api-ci-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
quality:
quality-and-tests:
name: Build, lint, and test
runs-on: ubuntu-latest
services:
mongodb:
@@ -41,12 +41,13 @@ jobs:
- name: Install locked dependencies
run: npm ci
- name: Static quality gates
run: |
npm run lint
npm run build
- name: Build API Gateway and project artifacts
run: npm run build
- name: Unit, integration, and coverage gates
- name: Lint
run: npm run lint
- name: Unit and coverage tests
run: npm run test:coverage
- name: Upload coverage report
@@ -69,50 +70,22 @@ jobs:
- name: Dependency security audit
run: npm audit --audit-level=high
- name: Verify production image
run: docker build --tag oudelaa-api:${{ github.sha }} .
deploy:
needs: quality
verify-image:
name: Build API Gateway image
needs: quality-and-tests
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create .ghaymah.json
- name: Verify Docker runner access
run: docker info
- name: Build CI image locally
run: docker build --tag oudelaa-api:${{ github.sha }} .
- name: Verify image entrypoint and media tools
run: |
cat > .ghaymah.json << 'EOF'
{
"id": "da97e2b8-0b2c-49d8-a672-1d162c8e15f1",
"name": "oudelaa-api",
"projectId": "1137d5bd-c997-4654-9d01-3c7a88b07269",
"ports": [
{
"expose": true,
"number": 4000
}
],
"publicAccess": {
"enabled": true
},
"resourceTier": "g1.nano",
"dockerFileName": "Dockerfile"
}
EOF
cat .ghaymah.json
- name: Install Ghaymah CLI
run: curl -sSl https://cli.ghaymah.systems/install.sh | bash
- name: Login to Ghaymah
run: |
$HOME/ghaymah/bin/gy auth login \
--email "${{ secrets.GHAYMAH_EMAIL }}" \
--password "${{ secrets.GHAYMAH_PW }}" \
--no-auto-update
- name: Deploy
run: $HOME/ghaymah/bin/gy resource app launch --no-auto-update
docker image inspect oudelaa-api:${{ github.sha }} --format '{{json .Config.Cmd}}' | grep -F 'dist/apps/api-gateway/apps/api-gateway/src/main.js'
docker run --rm --entrypoint ffmpeg oudelaa-api:${{ github.sha }} -version
docker run --rm --entrypoint ffprobe oudelaa-api:${{ github.sha }} -version
+24 -20
View File
@@ -1,4 +1,4 @@
FROM node:20-alpine AS builder
FROM node:20-alpine AS build
WORKDIR /app
@@ -6,34 +6,38 @@ COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
RUN npm run build:gateway \
&& test -f dist/apps/api-gateway/apps/api-gateway/src/main.js
FROM node:20-alpine AS runner
FROM node:20-alpine AS production-dependencies
WORKDIR /app
ENV NODE_ENV=production
ENV VIDEO_PROCESSING_FFMPEG_PATH=/usr/bin/ffmpeg
ENV NODE_OPTIONS=--enable-source-maps
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.edge.kernel.org/g' /etc/apk/repositories \
&& apk update \
&& apk add --no-cache ffmpeg tini
COPY package*.json ./
RUN npm ci --omit=dev \
&& npm cache clean --force
RUN npm ci --omit=dev && npm cache clean --force
COPY --from=builder --chown=node:node /app/dist ./dist
RUN mkdir -p /app/uploads \
&& chown -R node:node /app/uploads
FROM node:20-alpine AS runtime
WORKDIR /app
ENV NODE_ENV=production \
PORT=4000 \
HOST=0.0.0.0
# ffmpeg includes ffprobe on Alpine and is required when media processing is enabled.
RUN apk add --no-cache ffmpeg \
&& mkdir -p /app/uploads \
&& chown -R node:node /app/uploads
COPY --from=production-dependencies /app/node_modules ./node_modules
COPY --from=build /app/dist/apps/api-gateway ./dist/apps/api-gateway
COPY package.json ./
USER node
EXPOSE 4000
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD wget -q -O /dev/null http://127.0.0.1:4000/api/v1/health || exit 1
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD wget --quiet --spider http://127.0.0.1:4000/api/v1/health || exit 1
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["node", "dist/main.js"]
CMD ["node", "dist/apps/api-gateway/apps/api-gateway/src/main.js"]
+3 -1
View File
@@ -1,4 +1,4 @@
import { readFileSync } from 'fs';
import { readFileSync } from 'fs';
export interface RabbitConfigSource {
get(key: string): string | undefined;
@@ -93,3 +93,5 @@ export function resolveRabbitMqConfig(
export function processEnvSource(): RabbitConfigSource {
return { get: (key) => process.env[key] };
}