Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
240 commits
Select commit Hold shift + click to select a range
1b02c69
feat: changing of port by env
efroostrf Jan 2, 2025
539e211
feat: filters for workers
efroostrf Jan 2, 2025
14c3103
feat: upgrade drizzle version
efroostrf Jan 3, 2025
c77bdde
feat: addresses suggestions
efroostrf Jan 3, 2025
932d63f
feat: add redis
efroostrf Jan 3, 2025
1dec2a6
feat: closed forever for restaurants
efroostrf Jan 6, 2025
47a43b2
feat: drizzle db workshops and restaurants structure refactor
efroostrf Jan 6, 2025
37d3a44
fear: crud for restaurant workshops
efroostrf Jan 6, 2025
25dee39
fix: bugs and time decorator
efroostrf Jan 7, 2025
ef6f505
feat: attach restaurantName for worker entity
efroostrf Jan 7, 2025
8b9e342
feat: asignee workers to the workshops
efroostrf Jan 7, 2025
3bfa265
fix: dto
efroostrf Jan 7, 2025
f6bdd17
feat: timezones list api endpoint
efroostrf Jan 8, 2025
416d49b
feat: restaurant timezone assignment
efroostrf Jan 8, 2025
e6e9c90
feat: guests drizzle model
efroostrf Jan 8, 2025
5eea01b
feat: drizzle dishes model
efroostrf Jan 8, 2025
f040134
feat: dishes categories drizzle model with many-to-many
efroostrf Jan 8, 2025
c55d1ab
feat: init of the crud for guests
efroostrf Jan 8, 2025
1a4a644
feat: finish crud for guests
efroostrf Jan 9, 2025
0ec6c4c
feat: dishes crud
efroostrf Jan 10, 2025
ec82dbd
feat: dish categories crud
efroostrf Jan 10, 2025
7f21509
refactor: move drizzle folder to base
efroostrf Jan 10, 2025
d27fec2
fix: errors
efroostrf Jan 10, 2025
289a1d0
feat: drag and drop for sort indexes of categories
efroostrf Jan 10, 2025
b712aee
feat: s3 service with controller
efroostrf Jan 13, 2025
144a648
feat: orders drizzle model init
efroostrf Jan 13, 2025
f5d57ae
feat: dishes and image files relation
efroostrf Jan 13, 2025
eab60ec
refactor: auth module
efroostrf Jan 14, 2025
2aa51ed
refactor: split auth to sessions service
efroostrf Jan 14, 2025
63cc35d
refactor: env
efroostrf Jan 14, 2025
df46b83
feat: nestjs-i18n
efroostrf Jan 14, 2025
d66498c
fix: env coerce
efroostrf Jan 15, 2025
88f174a
feat: link images to the dishes
efroostrf Jan 15, 2025
64814e9
feat: alt text for dish image files
efroostrf Jan 15, 2025
c3c5b9b
refactor: move dish methods to base @ folder
efroostrf Jan 15, 2025
1ecc37c
feat: upload endpoint for dish images
efroostrf Jan 15, 2025
6f9bfaa
feat: editing and deletion of images
efroostrf Jan 15, 2025
022d01a
feat: sort index for updating
efroostrf Jan 15, 2025
d99c574
feat: move admin init to the workers service
efroostrf Jan 16, 2025
3414f53
feat: proper handling for validation errors with custom exception filter
efroostrf Jan 16, 2025
940a747
feat: error filter and translations for custom errors
efroostrf Jan 16, 2025
ee5d205
feat: header for disable refresh session for frontend
efroostrf Jan 16, 2025
2fed35e
feat: dishes to workshops model
efroostrf Jan 16, 2025
cb9156e
feat: dish pricelist endpoint
efroostrf Jan 16, 2025
f4b8964
refactor: individual relation for dish to restaurants and dish to wor…
efroostrf Jan 16, 2025
7657bd0
feat: allow decimals for euro and usd prices
efroostrf Jan 16, 2025
63fbdff
feat: search param for dishes
efroostrf Jan 16, 2025
92bd824
feat: orders drizzle model
efroostrf Jan 19, 2025
925fc21
feat: seed for workers and restaurants
efroostrf Jan 20, 2025
8c966d0
feat: create and find methods for orders
efroostrf Jan 20, 2025
283851f
feat: attach restaurant name to the orders
efroostrf Jan 21, 2025
009c459
feat: dispatcher orders endpoint testing
efroostrf Jan 22, 2025
90d31a6
feat: attention required orders endpoint for dispatcher
efroostrf Jan 22, 2025
0cecd71
feat: delayed orders endpoint
efroostrf Jan 23, 2025
c1853ac
feat: some fixes and features
efroostrf Jan 23, 2025
2d7a9d4
feat: some order creation validation
efroostrf Jan 27, 2025
9b8fb5a
feat: add order dish enpoint and service
efroostrf Jan 27, 2025
5277f1c
refactor: order dishes service
efroostrf Jan 27, 2025
4ae1bdb
feat: put order dish api endpoint
efroostrf Jan 28, 2025
ec09822
feat: remove dish api ednpoint
efroostrf Jan 28, 2025
e1a043e
feat: contry code and currency for restaurants
efroostrf Jan 30, 2025
a7c3626
feat: check table number for order creation
efroostrf Feb 3, 2025
c5dcf22
feat: patch method for orders
efroostrf Feb 3, 2025
b204291
fix: guest name and phone update for orders
efroostrf Feb 3, 2025
8114e25
feat: drizzle model for payment methods
efroostrf Feb 3, 2025
e58ac12
feat: encryption module
efroostrf Feb 4, 2025
27e46e5
feat: order price recalculation
efroostrf Feb 6, 2025
be0182f
feat: bullmq for order recalculation
efroostrf Feb 6, 2025
09b55d8
feat: socket gateway
efroostrf Feb 7, 2025
b465d9e
refactor: order prices service and it's usage in order dishes service
efroostrf Feb 7, 2025
7538ac6
feat: order dishes data update reliability with transaction
efroostrf Feb 7, 2025
9a3f3d3
feat: check table number statement
efroostrf Feb 7, 2025
c4569db
refactor: rename socket folder
efroostrf Feb 7, 2025
8c90f48
feat: scratch for socket notifications for connected users
efroostrf Feb 7, 2025
8028d9b
feat: saving clients from socket gateways to redis (sync steps)
efroostrf Feb 7, 2025
768e9b2
refactor: socket gateway
efroostrf Feb 7, 2025
f077c83
feat: local workers data saving
efroostrf Feb 7, 2025
f8c46bc
feat: timestamps and get workers method
efroostrf Feb 10, 2025
7d08e08
feat: socket gateway emit to clients (without multi-node implementation)
efroostrf Feb 10, 2025
9536382
feat: multiple instances pub/sub socket support with pipeline optimiz…
efroostrf Feb 10, 2025
08338b1
feat: subscriptions for syncing data on frontend
efroostrf Feb 10, 2025
0f960b8
feat: emit different data to recipients implementation
efroostrf Feb 10, 2025
e3f7393
feat: sending data to users about subscription update
efroostrf Feb 10, 2025
296ace6
feat: audit logs for requests with mongodb
efroostrf Feb 11, 2025
8bf9e12
feat: requestId in http exception handler
efroostrf Feb 11, 2025
4dbb09d
feat: snapshots with enabling them for orders
efroostrf Feb 12, 2025
7ff51fb
feat: order update passing workerId to worker snapshots
efroostrf Feb 12, 2025
e85b55b
feat: changes field for schema for tracking what changed
efroostrf Feb 12, 2025
07059a7
refactor: using quoue for snapshots saving
efroostrf Feb 12, 2025
a6fdd0d
feat: order snapshot entity for excluding not using data
efroostrf Feb 12, 2025
587f442
feat: snapshotting for order creation
efroostrf Feb 12, 2025
21be323
feat: audit logs literally for everything
efroostrf Feb 12, 2025
8376792
feat: bullmq for audit logs
efroostrf Feb 12, 2025
53ad137
feat: order dishes snapshots
efroostrf Feb 13, 2025
75cbed1
feat: multiple orders subscription
efroostrf Feb 13, 2025
150b6fa
feat: docs for audit log
efroostrf Feb 14, 2025
62a1b01
feat: notify users about order dishes changes by orderId
efroostrf Feb 17, 2025
f89e624
feat: completedAt field for order
efroostrf Feb 17, 2025
70a5d9e
feat: available actions endpoint
efroostrf Feb 17, 2025
e24b0cc
refactor: controller for order actions
efroostrf Feb 17, 2025
e4fd592
feat: send to kitchen api endpoint
efroostrf Feb 17, 2025
5921d88
refactor: individual controller for order dishes
efroostrf Feb 17, 2025
dd489eb
feat: force ready order dish endpoint
efroostrf Feb 17, 2025
72fbc8d
fix: for dispatcher orders return only not removed order dishes
efroostrf Feb 17, 2025
20e7440
fix: exclude removed dishes from attention required
efroostrf Feb 17, 2025
8e08c1c
fix: imports
efroostrf Feb 18, 2025
47d2dd0
feat: assignment of multiple restaurants to workers
efroostrf Feb 19, 2025
bc1e0ec
feat: restaurantIds filter for workers
efroostrf Feb 19, 2025
a575f2b
feat: ownerId field for restaurants
efroostrf Feb 19, 2025
fb37c79
feat: if owner creates restaurant assign it's id
efroostrf Feb 19, 2025
c816b11
feat: secure fetch of restaurants for different roles
efroostrf Feb 19, 2025
eae9f95
feat: backend payment methods cru(d) for restaurants
efroostrf Feb 19, 2025
dee318f
feat: drizzle model for dish modifiers
efroostrf Feb 19, 2025
4c70da3
feat: restaurant dish modifiers
efroostrf Feb 21, 2025
22547d7
feat: orders and payment method relation
efroostrf Feb 21, 2025
cef90d4
feat: guard for payment methods
efroostrf Feb 21, 2025
2c890bc
fix: dish modifiers is removed flag
efroostrf Feb 21, 2025
19ddc80
feat: endpoint for assigning order dish modifiers
efroostrf Feb 24, 2025
bd9ca06
feat: return order dishes modifiers for get request
efroostrf Feb 24, 2025
71f562b
fix: swagger entity for order dish
efroostrf Feb 24, 2025
0dfafd3
fix: removing modifiers behaviour
efroostrf Feb 24, 2025
37aeb9f
feat: start of kitcheners orders api endpoint development
efroostrf Feb 25, 2025
9c4f191
feat: fetching workshops for order dishes
efroostrf Feb 26, 2025
e4cd676
feat: load modifiers for kitchener order dishes
efroostrf Feb 26, 2025
656fc96
feat: timestamps for orders and order dishes
efroostrf Feb 26, 2025
5f9e0e7
feat: add cooking time and is ready on time flag
efroostrf Feb 26, 2025
29c6da0
refactor: service for kitchener actions
efroostrf Feb 26, 2025
dad1d5c
feat: discounts drizzle model
efroostrf Feb 27, 2025
888596d
feat: discounts controller with service (find many)
efroostrf Feb 28, 2025
2ff3403
feat: create discount endpoint
efroostrf Feb 28, 2025
3739cd0
feat: update method for discounts with patch
efroostrf Feb 28, 2025
f089980
feat: get discount by id api method
efroostrf Mar 3, 2025
27bcfb2
feat: order by createdAt for discounts by default
efroostrf Mar 3, 2025
2f60777
feat: some basic validations for discount entity
efroostrf Mar 3, 2025
00c4264
feat: payment methods assignment for order and dto validations
efroostrf Mar 3, 2025
c30aced
feat: dishes menu drizzle schema
efroostrf Mar 4, 2025
27d9b83
feat: dish menus progress
efroostrf Mar 5, 2025
afa38aa
feat: dishes menus assign a restaurants
efroostrf Mar 6, 2025
10d8492
feat: create and update methods for dishes-menus controller
efroostrf Mar 6, 2025
14e10dd
feat: remove for the dishes menus
efroostrf Mar 6, 2025
f321336
feat: attach owner to the dishes menus entity
efroostrf Mar 6, 2025
3002146
feat: dishes menuId filter
efroostrf Mar 6, 2025
8dacacd
fix: else if statement for update dishes menus
efroostrf Mar 6, 2025
447e7fc
fix: update restaurant ids
efroostrf Mar 6, 2025
f524c55
feat: define property for some errors and min length for dishes menu …
efroostrf Mar 6, 2025
3e8cb13
feat: menuId query param for restaurants
efroostrf Mar 6, 2025
63024a8
feat: ownerId filter for the restaurants
efroostrf Mar 6, 2025
bc6d278
feat: redlock module
efroostrf Mar 6, 2025
1759b25
feat: create default dish menu for restaurant owner if it don't have any
efroostrf Mar 6, 2025
6d9cbd9
refactor: snake_case for drizzle postgres database to prevent errors
efroostrf Mar 7, 2025
e0c4d16
feat: assign dish categories to the menus
efroostrf Mar 7, 2025
2f0ad89
feat: configure guard for the restaurants update/create
efroostrf Mar 7, 2025
a650e81
feat: dishes service checks for the worker role and menu
efroostrf Mar 7, 2025
c8da968
feat: load only dish menu restaurants for pricelist
efroostrf Mar 7, 2025
143c6a7
feat: validation of assign dish price for restaurants
efroostrf Mar 7, 2025
3cdf2a6
feat: redlock for session jwt update
efroostrf Mar 10, 2025
3184be6
feat: api endpoint for fetching available dishes for order
efroostrf Mar 10, 2025
85045a7
feat: additional fields for order dish at order menu
efroostrf Mar 10, 2025
fead4ea
feat: search param for the order menu dishes
efroostrf Mar 10, 2025
25c1bf2
feat: workshifts with payments drizzle schema
efroostrf Mar 11, 2025
886e617
feat: order dish returnments drizzle model
efroostrf Mar 11, 2025
4938e26
feat: implement guard for force-ready endpoint
efroostrf Mar 12, 2025
ea7b2b8
refactor: order dishes repository
efroostrf Mar 12, 2025
3e7b3d2
refactor: orders repository
efroostrf Mar 12, 2025
04fd501
feat: replace order dishes update methods with repository
efroostrf Mar 12, 2025
e8c4fc2
feat: order dish return endpoint
efroostrf Mar 12, 2025
6fa9363
feat: update modifiers only of pending order dishes
efroostrf Mar 12, 2025
23fa91c
feat: min length for dish returnment
efroostrf Mar 12, 2025
4975afb
feat: workshifts module with controller and findMany method
efroostrf Mar 12, 2025
f0ddf9b
feat: open workshift endpoint
efroostrf Mar 13, 2025
1dbe015
feat: close workshifts endpoint
efroostrf Mar 13, 2025
540eb5a
feat: restaurantId filter for findMany workshifts
efroostrf Mar 13, 2025
eee0275
feat: navigation endpoint for workshifts
efroostrf Mar 13, 2025
de1549b
feat: workshift payment category drizzle model
efroostrf Mar 13, 2025
0f70158
feat: workshift restaurant category entity
efroostrf Mar 14, 2025
b50d755
feat: crud for workshift payment categories of restaurants
efroostrf Mar 17, 2025
60c56a2
feat: updating is active state
efroostrf Mar 17, 2025
286580e
feat: dockerfile
efroostrf Mar 17, 2025
714ac43
feat: get workshift api endpoint
efroostrf Mar 18, 2025
db51adf
feat: fix timestamps to be with timezone and onUpdate for updatedAt
efroostrf Mar 25, 2025
e138f42
feat: run swagger only on dev
efroostrf Mar 25, 2025
158af19
feat: find and create workshift payments
efroostrf Mar 25, 2025
4919f00
feat: remove workshift payment method
efroostrf Mar 25, 2025
9abc20f
feat: attach worker to payments
efroostrf Mar 25, 2025
9f9af72
feat: workshift payment type filter
efroostrf Mar 25, 2025
f3412fd
feat: replace single type selection with multiple for workshift payment
efroostrf Mar 25, 2025
f45f22e
feat: src compiler
efroostrf Mar 25, 2025
956ef6b
feat: migration to fastify from express
efroostrf Mar 25, 2025
a230805
fix: is removed for childrens payment categories
efroostrf Mar 25, 2025
8f4416a
feat: add currency expose of restaurant for workshift endpoint
efroostrf Mar 25, 2025
af6ef44
feat: restaurant currency update ability and put to patch
efroostrf Mar 25, 2025
c605840
feat: take currency for order from restaurant
efroostrf Mar 25, 2025
fe30cc7
feat: check currency of restaurant before assign pricelist
efroostrf Mar 25, 2025
bff4958
fix: fastify multipart
efroostrf Mar 25, 2025
22bc152
feat: take restaurant currency for workshift payments
efroostrf Mar 25, 2025
c977ca1
feat: desc sorting for workshift payments
efroostrf Mar 26, 2025
f8fcbbd
feat: cashier access to workshift payment categories
efroostrf Mar 26, 2025
939d1f3
fix: zero order price calculation
efroostrf Mar 26, 2025
8a12241
feat: prechecks for orders drizzle model
efroostrf Mar 26, 2025
fb283e3
feat: upgrade some packages
efroostrf Mar 26, 2025
5993be9
feat: order prechecks controller method
efroostrf Mar 26, 2025
437279c
feat: order history records drizzle model
efroostrf Mar 26, 2025
b29c75d
feat: remove unneded updatedAt for prechecks
efroostrf Mar 26, 2025
9285723
feat: order history endpoint
efroostrf Mar 27, 2025
7da5daa
feat: draft of caching module
efroostrf Mar 27, 2025
edad0d8
feat: additional statuses for history
efroostrf Mar 27, 2025
01d4121
feat: find one kitchener order endpoint
efroostrf Mar 27, 2025
01348a4
feat: rethinking of socket notifications to notifications only, fetch…
efroostrf Mar 27, 2025
bef2845
fix: remove passwordHash in any circumstances
efroostrf Mar 27, 2025
9c9bb4a
feat: new order job processor with socket
efroostrf Mar 27, 2025
fb36fdb
refactor: simplier logic for data revalidation on frontend with track…
efroostrf Mar 27, 2025
1441e2c
feat: seed utility
efroostrf Mar 28, 2025
f7d8f00
feat: sent to kitchen orders seed
efroostrf Mar 28, 2025
f6b8529
feat: chunker for insane seed size and k6 testing (IT WORKS FOR 3000 …
efroostrf Mar 28, 2025
84e0c0d
draft: some things
efroostrf Mar 31, 2025
d20d18f
feat: a lot of useful changes
efroostrf Mar 31, 2025
9bf9a4f
feat: get order discounts method
efroostrf Apr 1, 2025
1b9ceb1
feat: assigning restaurants, dish menus, dish categories to discounts
efroostrf Apr 2, 2025
51f0933
feat: assign category ids for dishes
efroostrf Apr 2, 2025
b588b1f
fix: dishes to categories relations
efroostrf Apr 2, 2025
3e1ff2b
feat: categoryId query param for selecting dishes
efroostrf Apr 2, 2025
e258544
feat: query params for loading only active restaurants
efroostrf Apr 3, 2025
5c16993
feat: order get dish categories endpoint
efroostrf Apr 3, 2025
593c85d
feat: order available dishes filter by category id
efroostrf Apr 3, 2025
6bcf52f
feat: internal drizzle models for discounts apply
efroostrf Apr 3, 2025
2268ed5
feat: order discounts where condition for new requirments
efroostrf Apr 3, 2025
8b8544d
feat: remove deprecated discount fields and change namings
efroostrf Apr 3, 2025
d099f52
feat: guests assign to the discounts
efroostrf Apr 3, 2025
abcf7f7
feat: timestamp for knowing when guest was added to the discount
efroostrf Apr 3, 2025
6974e36
feat: include phone for discount guest
efroostrf Apr 3, 2025
c99d60f
feat: dark theme for swagger
efroostrf Apr 3, 2025
8bbf2d7
feat: find or create guest method
efroostrf Apr 3, 2025
b7057eb
fix: unique contraint for guests email
efroostrf Apr 3, 2025
9838d27
fix: zero length discount ids
efroostrf Apr 3, 2025
92d6bd7
feat: draft of discounts apply
efroostrf Apr 3, 2025
1047383
refactor: order discounts methods and repository
efroostrf Apr 4, 2025
0bcd138
feat: order history log for discounts enabling
efroostrf Apr 4, 2025
5c4a604
feat: security patches
efroostrf Apr 7, 2025
13183b8
feat: demo deployment
efroostrf Apr 7, 2025
a1fcccc
fix: upgrade pg from 8.11.3 to 8.14.1
snyk-bot Apr 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
37 changes: 37 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Version control
.git
.gitignore
.gitattributes

# Dependencies
node_modules
npm-debug.log
yarn-debug.log
yarn-error.log

# Environment
.env
.env.*

# Development
.vscode
.idea
*.md
test
coverage
.prettierrc
jest.config.js

# Build
dist
build

# Docker
Dockerfile
.dockerignore

# Misc
.DS_Store
*.log
*.swp
*.bak
7 changes: 6 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ POSTGRESQL_URL=postgres://root:password@192.168.1.120:8333/postgres
MONGO_URL=mongodb://admin:123456@192.168.1.120:27017/db?authSource=admin
JWT_SECRET=secret
SESSION_EXPIRES_IN=1h
INITIAL_ADMIN_PASSWORD=123456
INITIAL_ADMIN_PASSWORD=123456
PORT=6701
DADATA_API_TOKEN=
GOOGLE_MAPS_API_KEY=
REDIS_URL=redis://localhost:6379
DEV_SECRET_KEY=123456
33 changes: 32 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = {
],
"newlines-between": "always",
alphabetize: {
order: "asc" /* asc или desc */,
order: "asc",
caseInsensitive: true,
},
},
Expand All @@ -51,5 +51,36 @@ module.exports = {
"import/first": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",
"no-restricted-imports": [
"error",
{
paths: [
{
name: "class-validator",
message:
"Import custom validators from @i18n-class-validator instead",
},
],
patterns: [
{
group: ["class-validator/*"],
message:
"Import custom validators from @i18n-class-validator instead",
},
],
},
],
"import/no-restricted-paths": [
"error",
{
zones: [
{
target: "./src/**/*",
from: "class-validator",
except: ["./src/i18n/validators/index.ts"],
},
],
},
],
},
};
9 changes: 8 additions & 1 deletion .example.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
POSTGRESQL_URL=postgres://root:password@164.92.197.53:8333/testdb
JWT_SECRET=secret
SESSION_EXPIRES_IN=1s
INITIAL_ADMIN_PASSWORD=123456
INITIAL_ADMIN_PASSWORD=123456
PORT=6701
DADATA_API_TOKEN=
GOOGLE_MAPS_API_KEY=
REDIS_URL=
API_SECRET_KEY=
DEV_SECRET_KEY=
COOKIES_SECRET=
22 changes: 13 additions & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"javascript.updateImportsOnFileMove.enabled": "always",
"typescript.updateImportsOnFileMove.enabled": "always",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"npm.packageManager": "yarn"
}
"javascript.updateImportsOnFileMove.enabled": "always",
"typescript.updateImportsOnFileMove.enabled": "always",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"npm.packageManager": "yarn",
"workbench.colorCustomizations": {
"minimap.background": "#00000000",
"scrollbar.shadow": "#00000000"
}
}
60 changes: 60 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Build stage
FROM node:22-alpine AS builder

