Skip to content

Commit

Permalink
Import existing code
Browse files Browse the repository at this point in the history
  • Loading branch information
mwanggren-EW committed Aug 21, 2024
0 parents commit f48a9ff
Show file tree
Hide file tree
Showing 269 changed files with 32,206 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.git
**/__mocks__
**/*.test.ts
16 changes: 16 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# MongoDB
MONGODB_URI=${MONGODB_URI:-mongodb://api:password@localhost:27017/agile-live-gui}

# AgileLive System Controlleer
AGILE_URL=${AGILE_URL:-https://localhost:8080}
AGILE_CREDENTIALS=${AGILE_CREDENTIALS:-admin:admin}
# This ENV variable disables SSL Verification, the above AGILE_URL doesn't have a proper certificate
NODE_TLS_REJECT_UNAUTHORIZED=${NODE_TLS_REJECT_UNAUTHORIZED:-1}

# NextAuth
NEXTAUTH_SECRET=${NEXTAUTH_SECRET:-C8611AD4F5481368AB18F32158DBC}
NEXTAUTH_URL=${NEXTAUTH_URL:-http://localhost:3000}
BCRYPT_SALT_ROUNDS=${BCRYPT_SALT_ROUNDS:-10}

# i18n
UI_LANG=${UI_LANG:-en}
18 changes: 18 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"root": true,
"env": {
"node": true,
"browser": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"next"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier"],
"rules": {
"prettier/prettier": "error"
}
}
19 changes: 19 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build
on: [pull_request]

jobs:
ts:
if: "!contains(github.event.pull_request.title, 'WIP!')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Install Dependencies
run: npm ci
- name: Generate dummy version
run: echo "GITHUB_ACTIONS" > gui-version.txt
- name: Run build
run: npm run build
17 changes: 17 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Linting
on: [pull_request]

jobs:
lint:
if: "!contains(github.event.pull_request.title, 'WIP!')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Install Dependencies
run: npm ci
- name: Run Eslint
run: npm run lint
17 changes: 17 additions & 0 deletions .github/workflows/pretty.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Prettier
on: [pull_request]

jobs:
pretty:
if: "!contains(github.event.pull_request.title, 'WIP!')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Install Dependencies
run: npm ci
- name: Run Prettier
run: npm run pretty
16 changes: 16 additions & 0 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Unit Tests
on: [push]

jobs:
unittests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Install Dependencies
run: npm ci
- name: Run Unit Tests
run: npm test
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node_modules/
.DS_Store
.next
.env
.terraform/
*.tfstate
*.tfstate.*
swagger.json
.env.local
gui-version.txt

# TypeScript cache
*.tsbuildinfo
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx commitlint --edit
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/.next
*.tfstate*
scripts/mongosh-admin.js
.vscode/*
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"useTabs": false,
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "none"
}
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contributing Code

This project uses [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary).
58 changes: 58 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
FROM node:18-alpine AS base

# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi


# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED 1

RUN npm run build

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

COPY gui-version.txt ./

USER nextjs

EXPOSE 3000

ENV PORT 3000

CMD ["node", "server.js"]
4 changes: 4 additions & 0 deletions Dockerfile.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM mongo:latest

COPY ./scripts/mongo-init.js /docker-entrypoint-initdb.d/
COPY ./scripts/mongo-users.js /docker-entrypoint-initdb.d/
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Ateliere Live GUI

## Requirements

- Node.js 18.x

## Installation / Usage

For single server installation on Ubuntu 22 see instructions [here](docs/installation.md).

## Development

Start mongodb docker container using `docker-compose up`. It will initialize the db with some test data.

If you want to run the GUI and mongodb docker containers add this to the `docker-compose.yml` file:

```
agileui:
build: .
environment:
MONGODB_URI: mongodb://api:<API_PASSWORD>@host.docker.internal:27017/agile-live-gui
AGILE_URL: https://<SYSTEM_CONTROLLER_IP>:8080
AGILE_CREDENTIALS: <USERNAME>:<PASSWORD>
NODE_TLS_REJECT_UNAUTHORIZED: 0
NEXTAUTH_SECRET: <NEXT_AUTH_SECRET>
NEXTAUTH_URL: http://localhost:3000
BCRYPT_SALT_ROUNDS: 10
UI_LANG: en
ports:
- 3000:3000
extra_hosts:
- "host.docker.internal:host-gateway"
```

Then copy the `.env.sample` file and name it `.env`, it will contain env variables:

- `MONGODB_URI` - The mongodb connection string including credentials eg. `mongodb://user123:[email protected]:27017/agile-live-gui`

- `AGILE_URL` - The URL to the Agile-live system controller REST API
- `AGILE_CREDENTIALS` - Credentials for the Agile-live system controller REST API

- `NEXTAUTH_SECRET` - The secret used to encrypt the JWT Token
- `NEXTAUTH_URL` - The base url for the service, eg. `http://localhost:3000`, used internally by NextAuth.
- `BCRYPT_SALT_ROUNDS` - The number of salt rounds the bcrypt hashing function will perform, you probably don't want this higher than 13 ( 13 = ~1 hash/second )
- `UI_LANG` - Set language for the user interface (`en|sv`). Default is `en`
- `DB_OUTPUT_OVERRIDES` - Override and initiate DB presets on startup. Comma-separated list in the form `<pipeline|multiview>[<name>].<setting>=<value>`, where `<setting>` is one of:

- `port`
- `local_ip`
- `remote_ip`
- `srt_mode`
- `srt_passphrase`

for example:

```
DB_PRESET_OVERRIDES=pipeline[LD_Pipeline].port=9200,pipeline[HQ_Pipeline].srt_mode=caller,multiview[default].port=4567
```

Run following to run application in development environment:

1. `npm install`
2. `npm run dev`

### External Documentation

https://docs.agilecontent.com/docs/acl/reference/3-0-0/rest_api/

### Contributing

See [CONTRIBUTING](CONTRIBUTING.md)
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.7'

services:
mongodb:
image: mongo:latest
container_name: mongodb
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: password
ports:
- 27017:27017
volumes:
- ./scripts/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
Loading

0 comments on commit f48a9ff

Please sign in to comment.