Install devx
Option 1: Homebrew
brew tap stakpak/stakpak
brew install devx
Option 2: Binary
Init the project
mkdir myapp
cd myapp
devx project init
Update project dependencies
devx project update
Generate example
devx project gen
This will generate a sample DevX stack and builder. You create a stack to define your workload and what it needs to run.
stack.cue
package main
import (
"stakpak.dev/devx/v1"
"stakpak.dev/devx/v1/traits"
)
stack: v1.#Stack & {
components: {
cowsay: {
traits.#Workload
containers: default: {
image: "docker/whalesay"
command: ["cowsay"]
args: ["Hello DevX!"]
}
}
}
}
You create a builder for the dev
environment to tell DevX how to generate configurations. This step will usually be performed by platform teams or developers wishing to extend the platform.
builder.cue
package main
import (
"stakpak.dev/devx/v2alpha1"
"stakpak.dev/devx/v2alpha1/environments"
)
builders: v2alpha1.#Environments & {
dev: environments.#Compose
}
Build configurations for the dev environment
devx build dev
🏗️ Loading stack...
👀 Validating stack...
🏭 Transforming stack 100% |████████████████████████| (1/1, 711 it/s)
[compose] applied resources to "docker-compose.yml"
docker-compose.yml
version: "3"
volumes: {}
services:
cowsay:
image: docker/whalesay
environment: {}
depends_on: []
command:
- cowsay
- Hello DevX!
restart: always
volumes: []
No we run the compose file
docker-compose up
[+] Running 1/0
⠿ Container compose-cowsay-1 Created 0.0s
Attaching to compose-cowsay-1
compose-cowsay-1 | _____________
compose-cowsay-1 | < Hello DevX! >
compose-cowsay-1 | -------------
compose-cowsay-1 | \
compose-cowsay-1 | \
compose-cowsay-1 | \
compose-cowsay-1 | ## .
compose-cowsay-1 | ## ## ## ==
compose-cowsay-1 | ## ## ## ## ===
compose-cowsay-1 | /""""""""""""""""___/ ===
compose-cowsay-1 | ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
compose-cowsay-1 | \______ o __/
compose-cowsay-1 | \ \ __/
compose-cowsay-1 | \____\______/
compose-cowsay-1 exited with code 0