Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e5b66b8
refactor(ci): test dockerhub
atmosuwiryo Dec 9, 2025
49052b5
refactor(ci): update node & pnpm version
atmosuwiryo Dec 9, 2025
3e38ea2
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
50a7b86
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
7486aca
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
0647a97
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
4e0ea74
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
7c7c300
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
d57f097
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
66ee65f
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
b4e8c72
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
fe3acd9
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
b5a0129
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
1fac9d6
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
10d3dc5
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
587098e
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
984a3a7
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
a8d5de9
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
544fa24
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
9d224a4
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
727abf4
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
546e53c
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
f585955
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
824f51f
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
73e926a
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
bdd6b12
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
509832b
refactor(ci): test actions
atmosuwiryo Dec 9, 2025
39b9e73
refactor(ci): test actions
atmosuwiryo Dec 10, 2025
a4e220d
refactor(ci): test actions
atmosuwiryo Dec 10, 2025
1f7718d
refactor(ci): test actions
atmosuwiryo Dec 10, 2025
0993715
refactor(ci): test actions
atmosuwiryo Dec 10, 2025
6835d41
refactor(ci): test actions
atmosuwiryo Dec 10, 2025
7ac37c8
refactor(ci): test actions
atmosuwiryo Dec 10, 2025
d65827b
refactor(ci): test actions
atmosuwiryo Dec 10, 2025
e53f0de
refactor(ci): test actions
atmosuwiryo Dec 10, 2025
be6f3be
refactor(ci): test actions
atmosuwiryo Dec 10, 2025
9bcb1c6
refactor(ci): test actions
atmosuwiryo Dec 10, 2025
73e7499
refactor(ci): test actions
atmosuwiryo Dec 10, 2025
80115b1
refactor(ci): test actions
atmosuwiryo Dec 11, 2025
be8e5b1
refactor(ci): test actions
atmosuwiryo Dec 11, 2025
6c5f355
refactor(ci): test actions
atmosuwiryo Dec 11, 2025
aa6a3fb
refactor(ci): test actions
atmosuwiryo Dec 11, 2025
6d8615e
refactor(ci): test actions
atmosuwiryo Dec 11, 2025
a9c7550
refactor(ci): test actions
atmosuwiryo Dec 11, 2025
a084e6f
refactor(ci): test actions
atmosuwiryo Dec 11, 2025
2c7d176
refactor(ci): test actions
atmosuwiryo Dec 11, 2025
d7f59e0
refactor(ci): test actions
atmosuwiryo Dec 11, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,40 @@ name: CI - Build and Deploy datatable-api
on:
push:
branches:
- main
- test_dockerhub

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for nx affected
filter: tree:0 # Optional, but recommended: reduce the size of the checkout with tree filtering, see https://github.blog/open-source/git/get-up-to-speed-with-partial-clone-and-shallow-clone/

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
version: 10

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '22'
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Set Nx SHAs
uses: nrwl/nx-set-shas@v3
- name: Derive appropriate SHAs for base and head for `nx affected` commands
id: setSHAs
uses: nrwl/nx-set-shas@v4

- name: Check for affected datatable-api
id: check_affected
run: |
AFFECTED_APPS=$(npx nx affected:apps --plain)
AFFECTED_APPS=$(npx nx show projects --affected)
echo "Affected apps: $AFFECTED_APPS"
if [[ "$AFFECTED_APPS" == *"datatable-api"* ]]; then
echo "datatable-api is affected."
Expand All @@ -46,7 +48,8 @@ jobs:

- name: Build datatable-api
if: steps.check_affected.outputs.datatable_api_affected == 'true'
run: npx nx build datatable-api --prod
run: |
npm run build:datatable-api

- name: Login to Docker Hub
if: steps.check_affected.outputs.datatable_api_affected == 'true'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI - Build and Deploy datatable
on:
push:
branches:
- main
- test_dockerhub

jobs:
build-and-deploy:
Expand All @@ -17,12 +17,12 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
version: 10

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '22'
cache: 'pnpm'

- name: Install dependencies
Expand All @@ -34,8 +34,9 @@ jobs:
- name: Check for affected datatable
id: check_affected
run: |
AFFECTED_APPS=$(npx nx affected:apps --plain)
AFFECTED_APPS=$(npx nx show projects --affected)
echo "Affected apps: $AFFECTED_APPS"

if [[ "$AFFECTED_APPS" == *"datatable"* ]]; then
echo "datatable is affected."
echo "datatable_affected=true" >> $GITHUB_OUTPUT
Expand Down
94 changes: 94 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: CI - Build and Deploy datatable projects

