-
Notifications
You must be signed in to change notification settings - Fork 0
feat: dockerfile for backend #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SAHIL-Sharma21
wants to merge
3
commits into
master
Choose a base branch
from
feat/dockerize-app
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MONGO_DB_URI=mongodb+srv://<user>:<password>@<cluster>/<db>?retryWrites=true&w=majority | ||
| QDRANT_URL=https://<cluster-id>.<region>.aws.cloud.qdrant.io:6333 | ||
| QDRANT_API_KEY=<qdrant-api-key> | ||
|
|
||
| JWT_SECRET=<long-random-secret> | ||
| JWT_EXPIRATION_TIME=3600 | ||
| AUTH_COOKIE_NAME=access_token | ||
|
|
||
| KAFKA_BROKERS=kafka:29092 | ||
| KAFKA_CLIENT_ID=paperstack-backend | ||
| KAFKA_TOPIC=document-processing | ||
| KAFKA_HOST_PORT=19092 | ||
|
|
||
| EMBEDDING_PROVIDER=fastembed | ||
| LLM_PROVIDER=groq | ||
| GROQ_API_KEY=<groq-api-key> | ||
| GEMINI_API_KEY= | ||
|
|
||
| BACKEND_HOST_PORT=8001 | ||
| FRONTEND_HOST_PORT=3000 | ||
| VITE_API_BASE_URL=http://<your-server-or-domain>:8001/api/v1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| node_modules | ||
| dist | ||
| coverage | ||
| uploads | ||
| .env | ||
| .env.* | ||
| npm-debug.log* | ||
| pnpm-debug.log* | ||
| .git |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| FROM node:22-bookworm-slim AS base | ||
|
|
||
| ENV PNPM_HOME=/pnpm | ||
| ENV PATH=$PNPM_HOME:$PATH | ||
|
|
||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends \ | ||
| ca-certificates \ | ||
| python3 \ | ||
| make \ | ||
| g++ \ | ||
| && rm -rf /var/lib/apt/lists/* \ | ||
| && corepack enable | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| FROM base AS deps | ||
|
|
||
| COPY package.json pnpm-lock.yaml ./ | ||
| RUN pnpm install --frozen-lockfile | ||
|
|
||
| FROM deps AS build | ||
|
|
||
| COPY nest-cli.json tsconfig.json tsconfig.build.json ./ | ||
| COPY src ./src | ||
| RUN pnpm build | ||
|
|
||
| FROM base AS prod-deps | ||
|
|
||
| COPY package.json pnpm-lock.yaml ./ | ||
| RUN pnpm install --frozen-lockfile --prod | ||
|
|
||
| FROM node:22-bookworm-slim AS runtime-base | ||
|
|
||
| ENV NODE_ENV=production | ||
| ENV PORT=8001 | ||
| ENV UPLOAD_DIR=/app/uploads | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY --from=prod-deps /pnpm /pnpm | ||
| ENV PNPM_HOME=/pnpm | ||
| ENV PATH=$PNPM_HOME:$PATH | ||
|
|
||
| COPY --from=prod-deps /app/node_modules ./node_modules | ||
| COPY --from=build /app/dist ./dist | ||
| COPY package.json ./ | ||
|
|
||
| RUN mkdir -p /app/uploads && chown -R node:node /app | ||
|
|
||
| USER node | ||
|
|
||
| FROM runtime-base AS api | ||
| EXPOSE 8001 | ||
| CMD ["node", "dist/main"] | ||
|
|
||
| FROM runtime-base AS consumer | ||
| CMD ["node", "dist/consumer/main"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| services: | ||
| zookeeper: | ||
| image: confluentinc/cp-zookeeper:7.5.0 | ||
| container_name: paperstack-zookeeper | ||
| restart: unless-stopped | ||
| environment: | ||
| ZOOKEEPER_CLIENT_PORT: 2181 | ||
| ZOOKEEPER_TICK_TIME: 2000 | ||
| healthcheck: | ||
| test: ['CMD', 'nc', '-z', 'localhost', '2181'] | ||
| interval: 5s | ||
| timeout: 5s | ||
| retries: 5 | ||
| volumes: | ||
| - zookeeper_data:/var/lib/zookeeper/data | ||
|
|
||
| kafka: | ||
| image: confluentinc/cp-kafka:7.5.0 | ||
| container_name: paperstack-kafka | ||
| restart: unless-stopped | ||
| depends_on: | ||
| zookeeper: | ||
| condition: service_healthy | ||
| ports: | ||
| - '127.0.0.1:${KAFKA_HOST_PORT:-19092}:9092' | ||
| environment: | ||
| KAFKA_BROKER_ID: 1 | ||
| KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 | ||
| KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:29092,PLAINTEXT_HOST://0.0.0.0:9092 | ||
| KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:${KAFKA_HOST_PORT:-19092} | ||
| KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT | ||
| KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT | ||
| KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 | ||
| healthcheck: | ||
| test: ['CMD', 'kafka-topics', '--bootstrap-server', 'localhost:29092', '--list'] | ||
| interval: 10s | ||
| timeout: 10s | ||
| retries: 12 | ||
| volumes: | ||
| - kafka_data:/var/lib/kafka/data | ||
|
|
||
| backend: | ||
| platform: linux/amd64 | ||
| build: | ||
| context: ./backend | ||
| dockerfile: dockerfile | ||
| target: api | ||
| container_name: paperstack-backend | ||
| restart: unless-stopped | ||
| depends_on: | ||
| kafka: | ||
| condition: service_healthy | ||
| environment: | ||
| NODE_ENV: production | ||
| PORT: 8001 | ||
| UPLOAD_DIR: /app/uploads | ||
| MONGO_DB_URI: ${MONGO_DB_URI:?MONGO_DB_URI is required} | ||
| QDRANT_URL: ${QDRANT_URL:?QDRANT_URL is required} | ||
| QDRANT_API_KEY: ${QDRANT_API_KEY:-} | ||
| KAFKA_BROKERS: ${KAFKA_BROKERS:-kafka:29092} | ||
| KAFKA_CLIENT_ID: ${KAFKA_CLIENT_ID:-paperstack-backend} | ||
| KAFKA_TOPIC: ${KAFKA_TOPIC:-document-processing} | ||
| JWT_SECRET: ${JWT_SECRET:?JWT_SECRET is required} | ||
| JWT_EXPIRATION_TIME: ${JWT_EXPIRATION_TIME:-3600} | ||
| AUTH_COOKIE_NAME: ${AUTH_COOKIE_NAME:-access_token} | ||
| EMBEDDING_PROVIDER: ${EMBEDDING_PROVIDER:-fastembed} | ||
| LLM_PROVIDER: ${LLM_PROVIDER:-groq} | ||
| GROQ_API_KEY: ${GROQ_API_KEY:-} | ||
| GEMINI_API_KEY: ${GEMINI_API_KEY:-} | ||
| ports: | ||
| - '127.0.0.1:${BACKEND_HOST_PORT:-8001}:8001' | ||
| volumes: | ||
| - uploads_data:/app/uploads | ||
|
|
||
| consumer: | ||
| platform: linux/amd64 | ||
| build: | ||
| context: ./backend | ||
| dockerfile: dockerfile | ||
| target: consumer | ||
| container_name: paperstack-consumer | ||
| restart: unless-stopped | ||
| depends_on: | ||
| kafka: | ||
| condition: service_healthy | ||
| environment: | ||
| NODE_ENV: production | ||
| UPLOAD_DIR: /app/uploads | ||
| MONGO_DB_URI: ${MONGO_DB_URI:?MONGO_DB_URI is required} | ||
| QDRANT_URL: ${QDRANT_URL:?QDRANT_URL is required} | ||
| QDRANT_API_KEY: ${QDRANT_API_KEY:-} | ||
| KAFKA_BROKERS: ${KAFKA_BROKERS:-kafka:29092} | ||
| KAFKA_CLIENT_ID: ${KAFKA_CLIENT_ID:-paperstack-backend} | ||
| KAFKA_TOPIC: ${KAFKA_TOPIC:-document-processing} | ||
| EMBEDDING_PROVIDER: ${EMBEDDING_PROVIDER:-fastembed} | ||
| GEMINI_API_KEY: ${GEMINI_API_KEY:-} | ||
| volumes: | ||
| - uploads_data:/app/uploads | ||
|
|
||
| frontend: | ||
| platform: linux/amd64 | ||
| build: | ||
| context: ./frontend | ||
| dockerfile: dockerfile | ||
| args: | ||
| VITE_API_BASE_URL: ${VITE_API_BASE_URL:?VITE_API_BASE_URL is required} | ||
| container_name: paperstack-frontend | ||
| restart: unless-stopped | ||
| depends_on: | ||
| backend: | ||
| condition: service_started | ||
| ports: | ||
| - '${FRONTEND_HOST_PORT:-3000}:80' | ||
|
|
||
| volumes: | ||
| zookeeper_data: | ||
| kafka_data: | ||
| uploads_data: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| node_modules | ||
| dist | ||
| .env | ||
| .env.* | ||
| npm-debug.log* | ||
| pnpm-debug.log* | ||
| .git |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.