moved project to docker

This commit is contained in:
Kai Ritthaler 2025-06-30 21:49:51 +02:00
parent 5aa2463064
commit d2d48ca39c
20 changed files with 570 additions and 319 deletions

40
code/docker/Dockerfile Normal file
View file

@ -0,0 +1,40 @@
# -------- Frontend Build --------
FROM node:20 AS frontend-build
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN yarn install
COPY frontend/ .
RUN yarn build
# -------- Backend Build --------
FROM node:20 AS backend-build
WORKDIR /app/backend
COPY backend/package*.json ./
RUN yarn install
COPY backend/prisma ./prisma
RUN yarn prisma generate
# Jetzt den eigentlichen Backend-Code kopieren
COPY backend/ .
RUN yarn build
# -------- Production Image --------
FROM node:20
WORKDIR /app
# Kopiere dist, package.json, node_modules etc.
COPY --from=backend-build /app/backend/dist ./backend/dist
COPY --from=backend-build /app/backend/package*.json ./backend/
COPY --from=backend-build /app/backend/node_modules ./backend/node_modules
COPY --from=backend-build /app/backend/prisma ./backend/prisma
COPY --from=frontend-build /app/frontend/build ./backend/public
WORKDIR /app/backend
EXPOSE 3000
CMD ["yarn", "serve"]

BIN
code/docker/ERP.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 KiB

84
code/docker/README.md Normal file
View file

@ -0,0 +1,84 @@
This is DBML Code. It can be edited and viewed on [dbdiagram.io](https://dbdiagram.io/d)
```
// Docs: https://dbml.dbdiagram.io/docs
Table follows {
following_user_id integer
followed_user_id integer
created_at timestamp
}
Table users {
id integer [primary key]
username varchar [unique]
role varchar
email string
password string
profile_picture integer
bio string
created_at timestamp
}
Table posts {
id integer [primary key]
description varchar
user_id integer [not null]
status varchar
created_at timestamp
}
Table media {
id integer [primary key]
path string
created_at timestamp
}
Table post_media {
media_id integer
post_id integer
}
Table comments {
id integer [primary key]
post_id integer
content string
created_at timestamp
}
Table likes {
id integer [primary key]
post_id integer
user_id integer
created_at timestamp
}
Table tags {
id integer [primary key]
name varchar [unique]
}
Table post_tags {
post_id integer
tag_id integer
}
Ref: post_tags.post_id > posts.id
Ref: post_tags.tag_id > tags.id
Ref: post_media.post_id < posts.id
Ref: post_media.media_id < media.id
Ref: users.profile_picture < media.id
Ref: likes.user_id < users.id
Ref: likes.post_id < posts.id
Ref: posts.id < comments.post_id
Ref user_posts: posts.user_id > users.id // many-to-one
Ref: users.id < follows.following_user_id
Ref: users.id < follows.followed_user_id
```

View file

@ -0,0 +1,72 @@
name: db
services:
# Infrastructure services
db:
image: postgres:17
container_name: postgres-DB
ports:
- "5432:5432"
environment:
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: prisma
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD", "pg_isready", "-U", "${DB_USER}", "-d", "prisma"]
interval: 5s
timeout: 3s
retries: 5
networks:
- app-network
minio:
image: quay.io/minio/minio
container_name: minio
ports:
- "9000:9000" # API
- "9001:9001" # Web GUI
environment:
MINIO_ROOT_USER: ${MINIO_USER}
MINIO_ROOT_PASSWORD: ${MINIO_PASSWORD}
MINIO_BROWSER_REDIRECT_URL: "http://localhost:3001/minio"
command: server /data --console-address ":9001"
volumes:
- minio-data:/data
networks:
- app-network
# Node app - only runs when the "production" profile is activated
node-app:
container_name: featherfeed-node
build:
context: ..
dockerfile: docker/Dockerfile
env_file:
- .env
environment:
- DATABASE_URL=postgresql://${DB_USER}:${DB_PASSWORD}@postgres-DB:5432/prisma
ports:
- "${PORT:-3000}:${PORT:-3000}"
networks:
- app-network
depends_on:
db:
condition: service_healthy
minio:
condition: service_started
profiles: ["production"] # Only runs when production profile is activated
command: >
sh -c "
yarn prisma migrate deploy &&
yarn serve
"
volumes:
pgdata:
minio-data:
networks:
app-network:
name: featherfeed-network