V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  kentxxq  ›  全部回复第 2 页 / 共 2 页
回复总数  24
1  2  
2018 年 11 月 22 日
回复了 kentxxq 创建的主题 Python 关于 docker 打包 Python 环境的问题
不折腾了
2018 年 11 月 22 日
回复了 kentxxq 创建的主题 Python 关于 docker 打包 Python 环境的问题
```python:3-alpine
RUN sed -i "s@http://dl-cdn.alpinelinux.org/@https://mirrors.huaweicloud.com/@g" /etc/apk/repositories \
&& apk update \
&& apk upgrade \
&& apk add --no-cache git build-base make linux-headers openssl-dev libffi-dev \
&& pip --no-cache-dir install pip -U \
&& pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ \
&& pip --no-cache-dir install requirementslib \
&& python tt.py > requirements.txt \
&& pip --no-cache-dir install -r requirements.txt \
&& rm -rf /var/cache/apk/*
```

```python:3-slim
FROM python:3-slim

COPY . /root/

WORKDIR /root


RUN pip install pip -U \
&& pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ \
&& pip --no-cache-dir install requirementslib \
&& python tt.py > requirements.txt \
&& pip --no-cache-dir install -r requirements.txt


CMD ["gunicorn","-c","gunicorn_config.py","run:app"]
```

最终通过这几个包,满足了我现在的需要。但是:
```
myapp alpine bc665f800e59 20 seconds ago 318MB
myapp slim e675bfd36544 5 minutes ago 202MB
```

1.体积反而更大了...(不想再花更多时间在这上面)。我其实只看重这点才用 alpine
2.我还应该把 RUN 里面 apk 语句放到一个新的层来做缓存,加速构建
3.pipenv 在 alpine 下问题也比 slim 版本多.....

安心写代码去了
2018 年 11 月 21 日
回复了 kentxxq 创建的主题 Python 关于 docker 打包 Python 环境的问题
@x66 阿里云的镜像构建没有香港节点。。。 最近的貌似是新加坡,还不如选国内。。



@Beebird 学到了。 最后折腾一晚上 alpine,然后安心用 debian 了。
2018 年 11 月 21 日
回复了 kentxxq 创建的主题 Python 关于 docker 打包 Python 环境的问题
@shylockhg 嗯,又可以小一丢丢


@tomczhen 对个人学习项目来说,有点大。。
我 gitlab 提交。触发阿里的镜像构建。然后触发拉取镜像,重新部署。
我是想快速集成部署的。 结果。。
1  2  
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   1992 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 10ms · UTC 00:31 · PVG 08:31 · LAX 16:31 · JFK 19:31
♥ Do have faith in what you're doing.