Deploy notification service #1
+8
-1
@@ -4,7 +4,10 @@ NODE_ENV=development
|
|||||||
PORT=4000
|
PORT=4000
|
||||||
HOST=0.0.0.0
|
HOST=0.0.0.0
|
||||||
PUBLIC_BASE_URL=http://localhost:4000
|
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
|
RESPONSE_ENVELOPE_ENABLED=false
|
||||||
SWAGGER_ENABLED=true
|
SWAGGER_ENABLED=true
|
||||||
GLOBAL_PREFIX=api/v1
|
GLOBAL_PREFIX=api/v1
|
||||||
@@ -120,6 +123,8 @@ NOTIFICATION_RMQ_PREFETCH=10
|
|||||||
|
|
||||||
STORAGE_PROVIDER=local
|
STORAGE_PROVIDER=local
|
||||||
MEDIA_ACCESS_MODE=direct
|
MEDIA_ACCESS_MODE=direct
|
||||||
|
# Expiration for presigned S3 URLs (1 second to 7 days).
|
||||||
|
SIGNED_URL_EXPIRES_SECONDS=86400
|
||||||
STORAGE_BASE_PATH=uploads
|
STORAGE_BASE_PATH=uploads
|
||||||
# In Docker/production with local storage, mount a persistent volume to /app/uploads
|
# In Docker/production with local storage, mount a persistent volume to /app/uploads
|
||||||
# or to the runtime path resolved from STORAGE_BASE_PATH.
|
# or to the runtime path resolved from STORAGE_BASE_PATH.
|
||||||
@@ -130,6 +135,8 @@ S3_REGION=auto
|
|||||||
S3_ENDPOINT=
|
S3_ENDPOINT=
|
||||||
S3_ACCESS_KEY_ID=
|
S3_ACCESS_KEY_ID=
|
||||||
S3_SECRET_ACCESS_KEY=
|
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
|
S3_FORCE_PATH_STYLE=false
|
||||||
# Optional: writes then deletes a tiny health object when GET /media/health runs.
|
# Optional: writes then deletes a tiny health object when GET /media/health runs.
|
||||||
# Keep false unless you explicitly want to verify S3 write permissions.
|
# Keep false unless you explicitly want to verify S3 write permissions.
|
||||||
|
|||||||
+30
-57
@@ -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:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: oudelaa-production-${{ github.ref }}
|
group: oudelaa-api-ci-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
quality:
|
quality-and-tests:
|
||||||
|
name: Build, lint, and test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
mongodb:
|
mongodb:
|
||||||
@@ -41,12 +41,13 @@ jobs:
|
|||||||
- name: Install locked dependencies
|
- name: Install locked dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: Static quality gates
|
- name: Build API Gateway and project artifacts
|
||||||
run: |
|
run: npm run build
|
||||||
npm run lint
|
|
||||||
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
|
run: npm run test:coverage
|
||||||
|
|
||||||
- name: Upload coverage report
|
- name: Upload coverage report
|
||||||
@@ -69,50 +70,22 @@ jobs:
|
|||||||
- name: Dependency security audit
|
- name: Dependency security audit
|
||||||
run: npm audit --audit-level=high
|
run: npm audit --audit-level=high
|
||||||
|
|
||||||
- name: Verify production image
|
verify-image:
|
||||||
run: docker build --tag oudelaa-api:${{ github.sha }} .
|
name: Build API Gateway image
|
||||||
|
needs: quality-and-tests
|
||||||
deploy:
|
|
||||||
needs: quality
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
environment: production
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
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: |
|
run: |
|
||||||
cat > .ghaymah.json << 'EOF'
|
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
|
||||||
"id": "da97e2b8-0b2c-49d8-a672-1d162c8e15f1",
|
docker run --rm --entrypoint ffprobe oudelaa-api:${{ github.sha }} -version
|
||||||
"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
|
|
||||||
|
|||||||
+24
-20
@@ -1,4 +1,4 @@
|
|||||||
FROM node:20-alpine AS builder
|
FROM node:20-alpine AS build
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -6,34 +6,38 @@ COPY package*.json ./
|
|||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
COPY . .
|
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
|
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 ./
|
COPY package*.json ./
|
||||||
RUN npm ci --omit=dev \
|
RUN npm ci --omit=dev && npm cache clean --force
|
||||||
&& npm cache clean --force
|
|
||||||
|
|
||||||
COPY --from=builder --chown=node:node /app/dist ./dist
|
FROM node:20-alpine AS runtime
|
||||||
RUN mkdir -p /app/uploads \
|
|
||||||
&& chown -R node:node /app/uploads
|
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
|
USER node
|
||||||
|
|
||||||
EXPOSE 4000
|
EXPOSE 4000
|
||||||
|
|
||||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
|
||||||
CMD wget -q -O /dev/null http://127.0.0.1:4000/api/v1/health || exit 1
|
CMD wget --quiet --spider http://127.0.0.1:4000/api/v1/health || exit 1
|
||||||
|
|
||||||
ENTRYPOINT ["/sbin/tini", "--"]
|
CMD ["node", "dist/apps/api-gateway/apps/api-gateway/src/main.js"]
|
||||||
CMD ["node", "dist/main.js"]
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
|
|
||||||
export interface RabbitConfigSource {
|
export interface RabbitConfigSource {
|
||||||
get(key: string): string | undefined;
|
get(key: string): string | undefined;
|
||||||
@@ -93,3 +93,5 @@ export function resolveRabbitMqConfig(
|
|||||||
export function processEnvSource(): RabbitConfigSource {
|
export function processEnvSource(): RabbitConfigSource {
|
||||||
return { get: (key) => process.env[key] };
|
return { get: (key) => process.env[key] };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user