Lisy's blog Lisy's blog
首页
后端
前端
读书
关于

新晴

做事情积极主动。积极主动不仅指行事的态度,还意味着为人一定要对自己的人生负责。个人行为取决于自身的抉择,而不是外在的环境,人类应该有营造有利的外在环境的积极性和责任感。
首页
后端
前端
读书
关于
  • Java

  • linux

    • 常用docker-compose文件
    • 利用scp上传文件
    • 使用curl命令发送POST或者GET请求
    • 将java应用打包成uos适用的deb包
    • RPM打包java应用
    • x86架构的Ubuntu20利用QEMU运行arm64环境
    • ubuntu ufw 防火墙常用
    • centos7安装最新的nginx
    • ubuntu设置公钥登录
    • 常用Dockerfile
      • 1. python环境(Fastapi)
      • 2. nginx
    • docker学习
  • python

  • 其他

  • python

  • 后端
  • linux
lisy
2023-12-30
目录

常用Dockerfile

# 1. python环境(Fastapi)

FROM python:3.10.13-alpine

# 设置pip源地址为阿里云镜像源
RUN python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip && \
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
pip install fastapi==0.108.0 && \
pip install "uvicorn[standard]" && \
pip install mysql_connector_repackaged==0.3.1 && \
pip install mysql-connector

# 设置工作目录
WORKDIR /app
COPY app .

ENTRYPOINT ["uvicorn","main:app","--host","0.0.0.0"]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

# 2. nginx

Dockerfile:

# nginx镜像作为基础镜像
FROM nginx:latest

# 设置工作目录为/app
WORKDIR /app

# 删除默认的Nginx配置文件
RUN rm -rf /etc/nginx/conf.d/default.conf
# 将本地的Nginx配置文件复制到容器中
COPY default.conf /etc/nginx/conf.d

# 将本地的Web应用文件复制到工作目录
COPY ./app/app /app

# 暴露容器的80端口
EXPOSE 80

# 启动Nginx服务器
CMD ["nginx", "-g", "daemon off;"]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

default.conf:

server {
    listen 80;
    server_name localhost; #这里可以直接添加IP
    location / {
        root /app;
        try_files $uri $uri/ @router; #
        index index.html;
    }
    #路由配置信息 (解决页面刷新404问题)
    location @router {
        rewrite ^.*$ /index.html last;
    }
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
上次更新: 2024/01/07, 07:44:52
ubuntu设置公钥登录
docker学习

← ubuntu设置公钥登录 docker学习→

最近更新
01
Anaconda conda命令速查
01-05
02
奇特的一生
06-16
03
docker学习
02-16
更多文章>
Theme by Vdoing | Copyright © 2020-2025 lisy | 备案号:鲁ICP备18023702号-1
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式