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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
55 changes: 31 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
# Use Node LTS version as the base image
FROM node:lts

# Maintainer information
LABEL maintainer="haichang"

#Expose port 3000
EXPOSE 3000

# Create working directory
# Building layer
FROM node:16-alpine as development
# Optional NPM automation (auth) token build argument
# ARG NPM_TOKEN
# Optionally authenticate NPM registry
# RUN npm set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
WORKDIR /app
# Copy configuration files
COPY tsconfig*.json ./
COPY package*.json ./
# Install dependencies from package-lock.json, see https://docs.npmjs.com/cli/v7/commands/npm-ci
RUN npm ci
# Copy application sources (.ts, .tsx, js)
COPY src/ src/
# Build application (produces dist/ folder)
RUN npm run build
# Runtime (production) layer
FROM node:16-alpine as production
# Optional NPM automation (auth) token build argument
# ARG NPM_TOKEN
# Optionally authenticate NPM registry
# RUN npm set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
WORKDIR /app

# Set environment variables
ENV NODE_ENV production

# Copy package.json and package-lock.json to the container
# Copy dependencies files
COPY package*.json ./

# Install dependencies
RUN npm install --production

# Copy the source code to the container
COPY ./dist ./dist

# Set the default command to run when the container starts
CMD ["npm", "run", "start:prod"]
# Install runtime dependecies (without dev/test dependecies)
RUN npm ci --omit=dev
# Copy production build
COPY --from=development /app/dist/ ./dist/
# Expose application port
EXPOSE 3000
# Start application
CMD [ "node", "dist/main.js" ]
5 changes: 3 additions & 2 deletions src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Controller, Get, Header, HttpStatus, Post, Req, Res } from '@nestjs/common';
import { Controller, Get, Post, Req, Res } from '@nestjs/common';
import { AxiosHeaders } from 'axios';
import { Response } from 'express';
import { Request, Response } from 'express';
import { AppService } from './app.service';

@Controller()
Expand Down Expand Up @@ -49,3 +49,4 @@ export class ChatController {
}
}
}

2 changes: 1 addition & 1 deletion src/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class AppService {
}

getHello(): string {
return 'Hello World! 1.4';
return 'Hello World! 1.7';
}

async getCompletions(
Expand Down