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
7 changes: 1 addition & 6 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PORT=3000

DB_HOST=host.docker.internal
DB_HOST=db
DB_PORT=5432
DB_DATABASE=omnibox
DB_USERNAME=omnibox
Expand All @@ -11,10 +11,5 @@ DB_SYNC=true
JWT_SECRET=your-secret-key
JWT_EXPIRE=2678400s

# REDIS_URL=redis://redis:6379
# REDIS_PORT=6379
# REDIS_TTL=3600

MAIL_TRANSPORT=smtps://your-email@example.com:your-email-password@smtp.example.com:465
MAIL_FROM="No Reply <no-reply@example.com>"

18 changes: 10 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
FROM node:20
FROM node:22 AS builder

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install pm2@latest @nestjs/cli -g
RUN npm install

COPY . .

RUN npm run build

EXPOSE 9005
FROM node:22

WORKDIR /app
COPY package*.json ./
RUN npm install --only=production
COPY --from=builder /usr/src/app/dist ./dist
RUN npm install pm2@latest -g

CMD ["pm2-runtime", "dist/main.js"]
EXPOSE 3000
CMD ["pm2-runtime", "dist/main.js"]
42 changes: 20 additions & 22 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
# Do not use this file in production.
name: omnibox-backend-dev

services:
app:
build: .
image: node:22
ports:
- "8000:${PORT}"
- "${PORT}:${PORT}"
env_file:
- .env
working_dir: /app
volumes:
- ${PWD}:/app
- ${PWD}/.tmp/node_modules:/app/node_modules
command: ["sh", "-c", "npm install && npm run start:debug"]
depends_on:
db:
condition: service_healthy

db:
image: postgres:17-alpine
ports:
- '5432:5432'
- '${DB_PORT:-5432}:${DB_PORT:-5432}'
environment:
- POSTGRES_DB=${DB_DATABASE}
- POSTGRES_USER=${DB_USERNAME}
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_DB=${DB_DATABASE:-omnibox}
- POSTGRES_USER=${DB_USERNAME:-omnibox}
- POSTGRES_PASSWORD=${DB_PASSWORD:-omnibox}
- POSTGRES_PORT=${DB_PORT:-5432}
volumes:
- postgres_data:/var/lib/postgresql/data
- ${PWD}/.tmp/postgres:/var/lib/postgresql/data
healthcheck:
test: ["CMD", "pg_isready", "-q", "-d", "${DB_DATABASE}", "-U", "${DB_USERNAME}"]
interval: 30s
timeout: 10s
test: ["CMD", "pg_isready", "-q", "-d", "${DB_DATABASE:-omnibox}", "-U", "${DB_USERNAME:-omnibox}", "-p", "${DB_PORT:-5432}"]
interval: 5s
timeout: 3s
retries: 5

pgadmin:
Expand All @@ -33,15 +42,4 @@ services:
PGADMIN_DEFAULT_EMAIL: user-name@domain-name.com
PGADMIN_DEFAULT_PASSWORD: strong-password
volumes:
- pgadmin-data:/var/lib/pgadmin

# redis:
# image: redis:7-alpine
# command: redis-server --save 60 1 --loglevel warning
# volumes:
# - redis_data:/data

volumes:
pgadmin-data:
postgres_data:
# redis_data:
- ${PWD}/.tmp/pgadmin:/var/lib/pgadmin
7 changes: 2 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ import { NamespacesModule } from 'src/namespaces/namespaces.module';
inject: [ConfigService],
useFactory: (config: ConfigService) => ({
type: 'postgres',
host: config.get('DB_HOST'),
port: config.get('DB_PORT'),
database: config.get('DB_DATABASE'),
username: config.get('DB_USERNAME'),
password: config.get('DB_PASSWORD'),
logging: config.get('DB_LOGGING'),
synchronize: config.get('DB_SYNC'),
host: config.get('DB_HOST', 'db'),
port: config.get('DB_PORT', 5432),
database: config.get('DB_DATABASE', 'omnibox'),
username: config.get('DB_USERNAME', 'omnibox'),
password: config.get('DB_PASSWORD', 'omnibox'),
logging: config.get('DB_LOGGING', true),
synchronize: config.get('DB_SYNC', false),
autoLoadEntities: true,
}),
}),
Expand Down