WORKDIR /app

# Install python and build dependencies
RUN apk add --no-cache python3 make g++

COPY package.json yarn.lock ./

# Install dependencies
RUN yarn install --frozen-lockfile

COPY . .

# Build the application
RUN yarn build

# Production stage
FROM node:22-alpine AS production

WORKDIR /app

# Install python and build dependencies for production packages that need compilation
RUN apk add --no-cache python3 make g++

COPY package.json yarn.lock ./

# Install only production dependencies
RUN yarn install --frozen-lockfile --production

FROM node:22-alpine AS runner
WORKDIR /app

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nestjs

COPY --from=production /app/node_modules ./node_modules

RUN mkdir dist

RUN chown nestjs:nodejs dist
RUN chown nestjs:nodejs node_modules

# Copy built assets from builder stage
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/src/i18n ./src/i18n
COPY --from=builder /app/src/i18n/messages ./dist/i18n/messages

# Set environment variables
ENV NODE_ENV=production
ENV PORT=3000

# Expose the port the app runs on
EXPOSE ${PORT}

USER nestjs

# Start the application
CMD ["node", "dist/src/main.js"]
25 changes: 25 additions & 0 deletions deployment/.example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
DOMAIN=demo.toite.ee

# Docker images
BACKEND_REPO_IMAGE=yefro/toite-backend:latest
FRONTEND_REPO_IMAGE=yefro/toite-frontend:latest

