Skip to Content
Deployment

Deployment

Deploy with CLI (Local)

You can deploy directly from your local machine using the dockflow deploy command:

# Deploy to production with version 1.0.0 dockflow deploy production 1.0.0 # Deploy to staging (auto-generated version) dockflow deploy staging # Deploy to production with specific hostname dockflow deploy production 2.0.0 --hostname server1

Using Docker Image

If you prefer using the Docker image instead of installing the CLI:

# Deploy to production with version 1.0.0 docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v .:/project shawiizz/dockflow-cli:latest deploy production 1.0.0 # Deploy to staging docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v .:/project shawiizz/dockflow-cli:latest deploy staging

Note: The Docker socket mount is required for the deploy command. It enables Docker-in-Docker, allowing the CLI to build Docker images locally before transferring them to your server.

Prerequisites

Install Dockflow CLI

curl -fsSL "https://raw.githubusercontent.com/Shawiizz/dockflow/main/cli/cli_wrapper.sh?$(date +%s)" | bash

Create .env.dockflow file

Create this file in your project root:

# Production connection string (from setup-machine output) PRODUCTION_CONNECTION=eyJob3N0Ijoi... # Staging connection string (optional) STAGING_CONNECTION=eyJob3N0Ijoi... # Skip Docker installation on target (optional) SKIP_DOCKER_INSTALL=true

āš ļø Important: Add .env.dockflow to your .gitignore to avoid exposing secrets.

Initialize project structure

If not already done:

dockflow init

Deploy with Git Tags

# Production deployment git tag 1.0.0 git push origin --tags # Staging deployment git tag 1.0.0-staging git push origin --tags # Custom environment git tag 1.0.0-whatever git push origin --tags

Deploy on Branch Push

Before using, you need to configure your Github/GitLab workflow. You can also trigger deployments on direct branch pushes (deploys to production):

git push origin main

What Happens During Deployment

  1. Build - Docker images are built (locally or remotely)
  2. Transfer - Images/code sent to target servers
  3. Deploy - Ansible orchestrates the deployment
  4. Done - Your app is live!

CI/CD Jobs Available:

  • build - Validates Docker builds on every push
  • deploy - Deploys when you push a tag