A docker image to help deploy applications to a dokku server
1M+
A Docker image meant for use with CI/CD pipelines
Assuming a Docker image can be run as a CI task with environment variables injected, the following CI systems will have their variables automatically detected:
This image provides two binaries for external usage:
dokku-deploy: Triggers an app deploy at the configured GIT_REMOTE_URLdokku-unlock: Unlocks deploys for an app at the configured GIT_REMOTE_URLTo run either binary, the following docker command can be used from a
directory containing a non-shallow clone of the repository being deployed:
# where the `.env` file contains `GIT_REMOTE_URL` and `SSH_PRIVATE_KEY`
# deploy
docker run --rm -v="$PWD:/app" --env-file=.env dokku/ci-docker-image dokku-deploy
# unlock
docker run --rm -v="$PWD:/app" --env-file=.env dokku/ci-docker-image dokku-unlock
The following environment variables are supported:
BRANCH:
CI_BRANCH_NAME
CI_COMMIT
COMMAND:
DEPLOY_DOCKER_IMAGE:
git:from-imageDEPLOY_USER_NAME:
DEPLOY_USER_EMAIL:
GIT_REMOTE_URL:
GIT_PUSH_FLAGS:
REVIEW_APP_NAME:
SSH_HOST_KEY:
ssh-keyscan -t rsa $HOSTSSH_PRIVATE_KEY:
SSH_PRIVATE_KEY_BASE64.SSH_PRIVATE_KEY_BASE64:
SSH_PASSPHRASE:
TRACE:
GIT_REMOTE_URL SSH FormatThe GIT_REMOTE_URL value should be specified in SSH Format, as shown below:
# without port specified
ssh://[email protected]/node-js-app
# with the optional port specified
ssh://[email protected]:22/node-js-app
# generalized form
ssh://dokku@HOSTNAME:PORT/APP_NAME
This format mimics the DSN format. It is similar to the one in use by a normal git push dokku main command, though with a change on how the app name is separated by a slash from the rest of the hostname. The port is completely optional, but allows users to rebind the SSH server to another port as necessary.
Important
The SSH key _must_ be added to the dokku user via the `dokku ssh-keys:add` command and _not_ manually or the app name will not be properly detected.
This image allows a variety of file-based hooks to be triggered during the app
deploy process. These hooks should be executables relative to the current working
directory in which dokku-deploy script is executed - typically your repository root.
The following environment variables are available for usage in the script:
APP_NAME: The name of the remote app that will be deployed. This takes
the parsed GIT_REMOTE_URL and REVIEW_APP_NAME into account.IS_REVIEW_APP: true if a review app is being deployed, false otherwise.SSH_REMOTE: The parsed ssh remote url.The simplest hook is a shell script like so:
#!/bin/sh -l
echo "hello world"
Note
The Docker image in use by this repository currently only supports `sh` as the interpreter. If another interpreter is desired, it should be added to the environment manually.
To execute remote dokku commands, the ssh binary can be executed like so:
#!/bin/sh -l
ssh "$SSH_REMOTE" -- version
Additionally, if a Dokku command should be executed only for review apps,
the IS_REVIEW_APP variable can be checked for the value true to wrap
review app-specific logic:
#!/bin/sh -l
if [ "$IS_REVIEW_APP" = "true" ]; then
ssh "$SSH_REMOTE" -- config:set "$APP_NAME" "DOMAIN=$APP_NAME.dokku.me"
echo "configured the review app domain"
fi
The following hooks are available:
bin/ci-pre-deploy: Triggered after any app setup but before the app is deployedbin/ci-post-deploy: Triggered after the app is deployedbin/ci-pre-review-app-destroy: Triggered before a review app is destroyedbin/ci-post-review-app-destroy: Triggered after a review app is destroyeddocker build dokku/ci-docker-image .
Content type
Image
Digest
sha256:25141d21c…
Size
26.8 MB
Last updated
4 months ago
docker pull dokku/ci-docker-image