Populating fields
DevX has some helpers to populate fields from environmental variables, files, or auto-generate values.
Config
- stack.cue
- builder.cue
- VERSION
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!"]
env: {
ENV: string @guku(env=ENV) // environment variable ENV=dev
VERSION: string @guku(file="VERSION") // VERSION file
ENV_GEN: string @guku(generate) // autogenerated value
}
}
}
}
}
package main
import (
"stakpak.dev/devx/v2alpha1"
"stakpak.dev/devx/v2alpha1/environments"
)
builders: v2alpha1.#Environments & {
dev: environments.#Compose
}
v0.2.0
Build
ENV=dev devx build dev
Result
docker-compose.yml
version: "3"
volumes: {}
services:
cowsay:
image: docker/whalesay
environment:
ENV: dev
VERSION: v0.2.0
ENV_GEN: dummy
depends_on: []
command:
- cowsay
- Hello DevX!
restart: always
volumes: []