Elastic beanstalk require python 3.5

南楼画角 提交于 2019-12-04 12:47:31

The way I ended up solving this was to create a python based docker container, and switch to using the elastic beanstalk docker configuration. I'm including the script below to help folks out. Note that it doesn't contain uwsgi or supervisor, as it's just a first pass. You might want to add those depending on your situation.

Dockerfile

FROM python:3.5

ADD . /src

RUN apt-get update
RUN apt-get install -y postgresql postgresql-contrib libpq-dev python3-dev
RUN pip3 install -r /src/requirements.txt
EXPOSE  8080
RUN python3 --version
CMD ["python3", "/src/application.py", "-p 8080"]

This solution works on 06.06.2017 with AMI image: ami-1871797e

In your project simply create file .ebextensions/00_python_version.config with contents:

packages:
  yum:
    postgresql94-devel: []
    postgresql95-devel: []
    libffi-devel: []
    python35: []
    python35-devel: []
    python35-libs: []
    mod24_wsgi-python35: []

files:
  "/temp/change_python.sh":
    mode: "000644"
    owner: root
    group: root
    content: |
      rm -rf /opt/python/run/venv
      virtualenv -p /usr/bin/python35 /opt/python/run/venv
      rm -rf /opt/python/run/baselinenv
      ln -sf /opt/python/run/venv /opt/python/run/baselinenv

files:
  "/temp/change_python_2.sh":
    mode: "000644"
    owner: root
    group: root
    content: |
      ln -sf /opt/python/run/venv/lib64/python3.5 /opt/python/run/venv/lib64/python3.4
      ln -sf /opt/python/run/venv/lib/python3.5 /opt/python/run/venv/lib/python3.4

commands:
  00_aws_change_python:
    command: "sh /temp/change_python.sh"

container_commands:
  00_aws_change_python_2:
    command: "sh /temp/change_python_2.sh"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!