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端口

相关推荐
量子物理学17 小时前
ubuntu安装docker
ubuntu·docker·eureka
学代码的真由酱17 小时前
Docker基础
运维·docker·容器
MIXLLRED18 小时前
随笔——在 Ubuntu 22.04 中查看 Markdown (.md) 文件
linux·运维·ubuntu·markdown
元直数字电路验证18 小时前
云计算实验笔记(四):容器编排(Container Orchestration)
运维·笔记·docker·云计算
kukubuzai19 小时前
Docker Note
linux·运维·docker
惜年_night19 小时前
Docker部署05-GitLab的CI-CD发布
ci/cd·docker·gitlab
杨某不才19 小时前
内网环境下,使用Docker安装Elasticsearch分词器插件
elasticsearch·docker·jenkins
开开心心就好20 小时前
无弹窗不更新的PC本地播放工具
运维·科技·macos·docker·计算机外设·ocr·powerpoint
面向对象World20 小时前
Z8350 Broadcom SDIO网卡调试Ubuntu 22.04 Server版
linux·运维·ubuntu
小王师傅6620 小时前
深入解析:Docker在Mac上的运行本质与Linux进程管理机制
linux·macos·docker