on:
push:
branches:
- test_dockerhub

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for nx affected
filter: tree:0 # Optional, but recommended: reduce the size of the checkout with tree filtering, see https://github.blog/open-source/git/get-up-to-speed-with-partial-clone-and-shallow-clone/

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 10

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Derive appropriate SHAs for base and head for `nx affected` commands
id: setSHAs
uses: nrwl/nx-set-shas@v4

- name: Check for affected project
id: check_affected
run: |
AFFECTED_APPS=$(npx nx show projects --affected)
echo "Affected apps: $AFFECTED_APPS"
if [[ "$AFFECTED_APPS" == *"datatable-api"* ]]; then
echo "datatable-api is affected."
echo "datatable_api_affected=true" >> $GITHUB_OUTPUT
else
echo "datatable-api is not affected."
echo "datatable_api_affected=false" >> $GITHUB_OUTPUT
fi

if [[ "$AFFECTED_APPS" == *"datatable"* ]]; then
echo "datatable is affected."
echo "datatable_affected=true" >> $GITHUB_OUTPUT
else
echo "datatable is not affected."
echo "datatable_affected=false" >> $GITHUB_OUTPUT
fi

- name: Build datatable-api
if: steps.check_affected.outputs.datatable_api_affected == 'true'
run: |
npm run build:datatable-api

- name: Build datatable
if: steps.check_affected.outputs.datatable_affected == 'true'
run: |
npm run build:datatable

- name: Login to Docker Hub
if: steps.check_affected.outputs.datatable_api_affected == 'true' || steps.check_affected.outputs.datatable_affected == 'true'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
if: steps.check_affected.outputs.datatable_api_affected == 'true' || steps.check_affected.outputs.datatable_affected == 'true'
uses: docker/setup-buildx-action@v2

- name: Build and push datatable-api
if: steps.check_affected.outputs.datatable_api_affected == 'true'
uses: docker/build-push-action@v4
with:
context: .
file: ./datatable-api/Dockerfile.ci
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/datatable-api:latest

- name: Build and push datatable
if: steps.check_affected.outputs.datatable_affected == 'true'
uses: docker/build-push-action@v4
with:
context: .
file: ./datatable/Dockerfile.ci
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/datatable:latest
11 changes: 8 additions & 3 deletions datatable-api/Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# Stage 1: Runner
FROM node:18-alpine
WORKDIR /app
RUN apk add --no-cache libc6-compat openssl

# Copy the pre-built application
COPY dist/datatable-api .

# Copy production dependencies and install them
COPY package.json pnpm-lock.yaml* ./
RUN npm install -g pnpm && pnpm install --frozen-lockfile --prod

# Copy Prisma schema and generate client
# Copy Prisma schema and generated client
COPY datatable-api/prisma ./datatable-api/prisma

RUN npm install -g pnpm
RUN pnpm install --frozen-lockfile --prod
# RUN pnpm install --frozen-lockfile
RUN pnpm install prisma

RUN npm run prisma:generate

# Copy and setup entrypoint
Expand Down
3 changes: 3 additions & 0 deletions datatable-api/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ set -e
echo "Running database migrations..."
npx prisma migrate deploy --schema datatable-api/prisma/schema.prisma

# echo "Running database reset & seeder..."
# npm run prisma:reset -- -f

