-
Notifications
You must be signed in to change notification settings - Fork 14
Infra
Vagrant
You put code into environments
Run provisioning script onto VM =>
installs correct software (node.js version, user permissions, config)
Docker
You build your environment and can run it anywhere
Runs off of containers.
Dockerfile builds a docker image.
Docker image: complete app code that will sit on top of a machine (you don't store the machine on the image)
Run docker image in a container.
Push that image to Docker Hub (or others)
Any other machine can run your IMAGE. [docker run myProjectImage]
-> Since the image contains the entire image you don't need to install any software on that new machine
-> In other words, no need to install npm, node.js, etc.
-> Cloud Clusters: All the computers to act as one; share resources. Spin up containers all run in the cluster.
nginx: Can spin up an nginx container and load balance the containers and provide a port to allow one to
access the app.
Python & Docker
Docker container interacts directly with host kernel.
Spin up more processes? Spin up more containers.
Docker host?
The image contains everything (code, modules, dependencies, etc.)
Docker build
: Dependencies, nginx, wsgi, etc.
Docker run
: Makes instance of the app, creates a container (running instance of the app)
Docker engine. Call the Dockerfile
.
FROM python:3.4
# Set PYTHONUNBUFFERED so output is displayed in the Docker log
# Helps out put logs in console
ENV PYTHONUNBUFFERED=1
# app (service) is exposed on port 8000
EXPOSE 8000
# here is the location of the django app itself
WORKDIR /usr/src/app
# Install dependencies
# takes req.txt and copies it into the Docker image
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
# Copy the rest of the application's code
# copy all the source code
COPY . /usr/src/app
# Run the app: run django migrations & runserver
# not good for production practices.
CMD ["./run_app.sh"]
Docker build -t nameApp # -t: tag Docker image with a name Container: chained images