麻烦部署Docker Image Flask AWS aws beanstalker

发布于 2025-01-31 22:19:48 字数 2203 浏览 3 评论 0原文

我正在尝试使用烧瓶部署机器学习模型,然后使用Docker构建图像,最后用于CI \ CD,并将其部署在AWS Beanstalk上。 烧瓶应用程序在Localhost和Docker Image Run命令上运行良好。

我的整个项目在这里: end2endml

我有以下问题> 502 Bad Gateway

到目前为止:

  • 它在64位Amazon Linux 2/3.4.15-我找不到其他选项上运行 -
  • 我已经阅读了有关端口80或5000我尝试了两者,他们失败了,
  • 我读了日志并收到了此消息 “

我有一个dockerfile和docker-compose.yml用于部署。他们看起来像这样:

FROM python:3.7-slim-bullseye

WORKDIR /app

ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# Install dependencies:
COPY . /app
RUN pip install -r /app/requirements/requirements.txt

EXPOSE 5000

# Run the application:
CMD ["python", "/app/classification_model/application.py"] 


 ---> My docker Compose

# Docker compose for Amazon
version: '3'
services:
  aws_deployment:
    # This function forces Dockerfile
    build:
      # Files (look at the current dir)
      context: .

      # Look for this file
      dockerfile: Dockerfile
    ports:
      - "80:5000"

--> My Travis file 

#autom install a copy of docker 
services:
  - docker

# Do before : -f force -t anynameyouwantforyourimage
before_install: 
  - docker build -t raudez77/end2end-machine-learning -f Dockerfile .

# Run test
# Script contents all script to run
script:
  - docker run raudez77/end2end-machine-learning python test.py -- --coverage

#Deploy into Amazon ElasticBeanstalk
deploy:
  # Use this Saas for deployment
  provider: elasticbeanstalk
  region: "us-west-2"
  # Application name
  app: "docker_titanic"
  # Enviroment
  env: "Dockertitanic-env"
  # Go Services- S3 - look for yout us-west-2 elastickbeanstalk
  bucket_name: "elasticbeanstalk-us-west-2-082124557004"
  bucket_path : "docker_titanic"

  # Create Acces key in Travis
  access_key_id: $AWS_ACCESS_KEY
  secret_access_key: "$AWS_SECRET_KEY"
  on:
    branch: master
  skip_cleanup: true ```

I am trying to deploy a machine learning model using flask, then I used docker to build an image, and finally Travis for CI\CD and deploy it on AWS Beanstalk.
the Flask application runs well on localhost and docker image run command.

My entire project is here: end2endML

I am having the following problem > 502 Bad Gateway

Until now :

  • It is running on 64bit Amazon Linux 2/3.4.15 -I don't find any other option-
  • I have read about the port 80 or 5000 I have tried both and they failed
  • I read the Log and received this message Error

I have a Dockerfile and Docker-compose.yml for deployment. and they look like this:

FROM python:3.7-slim-bullseye

WORKDIR /app

ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# Install dependencies:
COPY . /app
RUN pip install -r /app/requirements/requirements.txt

EXPOSE 5000

# Run the application:
CMD ["python", "/app/classification_model/application.py"] 


 ---> My docker Compose

# Docker compose for Amazon
version: '3'
services:
  aws_deployment:
    # This function forces Dockerfile
    build:
      # Files (look at the current dir)
      context: .

      # Look for this file
      dockerfile: Dockerfile
    ports:
      - "80:5000"

--> My Travis file 

#autom install a copy of docker 
services:
  - docker

# Do before : -f force -t anynameyouwantforyourimage
before_install: 
  - docker build -t raudez77/end2end-machine-learning -f Dockerfile .

# Run test
# Script contents all script to run
script:
  - docker run raudez77/end2end-machine-learning python test.py -- --coverage

#Deploy into Amazon ElasticBeanstalk
deploy:
  # Use this Saas for deployment
  provider: elasticbeanstalk
  region: "us-west-2"
  # Application name
  app: "docker_titanic"
  # Enviroment
  env: "Dockertitanic-env"
  # Go Services- S3 - look for yout us-west-2 elastickbeanstalk
  bucket_name: "elasticbeanstalk-us-west-2-082124557004"
  bucket_path : "docker_titanic"

  # Create Acces key in Travis
  access_key_id: $AWS_ACCESS_KEY
  secret_access_key: "$AWS_SECRET_KEY"
  on:
    branch: master
  skip_cleanup: true ```

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文