echo "Starting the application..."
exec "$@"
4 changes: 2 additions & 2 deletions datatable-api/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ async function main() {
await prisma.employee.create({
data: {
name: employee.name,
departmentId: department.id,
positionId: position.id,
departmentId: department!.id,
positionId: position!.id,
dateOfHire: employee.dateOfHire
}
});
Expand Down
5 changes: 1 addition & 4 deletions datatable-api/src/app/services/prisma.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import { Injectable, OnModuleInit } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';

@Injectable()
export class PrismaService extends PrismaClient
implements OnModuleInit {

export class PrismaService extends PrismaClient implements OnModuleInit {
async onModuleInit() {
await this.$connect();
}

}
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@

<clr-datagrid
(clrDgRefresh)="refresh.emit($event)"
[clrDgLoading]="loading"
>
<clr-datagrid (clrDgRefresh)="refresh.emit($event)" [clrDgLoading]="loading">
<clr-dg-column [clrDgField]="'name'">Department Name</clr-dg-column>

@for (department of departments; track department) {
<clr-dg-row [clrDgItem]="department">
<clr-dg-action-overflow>
<button class="action-item" (click)="onEdit(department)">Edit</button>
<button class="action-item" (click)="onDelete(department)">Delete</button>
</clr-dg-action-overflow>
<clr-dg-cell>{{ department.name }}</clr-dg-cell>
</clr-dg-row>
<clr-dg-row [clrDgItem]="department">
<clr-dg-action-overflow>
<button class="action-item" (click)="onEdit(department)">Edit</button>
<button class="action-item" (click)="onDelete(department)">Delete</button>
</clr-dg-action-overflow>
<clr-dg-cell>{{ department?.['name'] }}</clr-dg-cell>
</clr-dg-row>
}

<clr-dg-footer>
<clr-dg-pagination
#pagination
[clrDgTotalItems]="total"
>
<clr-dg-pagination #pagination [clrDgTotalItems]="total">
<clr-dg-page-size [clrPageSizeOptions]="[10, 20, 50, 100]">
Departments per page
</clr-dg-page-size>
Expand Down
31 changes: 12 additions & 19 deletions datatable/src/app/features/employee/employee-list.component.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@

<clr-datagrid
(clrDgRefresh)="refresh.emit($event)"
[clrDgLoading]="loading"
>
<clr-datagrid (clrDgRefresh)="refresh.emit($event)" [clrDgLoading]="loading">
<clr-dg-column [clrDgField]="'name'">Employee Name</clr-dg-column>
<clr-dg-column [clrDgField]="'department'">Employee Department</clr-dg-column>
<clr-dg-column [clrDgField]="'position'">Employee Position</clr-dg-column>
<clr-dg-column [clrDgSortBy]="'dateOfHire'">Date of Hire</clr-dg-column>

@for (employee of employees; track employee) {
<clr-dg-row [clrDgItem]="employee">
<clr-dg-action-overflow>
<button class="action-item" (click)="onEdit(employee)">Edit</button>
<button class="action-item" (click)="onDelete(employee)">Delete</button>
</clr-dg-action-overflow>
<clr-dg-cell>{{ employee.name }}</clr-dg-cell>
<clr-dg-cell>{{ employee.department }}</clr-dg-cell>
<clr-dg-cell>{{ employee.position }}</clr-dg-cell>
<clr-dg-cell>{{ employee.dateOfHire | date }}</clr-dg-cell>
</clr-dg-row>
<clr-dg-row [clrDgItem]="employee">
<clr-dg-action-overflow>
<button class="action-item" (click)="onEdit(employee)">Edit</button>
<button class="action-item" (click)="onDelete(employee)">Delete</button>
</clr-dg-action-overflow>
<clr-dg-cell>{{ employee?.['name'] }}</clr-dg-cell>
<clr-dg-cell>{{ employee?.['department'] }}</clr-dg-cell>
<clr-dg-cell>{{ employee?.['position'] }}</clr-dg-cell>
<clr-dg-cell>{{ employee?.['dateOfHire'] | date }}</clr-dg-cell>
</clr-dg-row>
}

<clr-dg-footer>
<clr-dg-pagination
#pagination
[clrDgTotalItems]="total"
>
<clr-dg-pagination #pagination [clrDgTotalItems]="total">
<clr-dg-page-size [clrPageSizeOptions]="[10, 20, 50, 100]">
Employees per page
</clr-dg-page-size>
Expand Down
25 changes: 9 additions & 16 deletions datatable/src/app/features/position/position-list.component.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@

<clr-datagrid
(clrDgRefresh)="refresh.emit($event)"
[clrDgLoading]="loading"
>
<clr-datagrid (clrDgRefresh)="refresh.emit($event)" [clrDgLoading]="loading">
<clr-dg-column [clrDgField]="'name'">Position Name</clr-dg-column>

@for (position of positions; track position) {
<clr-dg-row [clrDgItem]="position">
<clr-dg-action-overflow>
<button class="action-item" (click)="onEdit(position)">Edit</button>
<button class="action-item" (click)="onDelete(position)">Delete</button>
</clr-dg-action-overflow>
<clr-dg-cell>{{ position.name }}</clr-dg-cell>
</clr-dg-row>
<clr-dg-row [clrDgItem]="position">
<clr-dg-action-overflow>
<button class="action-item" (click)="onEdit(position)">Edit</button>
<button class="action-item" (click)="onDelete(position)">Delete</button>
</clr-dg-action-overflow>
<clr-dg-cell>{{ position?.['name'] }}</clr-dg-cell>
</clr-dg-row>
}

<clr-dg-footer>
<clr-dg-pagination
#pagination
[clrDgTotalItems]="total"
>
<clr-dg-pagination #pagination [clrDgTotalItems]="total">
<clr-dg-page-size [clrPageSizeOptions]="[10, 20, 50, 100]">
Positions per page
</clr-dg-page-size>
Expand Down
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"serve:datatable:local": "npm run env:init && npx nx serve datatable"
},
"prisma": {
"seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts"
"seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} datatable-api/prisma/seed.ts"
},
"private": true,
"devDependencies": {
Expand Down Expand Up @@ -100,5 +100,13 @@
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "0.15.1"
},
"pnpm": {
"onlyBuiltDependencies": [
"@nestjs/core",
"@prisma/client",
"@prisma/engines",
"prisma"
]
}
}
Loading