Fly.ioTutorial
Powerbuilding with Fly
Summary
Powerbuilding with Fly explains how flyctl controls Docker-image builds when deploying applications to Fly infrastructure. It covers selecting the application configuration with --config, choosing an alternate Dockerfile with --dockerfile, and passing build-time values through --build-args. Using NGINX_PORT as an example, the post shows how Docker ARG can receive a default or command-line value and how ENV=${NGINX_PORT} carries that value into the running image; flyctl deploy --build-args NGINX_PORT=4000 overrides 8080. Build arguments are intended for non-sensitive data because values are baked into the image and may be retrievable, while Fly Secrets are recommended for sensitive application data and are injected as environment variables when the image starts.
Context
Fly deployments use Docker images, and flyctl identifies build instructions from a Dockerfile or creates a builder VM. Projects may need different configuration files or Dockerfiles when building multiple applications from one directory.
Approach / What changed
Use --config and --dockerfile to select build inputs, then use --build-args to pass name/value pairs into Docker builds. A Docker ARG can feed an ENV variable for runtime use; sensitive values should instead use Fly Secrets.
Takeaways
flyctl assumes fly.toml in the current directory, while --config selects another configuration file and --dockerfile selects an alternate Dockerfile when building without a builder.
The pattern ARG NGINX_PORT=8080 followed by ENV NGINX_PORT=${NGINX_PORT} lets a build argument become a runtime environment variable; --build-args NGINX_PORT=4000 overrides the default.
Build arguments are unsuitable for credentials because their values are baked into the image and may be retrievable; Fly Secrets are injected when the image starts.
Source and freshness
- Source
- fly.io
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.