amazon web services - How do I actually package and move my code, say for a production deployment using Docker? -
i realize there sorts of different strategies , dev opsy architectures deploy docker containers production, i'm still learning of basics of docker , i'm looking straight forward way move following example, aws or remote site. think understand how setup projects in various containers, link them, etc. don't understand how save or package existing code , deploy elsewhere.
here sample template trying work off of.
docker-compose
web: restart: build: ./web expose: - "8000" links: - postgres:postgres - redis:redis volumes: - /usr/src/app - /usr/src/app/static env_file: .env command: /usr/local/bin/gunicorn docker_django.wsgi:application -w 2 -b :8000 nginx: restart: build: ./nginx/ ports: - "80:80" volumes: - /www/static volumes_from: - web links: - web:web postgres: restart: image: postgres:latest ports: - "5432:5432" volumes: - pgdata:/var/lib/postgresql/data/ redis: restart: image: redis:latest ports: - "6379:6379" volumes: - redisdata:/data
dockerfile
from python:2.7 env pythonunbuffered 1 run mkdir /code workdir /code add requirements.txt /code/ run pip install -r requirements.txt add . /code/
this dockerfile creates directory called 'code' assume actual development take place. ie; run docker compose, containers created , start developing in code directory. let's i'm done whatever i'm working on , deploy production using exact same template above, won't dockerfile create empty 'code' directory in aws? work i'm trying deploy code directory on local machine? how package actual code directory move production?
the result of docker build
should image contains of commands, scripts, compiled code, , interpreted code needed run application anywhere. developers may inject own copy of code image volume mount while making changes avoid rebuilding entire container (though docker's layer caching shorten build time).
once built, docker push
image registry server, e.g. docker hub, or can run own (docker has registry image in addition own commercial offering) or use 1 provided third party aws. production environment should docker pull
, run image when deploy production.
Comments
Post a Comment