This commit is contained in:
2024-09-21 00:53:18 +02:00
parent bc39f6b6d6
commit a4810fc7ba
10 changed files with 51 additions and 40 deletions

View File

@ -1 +1,7 @@
.git
.mysql
dist
node_modules
Dockerfile
docker-compose.yml
sous-podzim2024-app.tar.gz

4
.gitignore vendored
View File

@ -1,2 +1,4 @@
node_modules
.mysql
dist
node_modules
sous-podzim2024-app.tar.gz

View File

@ -1,16 +1,17 @@
FROM oven/bun:1 AS base
FROM oven/bun:1 AS builder
WORKDIR /usr/src/app
COPY package.json bun.lockb .
#RUN bun install --frozen-lockfile --production
RUN bun install --frozen-lockfile --development
RUN bun install --frozen-lockfile --production
COPY . .
RUN bun run build
#ENV NODE_ENV=production
ENV NODE_ENV=development
FROM node:22-alpine AS base
WORKDIR /usr/src/app
COPY --from=builder /usr/src/app .
ENV NODE_ENV=production
USER bun
EXPOSE 8080/tcp
#ENTRYPOINT [ "bun", "run", "src/index.ts" ]
ENTRYPOINT [ "bun", "run", "dev" ]
ENTRYPOINT [ "node", "./dist/index.js" ]

View File

@ -12,4 +12,8 @@ To run:
bun run index.ts
```
This project was created using `bun init` in bun v1.1.12. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
# transfer to server
build image with `docker compose build`
save image to file on client: `docker save sous-podzim2024-app:latest | gzip > sous-podzim2024-app.tar.gz`
copy zip to server
load image on server: `docker load < sous-podzim2024-app.tar.gz`

BIN
bun.lockb

Binary file not shown.

View File

@ -1,6 +1,6 @@
services:
app:
image: labyrint
image: sous-podzim2024-app
build:
context: .
restart: on-failure:3

View File

@ -1,12 +1,10 @@
import { defineConfig } from "drizzle-kit";
export const dbCredentials = {
//host: "127.0.0.1",
host: "db",
//port: 8081,
port: 3306,
user: "root",
password: "password",
user: "fykosak",
password: "zxvFcEztX0vzDhB",
database: "sous-podzim2024-app"
};

View File

@ -1,26 +1,25 @@
{
"name": "sous-podzim2024-app",
"module": "index.ts",
"type": "module",
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"@types/ejs": "^3.1.5",
"@types/express": "^4.17.21",
"@types/multer": "^1.4.12",
"drizzle-kit": "^0.24.2",
"drizzle-orm": "^0.33.0",
"ejs": "^3.1.10",
"express": "^4.19.2",
"multer": "^1.4.5-lts.1",
"mysql2": "^3.11.0"
},
"scripts": {
"dev": "bun --watch src/index.ts",
"push": "bun drizzle-kit push"
}
"name": "sous-podzim2024-app",
"module": "index.ts",
"type": "module",
"devDependencies": {
"@types/bun": "latest"
},
"dependencies": {
"@types/ejs": "^3.1.5",
"@types/express": "^4.17.21",
"@types/multer": "^1.4.12",
"drizzle-kit": "^0.24.2",
"drizzle-orm": "^0.33.0",
"ejs": "^3.1.10",
"express": "^4.19.2",
"typescript": "^5.6.2",
"multer": "^1.4.5-lts.1",
"mysql2": "^3.11.0"
},
"scripts": {
"dev": "bun --watch src/index.ts",
"push": "bun drizzle-kit push",
"build": "bun build ./src/index.ts --outdir ./dist --target node"
}
}

View File

@ -15,7 +15,7 @@ export const personRelations = relations(personTable, ({ many }) => ({
export const pointsTable = mysqlTable('points', {
pointsId: int('pointsId').primaryKey().autoincrement(),
personId: int('personId').notNull().references(() => personTable.personId),
points: int('points'),
points: int('points').notNull(),
});
export const pointsRelations = relations(pointsTable, ({ one }) => ({

View File

@ -88,6 +88,7 @@ app.get("/gamble/:id", async (req, res) => {
if (isDetailAvailable(person.gambleTime)) {
res.redirect('/person/' + id);
return;
}
if (!isGambleAvailable(person.gambleTime)) {