I have a Django application whose docker image's Dockerfile
is as follows:
FROM python:3.7
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
RUN pip3 install -r requirements.txt
COPY . /code/
ENV PORT=8000
EXPOSE 8000
Then, I have a docker-compose.yml
file for defining other container images and dependencies for my Django application as follows:
version: '3'
services:
web: &django_app
build: .
command: python3 manage.py runserver 0.0.0.0:8000
ports:
- "80:8000"
depends_on:
- rabbitmq
rabbitmq:
image: rabbitmq:latest
celery_worker:
<<: *django_app
command: celery -A DJingApp worker --loglevel=info
ports: []
depends_on:
- rabbitmq
As you can see above, I've got to have 3 containers( web
, rabbitmq
, and celery_worker
) running at any point in time for my Django app to work.
So, how do I deploy this project's Docker images to AWS Elastic Beanstalk and run them out there? Are there any changes that I will have to make to my Dockerfile
or docker-compose.yml
? If yes, what are they?
It's quite challenging to deploy a multi-container app to Elastic Beanstalk. You need a Dockerrun.aws.json
version 2 configuration file which is an Elastic Beanstalk–specific JSON file that describes how to deploy a set of Docker containers as an Elastic Beanstalk application.
If you don't know how to create the configuration file I suggest reviewing the official page .
And also you can use container transform utility to transform your docker-compose
file to a Dockerrun.aws.json
configuration file which I find very helpful. You may need to make some changes in the autogenerated file.
And also to customize your environment you need to use .ebextensions . Such as defining your Django settings path, WSGI path, web server configurations, executing Django management commands before deployment and so.
For detailed logs, I suggest using environment logs under:
Elastic Beanstalk - Environments - 'your-environment-name' - Logs
Note : I suggest using eb deploy for successful deployment since you need to deploy your source code in .zip
file format.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.