跳到主要內容

[Python] Flask web in Docker- using pyodbc

 Python flask web run by Docker

*using ODBC:

COPY odbcinst.ini /etc/odbcinst.ini
  • The docker need to install odbc before pip install pyodbc

RUN apt-get update && apt-get install -y --no-install-recommends \
unixodbc-dev \
unixodbc \
libpq-dev

  •     vim odbcinst.ini  , check odbc driver path, then run image setting volumn path

docker run -v /opt/microsoft/:/opt/microsoft/ -p 5000:5000 ProjectName



-Dockerfile:

FROM python:3.7-rc

RUN apt-get update && apt-get install -y --no-install-recommends \
unixodbc-dev \
unixodbc \
libpq-dev

COPY odbcinst.ini /etc/odbcinst.ini

RUN mkdir /TargetPath
COPY ./Project /TargetPath


# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# set work directory
WORKDIR /TargetPath


# install dependencies
RUN pip install --upgrade pip
RUN pip install -r requirements.txt


CMD ["python", "main.py"]

留言

這個網誌中的熱門文章

[python] python 時區轉換 ( timezone )

python 時區轉換 import datetime as dt import pytz d = dt.datetime(2019,1,1,14,0,0) #create Taipei timezone tw = pytz.timezone('Asia/Taipei') #set d timezone is 'Asia/Taipei' twdt = tw.localize(d) #change to utc time utc_dt = twdt.astimezone(pytz.utc) *注意 網路上很多使用 d.replace(tzinfo=tw)   但是可能會出現時差問題, 如下: datetime.time(23, 18, 5, tzinfo=<DstTzInfo 'Asia/Shanghai' LMT+8:06:00 STD>) 參考文件 python时区设置——pytz模块

[HTML] 文字浮水印效果 text watermark css

[.css] .info-mask {     height: 0;       position: absolute;       margin-top:120px;   } .info-opacity {     opacity: 0.8;     color: black; } .info-text {     color: gray;     font-size: 40px;     -webkit-transform: rotate(-5deg);       line-height: 60px;     max-width:1200px;     letter-spacing:3px;     padding-left:0.8em; } [.html]     <div class="info-mask">         <p class="info-text">             WaterMarkText         </p>     </div>    <table class="table table-bordered table-striped table-responsive table-hover" style="position:                 relative;" >        <tbody class="info-opacity" >        </tbody>    </table>

[Linux] 解決 unix ///tmp/supervisor.sock no such file

supercisor run  一段時間系統會自動刪除tmp內的檔案, 這時候就會出現以下問題: unix ///tmp/supervisor.sock no such file 作業環境: Centos 7 *解決方法 修改 supervisor 設定檔 [...]#  vim /etc/supervisor/supervisord.conf [unix_http_server] file= /var/run/ supervisor.sock  ... [supervisord] logfile= /var/log/ supervisord.log ... [supervisorctl] serverurl=unix:/// var/run/ supervisor.sock 重新執行supervisor  關閉supervisor相關進程 [...]#  ps -ef | grep supervisord   [...]#  kill (進程id) 重新執行supervisor [...]# supervisord or [...]# supervisord -c /etc/supervisor/supervisord.conf 參考連結 解决unix:///tmp/supervisor.sock no such file的问题