Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue_django_test
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周田
vue_django_test
Commits
aa9acc79
Commit
aa9acc79
authored
Sep 22, 2023
by
周田
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
部署
parent
b72e3d42
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
87 additions
and
64 deletions
+87
-64
docker-compose.yml
docker-compose.yml
+19
-21
dockerfile
dockerfile
+5
-29
nginx.conf
nginx.conf
+62
-0
.yarn-integrity
node_modules/.yarn-integrity
+0
-13
settings.py
vue_django/settings.py
+1
-1
No files found.
docker-compose.yml
View file @
aa9acc79
version
:
'
3'
version
:
'
3'
services
:
services
:
device_web_dockerfile
:
device_web
:
# 通过 dockerfile 创建镜像
build
:
.
# build:
command
:
daphne vue_django.asgi:application --port 8000 --bind 0.0.0.0
# context: .
network_mode
:
"
host"
# dockerfile: Dockerfile
volumes
:
# 如果使用上面的内容下面 image 就不需要了
-
.:/app
image
:
device_web_dockerfile_compose
ports
:
container_name
:
device_web
-
"
8000:8000"
tty
:
true
nginx
:
# 容器的网络模式,如果使用 host 模式,就不需要下面 ports 的内容
image
:
nginx
# ports 的内容是在默认的网络模式 bridge 的情况下设置的
network_mode
:
"
host"
network_mode
:
host
ports
:
# ports:
-
"
10000:10000"
# - "8080:8080"
depends_on
:
-
device_web
# 文件映射,会将整个目录全部替换
volumes
:
# volumes:
-
./nginx.conf:/etc/nginx/nginx.conf
# - .:/app
-
./static:/app/static
environment
:
\ No newline at end of file
TZ
:
"
Asia/Shanghai"
entrypoint
:
"
python
manage.py
runserver
0.0.0.0:8080"
dockerfile
View file @
aa9acc79
# 使用的环境
FROM
python:3.9.18
FROM
ubuntu:20.04
# 升级 apt-get 和 下载 python3.9
# DEBIAN_FRONTEND="noninteractive" 禁用交互
RUN
apt-get update
&&
DEBIAN_FRONTEND
=
"nointeractive"
apt-get install
-y
\
python3.9
\
python3.9-venv
\
python3.9-dev
\
python3-pip
# 工作目录为 /app
# 意味着进入容器后的目录为 /app
WORKDIR
/app
WORKDIR
/app
# 将当前目录下的所有内容拷贝到 /app 目录下
COPY
. /app
COPY
. .
# 使用 python3.9 创建虚拟环境
RUN
pip install poetry
RUN
python3.9
-m
venv ./venv
RUN
poetry config virtualenvs.create
false
&&
poetry install
--no-dev
--no-interaction
--no-ansi
# 将虚拟环境添加到 PATH 中
ENV
PATH="/app/venv/bin:$PATH"
# 使用虚拟环境中的 pip3.9 安装 poetry
RUN
pip3.9 install poetry
-i
https://pypi.tuna.tsinghua.edu.cn/simple
# 使用 poetry 下载项目所需要的依赖
# poetry config virtualenvs.create false 为禁用创建虚拟环境
# 即直接将内容下到刚刚创建的虚拟环境中
RUN
poetry config virtualenvs.create
false
&&
poetry install
# 向外部暴露 8000 端口
EXPOSE
8000
EXPOSE
8000
# 启动容器后运行的命令
CMD
["daphne", "vue_django.asgi:application", "--port", "8000", "--bind", "0.0.0.0"]
ENTRYPOINT
["python", "manage.py", "runserver", "0.0.0.0:8000" ]
nginx.conf
0 → 100644
View file @
aa9acc79
user
nginx
;
worker_processes
auto
;
error_log
/var/log/nginx/error.log
notice
;
pid
/var/run/nginx.pid
;
events
{
worker_connections
1024
;
}
http
{
include
/etc/nginx/mime.types
;
default_type
application/octet-stream
;
log_format
main
'
$remote_addr
-
$remote_user
[
$time_local
]
"
$request
"
'
'
$status
$body_bytes_sent
"
$http_referer
"
'
'"
$http_user_agent
"
"
$http_x_forwarded_for
"'
;
access_log
/var/log/nginx/access.log
main
;
sendfile
on
;
#tcp_nopush on;
keepalive_timeout
65
;
#gzip on;
include
/etc/nginx/conf.d/*.conf
;
upstream
web
{
# server device_web:8000;
server
localhost
:
8000
;
}
server
{
listen
10000
;
server_name
localhost
;
location
/
{
root
/app/static
;
index
index.html
;
}
location
/api
{
proxy_pass
http://web
;
proxy_set_header
Host
$host
;
proxy_set_header
X-Real-IP
$remote_addr
;
proxy_set_header
X-Forwarded-For
$proxy_add_x_forwarded_for
;
proxy_set_header
Accept
application/json
;
}
location
/ws/
{
proxy_pass
http://web
;
proxy_http_version
1
.1
;
proxy_set_header
Upgrade
$http_upgrade
;
proxy_set_header
Connection
"Upgrade"
;
}
}
}
node_modules/.yarn-integrity
deleted
100644 → 0
View file @
b72e3d42
{
"systemParams": "linux-x64-93",
"modulesFolders": [
"node_modules"
],
"flags": [],
"linkedModules": [],
"topLevelPatterns": [],
"lockfileEntries": {},
"files": [],
"artifacts": {}
}
\ No newline at end of file
vue_django/settings.py
View file @
aa9acc79
...
@@ -134,7 +134,7 @@ STATIC_URL = '/static/'
...
@@ -134,7 +134,7 @@ STATIC_URL = '/static/'
# STATIC_ROOT = os.path.join(BASE_DIR, 'static')
# STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_ROOT
=
'static'
STATIC_ROOT
=
'static'
STATICFILES_DIRS
=
[
STATICFILES_DIRS
=
[
#
os.path.join(BASE_DIR, 'frontend', 'dist'),
os
.
path
.
join
(
BASE_DIR
,
'frontend'
,
'dist'
),
# os.path.join(BASE_DIR, 'static'),
# os.path.join(BASE_DIR, 'static'),
]
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment