Skip to main content

Populating fields

DevX has some helpers to populate fields from environmental variables, files, or auto-generate values.

Config

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
}
}
}
}
}

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: []