Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 96 additions & 10 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Deployer Examples

This directory contains example configurations for Deployer, showcasing different use cases including basic execution, Docker containerization, and Ansible deployment.

## `golang/example`

To prepare Go example repository, run:
Expand All @@ -11,13 +13,36 @@ mkdir -p golang-example/.depl && cp golang-example.yaml golang-example/.depl/con
cd golang-example
```

Example config has 3 pipelines:
### Available Pipelines

Each pipeline includes Docker and Ansible support built-in:

- `hello` - Build and run hello
- `helloserver` - Build helloserver (port 8080 exposed in Docker)
- `outyet` - Build outyet (port 8080 exposed in Docker)

- `hello`
- `helloserver`
- `outyet`
### Usage Examples

Run each of them with `depl run`.
**Run locally:**
```bash
depl run hello
```

**Run in Docker/Podman container:**
```bash
depl run hello -d
```

**Deploy to remote hosts with Ansible:**
```bash
depl run hello -a
```

### Features
- Go module caching for faster Docker builds
- Port bindings for web servers (helloserver, outyet)
- Artifact extraction from containers
- Remote deployment support

## `tokio-rs/axum`

Expand All @@ -30,10 +55,71 @@ mkdir -p rust-axum-example/.depl && cp rust-axum-example.yaml rust-axum-example/
cd rust-axum-example
```

Example config has 3 pipelines:
### Available Pipelines

Each pipeline includes Docker and Ansible support built-in:

- `hello` - Build hello-world example
- `readme` - Build readme example
- `todos` - Build todos example

### Usage Examples

**Run locally:**
```bash
depl run hello
```

**Run in Docker/Podman container:**
```bash
depl run hello -d
```

**Deploy to remote hosts with Ansible:**
```bash
depl run hello -a
```

### Features
- Rust 1.85 base image for Docker builds
- Cargo dependency caching
- Port 3000 exposed for web servers
- Local storage cache support
- Remote deployment support

## Configuration Options Explained

All pipelines include both `containered_opts` and `ansible_opts`, allowing you to choose execution mode at runtime with CLI flags.

### Docker (containered_opts)

Activated with the `-d` flag. Key options demonstrated:

- `base_image`: Base Docker image for builds (golang:1.23, rust:1.85, etc.)
- `preflight_cmds`: Setup commands for the container environment
- `cache_strategies`: Multi-stage caching for dependencies
- `port_bindings`: Expose container ports to host
- `use_containerd_local_storage_cache`: Store cache locally
- `driver: shell`: Use shell driver for simpler execution

### Ansible (ansible_opts)

Activated with the `-a` flag. Key options demonstrated:

- `create_inventory`: Create inventory from Deployer's remote hosts
- `use_inventory`: Use existing Ansible inventory file
- `host_group`: Target specific host group from inventory
- `driver: shell`: Use shell driver (deployer driver requires Deployer on remote hosts)

**Before using Ansible:**
1. Add remote hosts: `depl new remote`
2. Update `ansible_opts.create_inventory` in the config with your host names
3. Ensure Deployer is installed on remote hosts at `~/.cargo/bin/` (for deployer driver)

- `hello`
- `readme`
- `todos`
## Tips

Run each of them with `depl run`.
1. **One pipeline, multiple modes**: Same pipeline name, just add `-d` for Docker or `-a` for Ansible
2. **Fresh builds**: Use `-f` flag to rebuild from scratch: `depl run hello -d -f`
3. **Podman users**: Set `DEPLOYER_CONTAINER_DEFAULT_EXECUTOR=podman` environment variable
4. **Custom executor**: Add `executor: podman` to `containered_opts` in config
5. **View generated files**: Docker builds generate Dockerfiles, Ansible creates playbooks - check your build directory
93 changes: 89 additions & 4 deletions examples/golang-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ignore_files:
- .git
cache_files:
- go.work
- go.sum
variables:
cd-hello:
value:
Expand Down Expand Up @@ -53,6 +54,8 @@ pipelines:
info: golang-example-hello@0.1.0
tags:
- golang
- docker
- ansible
actions:
- title: Build `./hello`
used: golang-build@0.1.0
Expand All @@ -64,23 +67,105 @@ pipelines:
- from: hello/hello
to: hello
exclusive_exec_tag: hello
driver: shell
# Docker/Podman configuration - use with: depl run hello -d
containered_opts:
base_image: golang:1.23
preflight_cmds:
- RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
cache_strategies:
- copy_cmds:
- COPY go.mod go.sum ./
pre_cache_cmds:
- RUN go mod download
- copy_cmds:
- COPY hello/ hello/
pre_cache_cmds:
- DEPL
use_containerd_local_storage_cache: true
prevent_metadata_loading: false
# Ansible configuration - use with: depl run hello -a
ansible_opts:
# Option 1: Create inventory from Deployer's remote hosts
# create_inventory:
# - production-server-1
# Option 2: Use existing Ansible inventory
# use_inventory: ./ansible-inventory.ini
# host_group: webservers
# For demo purposes, using localhost
create_inventory:
- localhost
- title: helloserver
info: golang-example-helloserver@0.1.0
tags:
- golang
- docker
- ansible
actions:
- title: Run `./helloserver`
used: golang-run@0.1.0
- title: Build `./helloserver`
used: golang-build@0.1.0
with:
"{cd-folder && }": cd-helloserver
artifacts:
- from: helloserver/helloserver
to: helloserver
exclusive_exec_tag: helloserver
driver: shell
containered_opts:
base_image: golang:1.23
preflight_cmds:
- RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
port_bindings:
- from: 8080
to: 8080
cache_strategies:
- copy_cmds:
- COPY go.mod go.sum ./
pre_cache_cmds:
- RUN go mod download
- copy_cmds:
- COPY helloserver/ helloserver/
pre_cache_cmds:
- DEPL
use_containerd_local_storage_cache: true
prevent_metadata_loading: false
ansible_opts:
create_inventory:
- localhost
- title: outyet
info: golang-example-outyet@0.1.0
tags:
- golang
- docker
- ansible
actions:
- title: Run `./outyet`
used: golang-run@0.1.0
- title: Build `./outyet`
used: golang-build@0.1.0
with:
"{cd-folder && }": cd-outyet
artifacts:
- from: outyet/outyet
to: outyet
exclusive_exec_tag: outyet
driver: shell
containered_opts:
base_image: golang:1.23
preflight_cmds:
- RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
port_bindings:
- from: 8080
to: 8080
cache_strategies:
- copy_cmds:
- COPY go.mod go.sum ./
pre_cache_cmds:
- RUN go mod download
- copy_cmds:
- COPY outyet/ outyet/
pre_cache_cmds:
- DEPL
use_containerd_local_storage_cache: true
prevent_metadata_loading: false
ansible_opts:
create_inventory:
- localhost
Loading
Loading