Skip to content

Command Palette

Search for a command to run...

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.

Terminal
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,postgres

Flags

FlagPurpose
--tagVersion tag for the Docker image (e.g. v1.2.3, default latest)
--pushPush the image to the registry after building
--registryRegistry prefix (e.g. ghcr.io/user, docker.io/myorg, harbor.example.com/project)
-a, --build-argExtra build argument KEY=VALUE (repeatable; malformed entries are rejected with INVALID_ARGUMENT)
--with-composeGenerate a docker-compose.yml with the app service
--depends-onSidecar services for compose (redis, postgres, mysql, mongodb, rabbitmq)
--matrix + familyMatrix 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:

Terminal
phelix dockerize myapp --build-arg GO_VERSION=1.27
  1. Cache dependencies first
    Go 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.
  2. Build the real binary
    Go compiles the source into a fully static binary with CGO_ENABLED=0; Rust reuses cached deps and compiles only the app's own code.
  3. Minimal runtime
    Go 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

Terminal
phelix dockerize myapp --tag v1.0.0 --push --registry ghcr.io/myuser

Credentials 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

Terminal
phelix dockerize myapp --tag v1.0.0 --with-compose --depends-on redis,postgres

Produces 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.