Operations
Docker images
Generate optimized images, publish to registries, and scaffold Compose services.
Dockerize
phelix dockerize builds an optimized multi-stage Docker image for a Go or Rust app, then optionally pushes it to a registry and scaffolds a docker-compose.yml. Language is detected from go.mod (Go) or Cargo.toml (Rust); if both or neither are found, Phelix fails with a clear error.
phelix dockerize myapp --tag v1.0.0phelix dockerize myapp --tag v1.0.0 --push --registry ghcr.io/myuserphelix dockerize myapp --tag v1.0.0 --build-arg VERSION=1.0.0phelix dockerize myapp --tag v1.0.0 --with-compose --depends-on redis,postgresFlags
| Flag | Purpose |
|---|---|
| --tag | Version tag for the Docker image (e.g. v1.2.3, default latest) |
| --push | Push the image to the registry after building |
| --registry | Registry prefix (e.g. ghcr.io/user, docker.io/myorg, harbor.example.com/project) |
| -a, --build-arg | Extra build argument KEY=VALUE (repeatable; malformed entries are rejected with INVALID_ARGUMENT) |
| --with-compose | Generate a docker-compose.yml with the app service |
| --depends-on | Sidecar services for compose (redis, postgres, mysql, mongodb, rabbitmq) |
| --matrix + family | Matrix Docker builds: --go-versions/--rust-versions/--platforms, --multi-arch-tag (requires --push), --push-partial, --matrix-concurrency, --matrix-retries, --matrix-dry-run (see Matrix builds); a matrix: profile in phelix.yaml activates the Docker matrix too |
Generated images
Dockerfiles (generated when none exist) are multi-stage and optimized for Docker layer caching - dependency-heavy layers are cached separately from source code. The toolchain images are parameterized (ARG GO_VERSION=1.23 / ARG RUST_VERSION=1.80), so you can pin a different toolchain per build without editing the file:
phelix dockerize myapp --build-arg GO_VERSION=1.27- Cache dependencies firstGo starts FROM golang:${GO_VERSION}-alpine, copies go.mod/go.sum, and runs go mod download before source; Rust starts FROM rust:${RUST_VERSION}-slim, copies Cargo.toml/Cargo.lock, and compiles a dummy main.rs to cache all dependencies.
- Build the real binaryGo compiles the source into a fully static binary with CGO_ENABLED=0; Rust reuses cached deps and compiles only the app's own code.
- Minimal runtimeGo runs FROM scratch with just the binary - the smallest possible image. Rust runs debian:bookworm-slim with ca-certificates.
A .dockerignore is generated too (if none exists), excluding .git, .env files, build artifacts, logs, IDE configs, and Phelix internals. Build progress streams live to the terminal, and each image carries OCI metadata labels: org.opencontainers.image.version, .revision (git commit), and .created (build timestamp).
Each dockerize call records the image reference in versions.json - the same versioning system used by phelix rollback - so future rollback logic can support docker run <image> as a deploy source without redesigning the schema.
Publishing
phelix dockerize myapp --tag v1.0.0 --push --registry ghcr.io/myuserCredentials are stored using the same AES-256-GCM encrypted mechanism as environment variables. If not logged in to Docker, Phelix exits with a clear error telling you to run docker login first.
Compose
phelix dockerize myapp --tag v1.0.0 --with-compose --depends-on redis,postgresProduces a ready-to-use docker-compose.yml with the app's service plus requested sidecars - Redis on port 6379 using redis:7-alpine, PostgreSQL on 5432 using postgres:16-alpine. Supported sidecars: redis, postgres, mysql, mongodb, and rabbitmq.