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
2 changes: 1 addition & 1 deletion .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.26
bun-version: 1.0.29

- name: Install dependencies
run: cd interapp-backend && bun install
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,5 @@ dist
.DS_Store

pgdata/
minio_data/
minio_data/
dump/
6 changes: 5 additions & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3"
services:
postgres:
container_name: interapp-postgres
image: postgres:alpine
image: postgres:16-alpine
restart: on-failure
ports:
- 5432:5432
Expand Down Expand Up @@ -62,6 +62,10 @@ services:
condition: service_healthy
redis:
condition: service_healthy
volumes:
- type: bind
source: ./dump
target: /tmp/dump

minio:
container_name: interapp-minio
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3"
services:
postgres:
container_name: interapp-postgres
image: postgres:alpine
image: postgres:16-alpine
restart: always
ports:
- 5432:5432
Expand Down Expand Up @@ -52,6 +52,8 @@ services:
condition: service_healthy
redis:
condition: service_healthy
volumes:
- ./:/tmp/dump

minio:
container_name: interapp-minio
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3"
services:
postgres:
container_name: interapp-postgres-test
image: postgres:alpine
image: postgres:16-alpine
restart: on-failure
ports:
- 2345:2345
Expand Down
2 changes: 1 addition & 1 deletion interapp-backend/api/routes/swagger_docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"contact": {
"email": "sebastian.ong@hotmail.com"
},
"version": "0.3.0"
"version": "0.4.0"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion interapp-backend/dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM oven/bun:1.0.26
FROM oven/bun:1.0.29
WORKDIR /app

COPY . .
Expand Down
2 changes: 1 addition & 1 deletion interapp-backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "interapp-backend",
"version": "0.3.0",
"version": "0.4.0",
"module": "index.ts",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion interapp-backend/prod.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM oven/bun:1.0.26
FROM oven/bun:1.0.29
WORKDIR /app

COPY . .
Expand Down
13 changes: 11 additions & 2 deletions interapp-backend/scheduler/dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
FROM oven/bun:1.0.26
FROM oven/bun:1.0.29
WORKDIR /app

COPY . .

RUN bun install --frozen-lockfile

RUN apt-get update && apt-get install -y tzdata
# install curl, lsb-release and gnupg
RUN apt-get update && apt-get install -y curl lsb-release gnupg && apt-get clean

# add postgresql repository
RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list

# update and install postgresql-client-16, tzdata
RUN apt-get update && apt-get install -y postgresql-client-16 tzdata && apt-get clean

ENV TZ=Asia/Singapore
RUN ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
RUN apt-get clean
Expand Down
13 changes: 11 additions & 2 deletions interapp-backend/scheduler/prod.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
FROM oven/bun:1.0.26
FROM oven/bun:1.0.29
WORKDIR /app

COPY . .

RUN bun install --production --frozen-lockfile

RUN apt-get update && apt-get install -y tzdata
# install curl, lsb-release and gnupg
RUN apt-get update && apt-get install -y curl lsb-release gnupg && apt-get clean

# add postgresql repository
RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list

# update and install postgresql-client-16, tzdata
RUN apt-get update && apt-get install -y postgresql-client-16 tzdata && apt-get clean

ENV TZ=Asia/Singapore
RUN ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
RUN apt-get clean
Expand Down
19 changes: 18 additions & 1 deletion interapp-backend/scheduler/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { User } from '@db/entities/user';
import { AttendanceStatus } from '@db/entities/service_session_user';
import redisClient from '@utils/init_redis';
import { randomBytes } from 'crypto';
import { $ } from 'bun';
import { existsSync, mkdirSync } from 'fs';

function constructDate(day_of_week: number, time: string) {
const d = new Date();
Expand All @@ -26,7 +28,7 @@ async function getCurrentServices() {
}

schedule(
'0 0 * * * Sunday',
'0 0 0 * * Sunday',
async () => {
const to_be_scheduled = await getCurrentServices();
if (to_be_scheduled.length === 0) return;
Expand Down Expand Up @@ -114,3 +116,18 @@ schedule('0 */1 * * * *', async () => {
}
}
});

schedule('0 0 0 */1 * *', async () => {
// this is mounted on the host machine -- see docker compose file
const path = '/tmp/dump';
if (!existsSync(path)) mkdirSync(path);

const d = new Date();
const fmted = `interapp_${d.toLocaleDateString().replace(/\//g, '')}`;

const newFile = `${path}/${fmted}.sql`;
await $`touch ${newFile}`;
await $`PGPASSWORD=postgres pg_dump -U postgres -a interapp -h interapp-postgres > ${newFile}`;

console.log('db snapshot taken at location: ', newFile);
});
2 changes: 1 addition & 1 deletion interapp-backend/tests/config/test.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM oven/bun:1.0.26
FROM oven/bun:1.0.29
WORKDIR /app

COPY . .
Expand Down
Binary file modified interapp-frontend/bun.lockb
Binary file not shown.
6 changes: 3 additions & 3 deletions interapp-frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "interapp-frontend",
"version": "0.3.0",
"version": "0.4.0",
"private": true,
"scripts": {
"prettier": "prettier --write .",
Expand Down Expand Up @@ -32,14 +32,14 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "^20",
"@types/node": "^20.11.20",
"@types/qrcode": "^1.5.5",
"@types/react": "^18",
"@types/react-dom": "^18",
"bun-types": "^1.0.11",
"eslint": "^8",
"eslint-config-next": ">=14.1.0",
"prettier": "^3.1.0",
"typescript": "^5.3.2"
"typescript": "^5.3.3"
}
}