# Secrets
# openssl rand -base64 32
JWT_SECRET=
CSRF_SECRET=
COOKIES_SECRET=
INITIAL_ADMIN_PASSWORD=
REDIS_PASSWORD=
POSTGRES_PASSWORD=
MONGO_PASSWORD=

# S3
S3_ACCESS_KEY_ID=
S3_SECRET_ACCESS_KEY=
S3_BUCKET_NAME=
S3_ENDPOINT=

# Api keys
DADATA_API_TOKEN=
GOOGLE_MAPS_API_KEY=
162 changes: 162 additions & 0 deletions deployment/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
version: "3.9"
name: "toite"

services:
traefik:
container_name: traefik
image: traefik:v3.3
ports:
- "80:80"
- "443:443"
- "443:443/tcp" # HTTP/3
- "443:443/udp" # HTTP/3
- "8080:8080"
networks:
toite-network:
ipv4_address: 172.36.0.2
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./traefik.yml:/etc/traefik/traefik.yml:ro" # Static configuration
- "traefik-data:/data" # Certificates and etc
labels:
- "traefik.enable=true"
# Global redirection to https
- "traefik.http.routers.http-catchall.rule=Host(`${DOMAIN}`)"
- "traefik.http.routers.http-catchall.entrypoints=web"
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"

