debugging - pycharm docker-compose 调试
问题描述
我最近开始研究一个使用 docker-compose 并由多个服务组成的项目,因此在本地安装和调试一直是个问题。我开始寻找一种使用 docker-compose 进行调试的方法,并遇到了这篇文档
虽然这解释了如何使用 Django 配置解释器,但我在项目中使用 Sanic,因此无法按照 T 的教程进行操作。您能否就使用 docker-compose 的运行/调试配置模板提供建议?
我也阅读了这篇文章,但它链接到上述文档。
解决方案
我相信大多数文档应该很容易与 Sanic 一起使用,只要您Dockerfile
稍微修改一下:
FROM python:3.7
WORKDIR /app
# By copying over requirements first, we make sure that Docker will cache
# our installed requirements rather than reinstall them on every build
COPY requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
# Now copy in our code, and run it
COPY . /app
EXPOSE 8000
CMD ["python", "main.py"]
然后在main.py
:
from sanic import Sanic
app = Sanic("MyApp")
# ...
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)
推荐阅读
- javascript - 使用 swiper.js 库做出反应的 CSS 冲突
- javascript - javascript中this关键字的默认绑定?
- audio - 修改一些代码以将 ffmpeg / concat 不同的音频格式转换为 1 个长 WAV 文件
- reactjs - 为什么 setState 不改变值?
- kubernetes - GCP 上的 Kubernetes 集群缺少编辑权限
- sql - SQL - 将时间序列事件转换为开/关对(处理可能丢失的开或关)
- python - Python请求模块不遵循重定向文件下载
- javascript - javascript中类内的引用类型未按预期工作
- javascript - 如何用 js 定义数学值,然后将这些值相乘?
- iis - VS 2017 - Web 应用程序项目 [MyProject] 配置为使用 IIS。您无权访问 IIS 配置文件