Gx
主页
  • 甘特图开发
  • 前端考核
  • js
  • DOCKER 初始化
  • docker 镜像使用
  • docker 镜像定制
  • nestjs 安装
  • 连接数据库
  • typeOrm 操作
  • 任务调度
  • typeorm 一对多,多对一 多对多 一对一 对应实体之间的关系
  • sql 练习
  • 文件相关
  • ts学习
  • 面试题
  • rust
  • 入门
  • 基础
  • 性能公式
  • 线性回归
  • 基础语法
  • 数据类型
  • 复合类型
  • rust 控制流 匹配模式
  • ❤️ 父子传参
  • 🔔 Git的提交规则
主页
  • 甘特图开发
  • 前端考核
  • js
  • DOCKER 初始化
  • docker 镜像使用
  • docker 镜像定制
  • nestjs 安装
  • 连接数据库
  • typeOrm 操作
  • 任务调度
  • typeorm 一对多,多对一 多对多 一对一 对应实体之间的关系
  • sql 练习
  • 文件相关
  • ts学习
  • 面试题
  • rust
  • 入门
  • 基础
  • 性能公式
  • 线性回归
  • 基础语法
  • 数据类型
  • 复合类型
  • rust 控制流 匹配模式
  • ❤️ 父子传参
  • 🔔 Git的提交规则
  • docker 镜像定制

docker 镜像定制

项目目录新建 Dockerfile 文件

# Use an official Node.js runtime as the base image
FROM node:latest as build-stage

# Set the working directory in the container
WORKDIR /app

# Copy the package.json and package-lock.json files to the working directory
COPY package*.json ./

# Install project dependencies
RUN npm install

# Copy all files to the working directory
COPY . .

# Build the project
RUN npm run build

# Use a lightweight nginx image as the base for the second stage
FROM nginx:stable-alpine as production-stage

# Copy the built files from the previous stage to the nginx public directory 复制文件到nginx目录
COPY --from=build-stage /app/dist /usr/share/nginx/html
 
# Copy the nginx configuration file to the nginx configuration directory 自定义nginx配置文件
COPY umiBlog.conf /etc/nginx/nginx.conf
 
# Expose port 80
#EXPOSE 80

# Start the nginx server 
CMD ["nginx", "-g", "daemon off;"] 

.dockerignore 文件

.idea/
.git/
node_modules/
yarn-error.log

nginx 配置文件


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

 server {
   listen 8080;
   index index.html;
   location / {
        root   /usr/share/nginx/html;
        index  index.html;
       try_files $uri $uri/ /index.html;
   }

   location /api/ {
     proxy_pass   http://175.24.115.95:8090/;
   }
 }
}

最近更新: 2024/6/18 05:59
Contributors: G_xing