Skip to content

Commit 4f2b1b6

Browse files
committed
configured ES modules support and added build scripts
1 parent 85fdc93 commit 4f2b1b6

6 files changed

Lines changed: 60 additions & 8 deletions

File tree

.dockerIgnore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
dist
3+
.git
4+
.gitignore
5+
.env
6+
*.md
7+
.DS_Store
8+
terraform
9+
k8s

Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM node:20-alpine AS builder
2+
3+
WORKDIR /app
4+
5+
ARG PORT
6+
ARG DATABASE_URL
7+
8+
COPY package.json yarn.lock ./
9+
RUN yarn install --frozen-lockfile
10+
11+
COPY prisma ./prisma
12+
RUN yarn prisma generate
13+
14+
COPY tsconfig.json ./
15+
COPY src ./src
16+
RUN yarn tsc
17+
18+
FROM node:20-alpine AS production
19+
20+
WORKDIR /app
21+
22+
RUN addgroup -g 1001 -S nodejs && \
23+
adduser -S nodejs -u 1001
24+
25+
COPY package.json yarn.lock ./
26+
RUN yarn install --frozen-lockfile --production && yarn cache clean
27+
28+
COPY --from=builder /app/dist ./dist
29+
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
30+
COPY prisma ./prisma
31+
32+
RUN chown -R nodejs:nodejs /app
33+
34+
USER nodejs
35+
36+
EXPOSE 3000
37+
38+
CMD ["yarn", "run", "start"]

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@
33
"version": "1.0.0",
44
"license": "MIT",
55
"scripts": {
6-
"dev": "tsx src/index.ts"
6+
"dev": "tsx src/index.ts",
7+
"build": "tsc",
8+
"start": "node dist/index.js",
9+
"clean": "rm -rf dist node_modules"
710
},
811
"dependencies": {
912
"@prisma/adapter-pg": "7.0.0",
1013
"@prisma/client": "7.0.0",
1114
"express": "5.1.0",
12-
"pg": "^8.16.3"
15+
"pg": "^8.16.3",
16+
"dotenv": "^17.2.1"
1317
},
1418
"devDependencies": {
1519
"@types/express": "5.0.5",
1620
"@types/node": "22.18.12",
17-
"dotenv": "^17.2.1",
1821
"prisma": "7.0.0",
1922
"tsx": "^4.20.6",
2023
"typescript": "5.8.2",

prisma/schema.prisma

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
generator client {
2-
provider = "prisma-client"
3-
output = "./generated"
2+
provider = "prisma-client-js"
43
}
54

65
datasource db {

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'dotenv/config'
2-
import { Prisma, PrismaClient } from '../prisma/generated/client'
2+
import { Prisma, PrismaClient } from '@prisma/client'
33
import { PrismaPg } from '@prisma/adapter-pg'
44
import express from 'express'
55

tsconfig.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
{
22
"compilerOptions": {
3+
"target": "ES2020",
34
"sourceMap": true,
45
"outDir": "dist",
6+
"rootDir": "src",
57
"strict": true,
68
"lib": [
79
"esnext"
810
],
911
"esModuleInterop": true,
10-
"module": "ESNext",
12+
"module": "CommonJS",
1113
"moduleResolution": "node",
1214
"resolveJsonModule": true
13-
}
15+
},
16+
"include": ["src/**/*"]
1417
}

0 commit comments

Comments
 (0)