diff --git a/apps/api/.env.example b/apps/api/.env.example index 4f95810..c2bacd8 100644 --- a/apps/api/.env.example +++ b/apps/api/.env.example @@ -22,4 +22,7 @@ REDIS_PORT= REDIS_DOCKER_PORT=6397 OPENAI_API_KEY="sk-your api key" -GPT_MODEL="gpt-4o" \ No newline at end of file +GPT_MODEL="gpt-4o" + +# Docker env +COMPOSE_PROJECT_NAME=transcript-summarizer-api diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile new file mode 100644 index 0000000..8d3e7ac --- /dev/null +++ b/apps/api/Dockerfile @@ -0,0 +1,29 @@ +# Use Node.js 20 as the base image +FROM node:20 + +# Set the working directory inside the container +WORKDIR /app + +# Copy package.json and package-lock.json to the container +COPY package*.json ./ + +# Set NODE_ENV environment variable +ENV NODE_ENV production + +# Running `npm ci` removes the existing node_modules directory and passing in --only=production ensures that only the production dependencies are installed. This ensures that the node_modules directory is as optimized as possible +RUN npm ci --only=production && npm cache clean --force + +# Install Nest CLI globally +RUN npm install -g @nestjs/cli + +# Copy the rest of the application code to the container +COPY . . + +# Build the NestJS application +RUN npm run build + +# Expose the port your application will run on +EXPOSE 3000 + +# Command to start your NestJS application +CMD ["node", "dist/main.js"] diff --git a/apps/api/Transcript Summarization.postman_collection.json b/apps/api/Transcript Summarization.postman_collection.json index 8f4e4f8..11f0cfe 100644 --- a/apps/api/Transcript Summarization.postman_collection.json +++ b/apps/api/Transcript Summarization.postman_collection.json @@ -41,7 +41,7 @@ "formdata": [ { "key": "operations", - "value": "{\"query\":\"mutation ($file: Upload!) {\\n createSummary(createSummaryInput: { inputFile: $file }) {\\n id\\n }\\n}\"}", + "value": "{\"query\":\"mutation ($file: Upload!) {\\n createSummary(createSummaryInput: { inputFile: $file }) {\\n jobId\\n }\\n}\"}", "type": "text" }, { diff --git a/apps/api/docker-compose.yml b/apps/api/docker-compose.yml new file mode 100644 index 0000000..abc4a7c --- /dev/null +++ b/apps/api/docker-compose.yml @@ -0,0 +1,39 @@ +version: '3' +services: + transcript-summarizer-api: + image: transcript-summarizer-api + container_name: transcript-summarizer-api + build: + context: . + dockerfile: Dockerfile + ports: + - '127.0.0.1:${SERVER_PORT}:3000' + depends_on: + - transcript-summarizer-mariadb + - transcript-summarizer-redis + environment: + NODE_ENV: production + + transcript-summarizer-mariadb: + container_name: transcript-summarizer-mariadb + image: mariadb:latest + restart: always + environment: + MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} + MYSQL_USER: ${DB_USERNAME} + MYSQL_PASSWORD: ${DB_PASSWORD} + MYSQL_DATABASE: ${DB_NAME} + ports: + - '127.0.0.1:${MARIADB_DOCKER_PORT}:3306' + volumes: + - transcript-summarizer-mariadb-data:/var/lib/mysql + + transcript-summarizer-redis: + container_name: transcript-summarizer-redis + image: redis:latest + restart: always + ports: + - '127.0.0.1:${REDIS_DOCKER_PORT}:6379' + +volumes: + transcript-summarizer-mariadb-data: ~ diff --git a/apps/api/src/config/typeorm/configuration.ts b/apps/api/src/config/typeorm/configuration.ts index 6dc3fc2..9ef7d1d 100644 --- a/apps/api/src/config/typeorm/configuration.ts +++ b/apps/api/src/config/typeorm/configuration.ts @@ -14,7 +14,6 @@ export default new DataSource({ password: configService.getOrThrow('DB_PASSWORD'), database: configService.getOrThrow('DB_NAME'), entities: [], - autoLoadEntities: true, migrations: ['src/database/migrations/**'], migrationsTableName: 'summary_migrations', synchronize: false,