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. The language is detected automatically 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.0
phelix dockerize myapp --tag v1.0.0 --push --registry ghcr.io/myuser
phelix dockerize myapp --tag v1.0.0 --build-arg VERSION=1.0.0
phelix dockerize myapp --tag v1.0.0 --with-compose --depends-on redis,postgres

Flags

FlagPurpose
--tagImage version tag, 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
--build-arg, -aRepeatable KEY=value argument
--with-composeGenerate docker-compose.yml with the app service
--depends-onAdd supported sidecars (redis, postgres, mysql, mongodb, rabbitmq)
--matrix + familyMatrix Docker builds

Generated images

Phelix auto-detects the language from go.mod or Cargo.toml and generates multi-stage Dockerfiles optimized for layer caching — dependency-heavy layers are cached separately from source code, so rebuilds reuse them and only recompile what changed.

  1. 1
    Cache dependencies first
    Go copies go.mod/go.sum and runs go mod download before source; Rust copies Cargo.toml and Cargo.lock and compiles a dummy main.rs to cache all dependencies.
  2. 2
    Build the real binary
    Go compiles the source into a fully static binary with CGO_ENABLED=0; Rust reuses the cached deps and compiles only the app's own code.
  3. 3
    Minimal runtime
    Go runs from scratch with just the binary — the smallest possible image. Rust runs on debian:bookworm-slim with ca-certificates.

A .dockerignore is also generated (if none exists) to exclude git metadata, .env files, build artifacts, logs, IDE configs, and Phelix internals from the build context.

Docker's build progress streams live to the terminal, and each image carries OCI metadata labels: org.opencontainers.image.version (the --tag), .revision (the git commit, when available), and .created (the build timestamp).

The image reference is recorded 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

--push pushes the image to the registry given by --registry. Registry credentials are stored with the same AES-256-GCM encrypted mechanism as environment variables and are never logged in plaintext. If you are not already authenticated, Phelix exits with a clear error telling you to run docker login first — Docker's own registry authentication is used.

Compose

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

--with-compose produces a ready-to-use docker-compose.yml with the app service plus the requested sidecars. Supported sidecars: redis, postgres, mysql, mongodb, and rabbitmq. For example, Redis binds port 6379 using redis:7-alpine, and PostgreSQL binds 5432 using postgres:16-alpine.