Skip to content

Commit 17d01bb

Browse files
nhalsteadymadamshiervaniIDisposable
authored
Upgrade to Express v5, Dockerfile, and Health Checks (#29)
Co-authored-by: Aveline <[email protected]> Co-authored-by: Adam Shiervani <[email protected]> Co-authored-by: Marc Brooks <[email protected]>
1 parent 2d20ce0 commit 17d01bb

File tree

11 files changed

+628
-328
lines changed

11 files changed

+628
-328
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.github/
2+
.idea/
3+
node_modules/
4+
dist/
5+
.DS_Store
6+
.env

.env.example

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,39 @@
1+
PORT=3000
12
DATABASE_URL="postgresql://jetkvm:jetkvm@localhost:5432/jetkvm?schema=public"
23

3-
GOOGLE_CLIENT_ID=XXX # Google OIDC Client ID
4-
GOOGLE_CLIENT_SECRET=XXX # Google OIDC Client Secret
4+
##
5+
## Google Auth with OIDC Configuration
6+
##
7+
GOOGLE_CLIENT_ID=
8+
GOOGLE_CLIENT_SECRET=
9+
API_HOSTNAME=
10+
APP_HOSTNAME=
511

6-
API_HOSTNAME=XXX # Is needed for the OIDC Callback
7-
APP_HOSTNAME=XXX # Is needed for the OIDC Callback
12+
##
13+
## Cloudflare TURN Service
14+
##
15+
CLOUDFLARE_TURN_ID=
16+
CLOUDFLARE_TURN_TOKEN=
817

9-
CLOUDFLARE_TURN_ID=XXX # Cloudflare TURN ID
10-
CLOUDFLARE_TURN_TOKEN=XXX # Cloudflare TURN Token
18+
##
19+
## Session Cookie Secret
20+
##
21+
COOKIE_SECRET=
1122

12-
COOKIE_SECRET=XXX # Session Cookie Secret
23+
###
24+
### S3 Compatible Storage
25+
###
26+
R2_ENDPOINT=
27+
R2_ACCESS_KEY_ID=
28+
R2_SECRET_ACCESS_KEY=
29+
R2_BUCKET=
30+
R2_CDN_URL=
1331

14-
R2_ENDPOINT=XXX # Any S3 compatible endpoint
15-
R2_ACCESS_KEY_ID=XXX # Any S3 compatible access key
16-
R2_SECRET_ACCESS_KEY=XXX # Any S3 compatible secret access key
17-
R2_BUCKET=XXX # Any S3 compatible bucket
18-
R2_CDN_URL=XXX # Any S3 compatible CDN URL
32+
# Allowed CORS Origins, split by comma
33+
CORS_ORIGINS=https://app.jetkvm.com,http://localhost:5173
1934

20-
CORS_ORIGINS=https://app.jetkvm.com,http://localhost:5173 # Allowed CORS Origins, split by comma
35+
# Real IP Header for the reverse proxy (e.g. X-Real-IP), leave empty if not needed
36+
REAL_IP_HEADER=
2137

22-
REAL_IP_HEADER=XXX # Real IP Header for the reverse proxy (e.g. X-Real-IP), leave empty if not needed
23-
ICE_SERVERS=XXX # ICE Servers for WebRTC, split by comma (e.g. stun:stun.l.google.com:19302,stun:stun1.l.google.com:19302)
38+
# ICE Servers for WebRTC, split by comma (e.g. stun:stun.l.google.com:19302,stun:stun1.l.google.com:19302)
39+
ICE_SERVERS=

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules
22
.idea
3+
dist/
34
.env
45
.env.development

Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM node:21.1.0-alpine AS packages
2+
WORKDIR /usr/src/app
3+
4+
COPY LICENSE /usr/src/app/
5+
COPY package.json /usr/src/app/
6+
COPY package-lock.json /usr/src/app/
7+
8+
RUN npm install
9+
10+
FROM packages AS builder
11+
WORKDIR /usr/src/app
12+
13+
COPY . /usr/src/app/
14+
RUN npx prisma generate
15+
RUN npm run build
16+
17+
FROM packages AS app
18+
LABEL org.opencontainers.image.source="https://github.com/jetkvm/cloud-api"
19+
WORKDIR /usr/src/app
20+
21+
COPY --from=builder /usr/src/app/prisma /usr/src/app/prisma
22+
COPY --from=builder /usr/src/app/node_modules/.prisma /usr/src/app/node_modules/.prisma
23+
COPY --from=builder /usr/src/app/dist /usr/src/app/dist
24+
COPY .env.example ./.env
25+
26+
ENV NODE_ENV=production
27+
ENV PORT=3000
28+
EXPOSE 3000
29+
CMD ["node", "./dist/index.js"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ If you've found an issue and want to report it, please check our [Issues](https:
2626

2727
## Development
2828

29-
This project is built with Node.JS, Prisma and Express.
29+
This project is built on Node.JS using Prisma and Express.
3030

3131
To start the development server, run:
3232

compose.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: jetkvm-cloud-api
2+
3+
networks:
4+
jetkvm:
5+
driver: bridge
6+
7+
services:
8+
db:
9+
image: postgres
10+
restart: always
11+
environment:
12+
POSTGRES_PASSWORD: jetkvm
13+
POSTGRES_USER: jetkvm
14+
POSTGRES_DB: jetkvm
15+
#ports:
16+
# - "5432:5432"
17+
networks:
18+
- jetkvm
19+
volumes:
20+
- postgresql:/var/lib/postgresql/data
21+
22+
app: &app
23+
build: .
24+
environment:
25+
PORT: 5172
26+
DATABASE_URL: postgres://jetkvm:jetkvm@db:5432/jetkvm
27+
depends_on:
28+
- db
29+
ports:
30+
- "5172:5172"
31+
networks:
32+
- jetkvm
33+
34+
# Trigger prisma migration
35+
# This can be done in the app container as well, but is generally discouraged.
36+
app-migrate:
37+
<<: *app
38+
command: npm run prisma-migrate
39+
ports: []
40+
restart: no
41+
42+
volumes:
43+
postgresql:
44+
driver: local

0 commit comments

Comments
 (0)