# Running mongo database
mongo:
container_name: mongo
build:
context: mongo
dockerfile: Dockerfile
restart: unless-stopped
environment:
MONGO_INITDB_ROOT_USERNAME: toite
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD}
ports:
- "27017:27017"
networks:
toite-network:
ipv4_address: 172.36.0.3
volumes:
- "mongo-data:/data/db"

# Running simple postgres database
postgres:
container_name: postgres
image: postgres
restart: unless-stopped
environment:
PGDATA: /data/postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
ports:
- "5432:5432"
networks:
toite-network:
ipv4_address: 172.36.0.4
volumes:
- "postgres-data:/data/postgres"

# Running redis cache
redis:
container_name: redis
image: redis:6.2-alpine
command: redis-server --save 20 1 --loglevel warning --requirepass "${REDIS_PASSWORD}"
restart: unless-stopped
ports:
- "6379:6379"
networks:
toite-network:
ipv4_address: 172.36.0.5
volumes:
- "redis-data:/data"

backend:
container_name: toite-backend
image: ${BACKEND_REPO_IMAGE:-yefro/toite-backend:latest}
restart: unless-stopped
environment:
NODE_ENV: production
PORT: 5000
MONGO_URL: mongodb://toite:${MONGO_PASSWORD}@172.36.0.3:27017/toite?authSource=admin&directConnection=true
POSTGRESQL_URL: postgres://postgres:${POSTGRES_PASSWORD}@172.36.0.4:5432/postgres
JWT_SECRET: ${JWT_SECRET}
CSRF_SECRET: ${CSRF_SECRET}
SESSION_EXPIRES_IN: 4h
INITIAL_ADMIN_PASSWORD: ${INITIAL_ADMIN_PASSWORD}
DADATA_API_TOKEN: ${DADATA_API_TOKEN}
GOOGLE_MAPS_API_KEY: ${GOOGLE_MAPS_API_KEY}
REDIS_URL: redis://:${REDIS_PASSWORD}@172.36.0.5:6379
COOKIES_SECRET: ${COOKIES_SECRET}
S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID}
S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY}
S3_BUCKET_NAME: ${S3_BUCKET_NAME}
S3_ENDPOINT: ${S3_ENDPOINT}
S3_REGION: ${S3_REGION}
ports:
- "5000:5000"
networks:
toite-network:
ipv4_address: 172.36.0.10
depends_on:
- redis
- postgres
- mongo
labels:
- "traefik.enable=true"
- "traefik.http.routers.backend.rule=Host(`${DOMAIN}`) && (PathPrefix(`/api`) || PathPrefix(`/socket.io`))"
- "traefik.http.routers.backend.entrypoints=websecure"
- "traefik.http.routers.backend.tls.certresolver=letsencrypt"
- "traefik.http.services.backend.loadbalancer.server.port=5000"
- "traefik.http.routers.backend.middlewares=strip-api" # Apply the middleware

# Define the middleware to strip the /api prefix
- "traefik.http.middlewares.strip-api.stripprefix.prefixes=/api"

frontend:
container_name: toite-frontend
image: ${FRONTEND_REPO_IMAGE:-yefro/toite-frontend:latest}
restart: unless-stopped
environment:
NODE_ENV: production
NEXT_INTERNAL_API_URL: http://172.36.0.10
ports:
- "3000:3000"
networks:
toite-network:
ipv4_address: 172.36.0.11
depends_on:
- backend
labels:
- "traefik.enable=true"
- "traefik.http.routers.frontend.rule=Host(`${DOMAIN}`)"
- "traefik.http.routers.frontend.entrypoints=websecure"
- "traefik.http.routers.frontend.tls.certresolver=letsencrypt"
- "traefik.http.services.frontend.loadbalancer.server.port=3000"

volumes:
# SSL and etc.
traefik-data:
driver: local
# Mongo data storage
mongo-data:
driver: local
# Postgres data storage
postgres-data:
driver: local
# Redis data storage
redis-data:
driver: local

networks:
# Shared network
toite-network:
driver: bridge
ipam:
config:
- subnet: 172.36.0.0/16
gateway: 172.36.0.1
Loading