I'm trying to figure out the best way to work with Docker containers in my dev environment, but deploy versioned images of my app to Kubernetes. Here's what I have so far:
I'm using the following Docker image as a base - https://github.com/shufo/docker-phoenix. When I create a container for my dev environment (following the instructions) I run:
docker run -d -p 4000:4000 -v $(pwd):/app -w /app shufo/phoenix
As far as I understand, for Kubernetes, my app needs to be contained in a versioned image. In other words, the code needs to be in the container that's generated, rather than being passed up to the container in a volume?
So I have a Dockerfile that looks like this:
FROM shufo/phoenix
MAINTAINER Hamish Murphy <hamishmurphy@gmail.com>
COPY . /app
WORKDIR /app
After building the image (with a version number), I can use this to create a Deployment in Kubernetes.
So this is a home baked solution. Is there a common pattern for this?
In my opinion you are on the right track. Including the code in the image is probably considered best practice. I have recently written an answer to another question describing some of the benefits.
In practice people are using all kinds of ways to serve the application to a container. It is possible to use attached volumes or have a Git in the container pull/update the code when deployed but I believe you would need some good reason (that I can't think of) for that being preferable.