Set Up the Environment
An Environment is one running copy of your App, such as production. Configure
its source, Services and variables before deploying. You can work through each
stage in the Web UI, use the CLI, or ask your agent to help.
The commands below create the Environment, connect its source and configure what it runs. Start with the Environment:
blossom environment:create -d '{"environment":{"name":"production","app_id":"app-100"}}'
Connect The Source
Short settings fit inline, like the command above. Longer ones read better as
a file: each init command writes a starter YAML file, you edit it, and
--data reads it. Write the source connection:
blossom git_repo:init
git_repo.yml:
git_repo:
environment_id: environment-100 # replace with your environment id
clone_url: https://github.com/blossom-examples/ruby-sinatra
branch: main
repository_type: public
Point it at your repository, then create it:
blossom git_repo:create --data git_repo.yml
Add subfolder: apps/web when the App is in a folder of a larger repository.
Private repositories use a connected Git provider
(blossom git_provider:list). Blossom builds with Buildpacks unless you pick
another build type, and stores the
images for you.
Add A Service
A Service is a process your App runs. Give it the command and port:
blossom service:init
service.yml:
service:
environment_id: environment-100 # replace with your environment id
name: web
command: bundle exec puma
port: 3000
publicly_exposed: true
desired_size: 1
# ... health check and size
blossom service:create --data service.yml
Add Variables
Put your App’s variables in .env.production, named after the Environment:
RACK_ENV=production
SESSION_SECRET=replace-with-a-long-random-string
MAILER_FROM=hello@example.com
Put # blossom:build before the block of variables needed during the build,
such as asset compilation. They remain available at runtime too. Start the
next block with # blossom:runtime to keep those variables runtime-only.
Each marker applies until the next marker, including across blank lines.
Preview the sync, then push. These commands show names and Build changes, never values:
blossom env_var:push --environment environment-100 --dry-run
blossom env_var:push --environment environment-100
Use --file /path/to/prod.env to select another file. See
build and runtime blocks
for examples and how variables before the first marker behave.
Keep the file out of git; add it to .gitignore. Linking a database later
adds its DATABASE_URL for you.
blossom environment:show --id environment-100 shows the Environment and, if
anything is still missing before it can deploy, what it is.
Next, add PostgreSQL before deploying.