サマリ
①dashサンプルアプリ作成
→②コンテナ化
③AWSデプロイ
dashアプリのコンテナ化
gunicorn化
gunicornインストール
pip install gunicorn
requirements.txt更新
pip freeze > requirements.txt
main.py修正
server = Flask(__name__)
app = Dash(name=__name__ , server=server)
#修正前
#app = Dash(__name__)
Dockerfile作成
FROM python:3.10
ENV DEBIAN_FRONTEND noninteractive
ENV PROJECT_ROOTDIR /work/
WORKDIR $PROJECT_ROOTDIR
COPY ./requirements.txt $PROJECT_ROOTDIR
COPY ./main.py $PROJECT_ROOTDIR
RUN pip install -U pip && \
pip install -r requirements.txt
docker-compose.yml作成
docker-compose.yml
FROM python:3.10
ENV DEBIAN_FRONTEND noninteractive
ENV PROJECT_ROOTDIR /work/
WORKDIR $PROJECT_ROOTDIR
COPY ./requirements.txt $PROJECT_ROOTDIR
COPY ./main.py $PROJECT_ROOTDIR
RUN pip install -U pip && \
pip install -r requirements.txt
EXPOSE 8050
試しに実行
docker-compose up -d