Skip to content

Commit a3c25c2

Browse files
authored
Merge pull request #19 from import-ai/feature/deploy
Support debug with compose.yaml
2 parents 492d1e0 + 347cee3 commit a3c25c2

File tree

5 files changed

+40
-48
lines changed

5 files changed

+40
-48
lines changed

.env.example

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PORT=3000
22

3-
DB_HOST=host.docker.internal
3+
DB_HOST=db
44
DB_PORT=5432
55
DB_DATABASE=omnibox
66
DB_USERNAME=omnibox
@@ -11,10 +11,5 @@ DB_SYNC=true
1111
JWT_SECRET=your-secret-key
1212
JWT_EXPIRE=2678400s
1313

14-
# REDIS_URL=redis://redis:6379
15-
# REDIS_PORT=6379
16-
# REDIS_TTL=3600
17-
1814
MAIL_TRANSPORT=smtps://your-email@example.com:your-email-password@smtp.example.com:465
1915
MAIL_FROM="No Reply <no-reply@example.com>"
20-

Dockerfile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
FROM node:20
1+
FROM node:22 AS builder
22

33
WORKDIR /usr/src/app
4-
54
COPY package*.json ./
6-
7-
RUN npm install pm2@latest @nestjs/cli -g
85
RUN npm install
9-
106
COPY . .
11-
127
RUN npm run build
138

14-
EXPOSE 9005
9+
FROM node:22
10+
11+
WORKDIR /app
12+
COPY package*.json ./
13+
RUN npm install --only=production
14+
COPY --from=builder /usr/src/app/dist ./dist
15+
RUN npm install pm2@latest -g
1516

16-
CMD ["pm2-runtime", "dist/main.js"]
17+
EXPOSE 3000
18+
CMD ["pm2-runtime", "dist/main.js"]

compose.yaml

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,37 @@
1+
# Do not use this file in production.
2+
name: omnibox-backend-dev
3+
14
services:
25
app:
3-
build: .
6+
image: node:22
47
ports:
5-
- "8000:${PORT}"
8+
- "${PORT}:${PORT}"
69
env_file:
710
- .env
11+
working_dir: /app
12+
volumes:
13+
- ${PWD}:/app
14+
- ${PWD}/.tmp/node_modules:/app/node_modules
15+
command: ["sh", "-c", "npm install && npm run start:debug"]
816
depends_on:
917
db:
1018
condition: service_healthy
1119

1220
db:
1321
image: postgres:17-alpine
1422
ports:
15-
- '5432:5432'
23+
- '${DB_PORT:-5432}:${DB_PORT:-5432}'
1624
environment:
17-
- POSTGRES_DB=${DB_DATABASE}
18-
- POSTGRES_USER=${DB_USERNAME}
19-
- POSTGRES_PASSWORD=${DB_PASSWORD}
25+
- POSTGRES_DB=${DB_DATABASE:-omnibox}
26+
- POSTGRES_USER=${DB_USERNAME:-omnibox}
27+
- POSTGRES_PASSWORD=${DB_PASSWORD:-omnibox}
28+
- POSTGRES_PORT=${DB_PORT:-5432}
2029
volumes:
21-
- postgres_data:/var/lib/postgresql/data
30+
- ${PWD}/.tmp/postgres:/var/lib/postgresql/data
2231
healthcheck:
23-
test: ["CMD", "pg_isready", "-q", "-d", "${DB_DATABASE}", "-U", "${DB_USERNAME}"]
24-
interval: 30s
25-
timeout: 10s
32+
test: ["CMD", "pg_isready", "-q", "-d", "${DB_DATABASE:-omnibox}", "-U", "${DB_USERNAME:-omnibox}", "-p", "${DB_PORT:-5432}"]
33+
interval: 5s
34+
timeout: 3s
2635
retries: 5
2736

2837
pgadmin:
@@ -33,15 +42,4 @@ services:
3342
PGADMIN_DEFAULT_EMAIL: user-name@domain-name.com
3443
PGADMIN_DEFAULT_PASSWORD: strong-password
3544
volumes:
36-
- pgadmin-data:/var/lib/pgadmin
37-
38-
# redis:
39-
# image: redis:7-alpine
40-
# command: redis-server --save 60 1 --loglevel warning
41-
# volumes:
42-
# - redis_data:/data
43-
44-
volumes:
45-
pgadmin-data:
46-
postgres_data:
47-
# redis_data:
45+
- ${PWD}/.tmp/pgadmin:/var/lib/pgadmin

package-lock.json

Lines changed: 2 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/app.module.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ import { NamespacesModule } from 'src/namespaces/namespaces.module';
4444
inject: [ConfigService],
4545
useFactory: (config: ConfigService) => ({
4646
type: 'postgres',
47-
host: config.get('DB_HOST'),
48-
port: config.get('DB_PORT'),
49-
database: config.get('DB_DATABASE'),
50-
username: config.get('DB_USERNAME'),
51-
password: config.get('DB_PASSWORD'),
52-
logging: config.get('DB_LOGGING'),
53-
synchronize: config.get('DB_SYNC'),
47+
host: config.get('DB_HOST', 'db'),
48+
port: config.get('DB_PORT', 5432),
49+
database: config.get('DB_DATABASE', 'omnibox'),
50+
username: config.get('DB_USERNAME', 'omnibox'),
51+
password: config.get('DB_PASSWORD', 'omnibox'),
52+
logging: config.get('DB_LOGGING', true),
53+
synchronize: config.get('DB_SYNC', false),
5454
autoLoadEntities: true,
5555
}),
5656
}),

0 commit comments

Comments
 (0)