docker+django+ubuntu服务器 测试质量管理平台部署

1. 首先需要写一个dockerfile就和流水线配置一样

复制代码
# 使用基础的 Python 镜像作为基础
FROM python:3.8

 # 设置工作目录
WORKDIR /mydjpro

 # 将项目的依赖项添加到容器中
COPY requirements.txt /mydjpro/
RUN pip install urllib3
RUN apt-get update && apt-get install -y libmariadb-dev-compat
RUN pip install mysqlclient
RUN python3 -m pip install pytz
RUN pip install --no-cache-dir --ignore-installed --no-deps -r requirements.txt

COPY . /mydjpro/
# 等待数据库启动
RUN sleep 10
#RUN python manage.py migrate

# 运行 Django 项目
RUN python manage.py collectstatic
CMD python manage.py runserver 0:8888

然后setting.py中增加服务器ip地址

0.0.0.0开放所有

复制代码
ALLOWED_HOSTS = ['10.10.32.8', '0.0.0.0', '127.0.0.1']

其中setting.py注意

DEBUG = False 是False的话js和css的静态文件不会生效 在此注意一下!!!!!!!

复制代码
DEBUG = False

2.拉取git的项目代码

复制代码
git clone  仓库地址

构建成镜像

复制代码
 docker build -t integratedtestmanagement:tag .

镜像run成容器

其中8888是容器内部的端口号,8886是对外开放的端口号

复制代码
docker run -p 8886:8888 integratedtestmanagement:tag

没有报错说明就是成功了

最后直接访问

8886端口

相关推荐
a41324473 小时前
ubuntu 25 安装vllm
linux·服务器·ubuntu·vllm
啦啦啦小石头6 小时前
Docker 换源
docker
等什么君!9 小时前
docker -数据卷技术
运维·docker·容器
上天_去_做颗惺星 EVE_BLUE10 小时前
Docker高效使用指南:从基础到实战模板
开发语言·ubuntu·docker·容器·mac·虚拟环境
好好沉淀11 小时前
Docker开发笔记(详解)
运维·docker·容器
禅口魔心13 小时前
Win10 + WSL2 + Docker:K510(DongshanPI-Vision)开发环境从踩坑到跑通全记录(交叉编译 + 上板运行)
docker·嵌入式开发·wsl2·k510
Free Tester14 小时前
基于已有容器生成Dockerfile
docker
芋圆奶绿,要半t14 小时前
ubuntu20/2204修改系统时间的命令
ubuntu
lcx_defender14 小时前
【Docker】Docker部署运行nacos
运维·docker·容器
啦啦啦小石头15 小时前
docker添加用户权限不使用sudo
运维·docker·容器