Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# API and worker ports (host side)
API_PORT=8080
AUDIT_WORKER_PORT=8081
FRONTEND_PORT=5173

# Postgres
POSTGRES_HOST=postgres
Expand Down Expand Up @@ -33,12 +34,13 @@ RABBITMQ_MANAGEMENT_PORT=15672
# Audit worker health endpoint
AUDIT_HEALTH_URL=http://0.0.0.0:8081

# Dashboard worker schedule (hourly)
DASHBOARD_CRON=0 * * * *

# Dashboard worker health port
DASHBOARD_HEALTH_PORT=8090

# Dashboard worker queue settings
DASHBOARD_RABBIT_QUEUE=workforce.dashboard
DASHBOARD_RABBIT_PREFETCH=10

# Dashboard worker retry settings
DASHBOARD_RETRY_MAX=3
DASHBOARD_RETRY_BASE_MS=1000
125 changes: 125 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: CI

on:
push:
branches: ['**']
pull_request:

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Restore and build backend
run: dotnet build backend/dotnet/Workforce.slnx

- name: Install and build dashboard worker
working-directory: backend/node/dashboard-worker
run: |
npm ci
npm run build

- name: Install and build frontend
if: ${{ hashFiles('frontend/package.json') != '' }}
working-directory: frontend
run: |
npm ci
npm run build

test:
name: Test
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Run backend tests
run: dotnet test backend/dotnet/Workforce.slnx

- name: Run frontend tests
if: ${{ hashFiles('frontend/package.json') != '' }}
working-directory: frontend
run: |
npm ci
npm run test --if-present

lint:
name: Lint
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dotnet format
run: dotnet tool install --global dotnet-format

- name: Lint backend
run: dotnet format backend/dotnet/Workforce.slnx --verify-no-changes

- name: Lint dashboard worker
working-directory: backend/node/dashboard-worker
run: |
npm ci
npm run lint

- name: Lint frontend
if: ${{ hashFiles('frontend/package.json') != '' }}
working-directory: frontend
run: |
npm ci
npm run lint

docker-build:
name: Docker Build
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build API image
run: docker build -f docker/Dockerfile.api -t workforce-api .

- name: Build audit worker image
run: docker build -f docker/Dockerfile.auditworker -t workforce-audit-worker .

- name: Build dashboard worker image
run: docker build -f docker/Dockerfile.dashboardworker -t workforce-dashboard-worker .

- name: Build frontend image
run: docker build -f docker/Dockerfile.frontend -t workforce-frontend .
1 change: 1 addition & 0 deletions backend/node/dashboard-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"scripts": {
"generate": "prisma generate",
"build": "tsc -p tsconfig.json",
"lint": "tsc -p tsconfig.json --noEmit",
"start": "node dist/index.js",
"dev": "tsx src/index.ts"
},
Expand Down
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ services:
timeout: 5s
retries: 3

frontend:
build:
context: .
dockerfile: docker/Dockerfile.frontend
ports:
- '${FRONTEND_PORT:-5173}:80'

postgres:
image: postgres:16
environment:
Expand Down
15 changes: 15 additions & 0 deletions docker/Dockerfile.frontend
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:20-bullseye-slim AS build

WORKDIR /app

COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci

COPY frontend/ ./
RUN npm run build

FROM nginx:1.27-alpine

COPY --from=build /app/dist/ /usr/share/nginx/html/

EXPOSE 80
24 changes: 24 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
73 changes: 73 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## React Compiler

The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:

```js
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...

// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,

// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```

You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:

```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'

export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```
23 changes: 23 additions & 0 deletions frontend/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import { defineConfig, globalIgnores } from 'eslint/config'

export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
js.configs.recommended,
tseslint.configs.recommended,
reactHooks.configs.flat.recommended,
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
},
])
13 changes: 13 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>frontend</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading