MEMOS

Dokku

Deployments

Deploy docker image

####On dokku host

# Fetch/update docker image from docker-hub and retag to match dokku app name
docker pull vendor/image
docker tag vendor/image:latest dokku/app-name:version
# Or build it
docker build -t dokku/app-name:version .

# Create a tag for the previous version if needed
dokku tags:create app-name previous

# Deploy tag
dokku tags:deploy app-name version

####Or from dokku client

# Either pull from docker-hub and retag to match dokku app name
docker pull vendor/image
docker tag vendor/image:latest dokku/app-name:version
# Or build it
docker build -t dokku/app-name:version .

# copy the image to the dokku host
# docker save: image to tar or stream to stdout
# docker load: tar to image or load from stdin
docker save dokku/app-name:version | bzip2 | ssh dokku.host "bunzip2 | docker load"

# tag and deploy the image
ssh dokku.host "dokku tags:create app-name previous; dokku tags:deploy app-name version"

Not yet possible in dokku1, so we have to directly use docker.

# Create network if it does not exists
NETWORK_NAME='common-network'
NETWORK=$(docker network ls -q -f name="$NETWORK_NAME")
[[ -z "$NETWORK" ]] && docker network create "$NETWORK_NAME"

# Connect to the common-network
docker network connect "$NETWORK_NAME" container1-name
docker network connect "$NETWORK_NAME" container2-name

container1-name and container2-name are now sharing a common common-network. We can now use the names of the containers that we want to refer to, in order to resolve their IP addresses.

After each deploy of an app, a new container is created, we then have to reattach the created container to the network. Using Dokku-post-deploy-script we can automate the process. Just create a POST_DEPLOY_SCRIPT file at the root of the application with the snippet above. It will be executed after a deploy so that the container can be reattached to the network

Plugins


  1. Github issue regarding its integration into dokku. [return]