No configuration file in your repository. Qovery does not read a
qovery.yml, .qovery.yml or .qovery.toml, and there is no qovery init. Projects, environments and services are created in the Console, with qovery api, or with Terraform. For the full path from a repository to a running app with commands only, see Deploy with the CLI and API.Prerequisites
- A Rails 7.1 or later application in a GitHub, GitLab or Bitbucket repository, using the
pggem. - A Qovery account and a cluster: create one in your cloud account, connect your own cluster, or try it on your laptop.
- The
RAILS_MASTER_KEYof the application (the content ofconfig/master.key).
Add a production Dockerfile
rails new generates a production Dockerfile since Rails 7.1. You can keep it (see the port note), or use this shorter one at the root of the repository:
Dockerfile
ruby:3.4-slimis the official Ruby image without build tools. Match the version to your.ruby-version. It installslibpq5, the PostgreSQL client library that thepggem loads at runtime.- The
buildstage has the compilers and headers that native gems such aspgneed. The final stage copies only the installed gems and the application, so the image stays small. BUNDLE_WITHOUT=development:testleaves out the gems you do not need in production.SECRET_KEY_BASE_DUMMY=1letsassets:precompilerun at build time without the real secret.- The container runs as a non-root user that owns
db,log,storageandtmp, the folders Rails writes to. - Puma binds to
0.0.0.0, notlocalhost, so Kubernetes can reach it.
Port and health check
The application listens on port3000. Rails 7.1 and later add a GET /up route that answers 200 when the application boots, so use it as the health check path.
The Dockerfile that Rails 8 generates starts Puma behind Thruster on port 80. If you keep it, set the port to 80 in Qovery instead of 3000.
If you set config.hosts in config/environments/production.rb, exclude the health check from host authorization, because Kubernetes probes call the pod by its IP address:
config/environments/production.rb
Connect PostgreSQL
The application and the migration job read the connection string fromDATABASE_URL. Create PostgreSQL, then expose its connection string under that name at the environment scope, so every service of the environment gets it.
- Qovery database (development)
- Blueprint (production)
- In the environment, click New Service and pick PostgreSQL. Keep the visibility private, then create and deploy it. See Create a Database.
- Open the Variables section of the environment, find the built-in variable
QOVERY_POSTGRESQL_Z<ID>_DATABASE_URL_INTERNAL, select Create alias, and name itDATABASE_URL.
DATABASE_URL and merges it into the production entry of config/database.yml. If that entry also declares cache, queue and cable databases (the Rails 8 default for Solid Cache, Solid Queue and Solid Cable), give each one a database it can reach on the same server, or remove the ones you do not use.
Set the variables
Run the migrations
Rundb:migrate in a lifecycle job built from the same repository and Dockerfile, triggered on the Deploy event, with these CMD arguments:
DATABASE_URL and RAILS_MASTER_KEY too: create them at the environment scope.
The Dockerfile that Rails generates also runs db:prepare in bin/docker-entrypoint when the server starts. This works for a single instance. With several instances, each one runs it at boot, so prefer the job.
Deploy
- Console
- With a coding agent
1
Create a project and an environment
Follow steps 1 and 2 of Deploy Your First Application. Pick the cluster the environment runs on.
2
Add PostgreSQL
Create the database and the
DATABASE_URL variable as described in Connect PostgreSQL.3
Create the application
In the environment, click New Service › Create application, select Git Repository, then your repository and branch. Leave Root Application Path empty unless the Dockerfile is in a subfolder.
4
Set the port
Add port
3000 with the protocol HTTP, and turn on Publicly Accessible. Qovery serves it over HTTPS on port 443.5
Set the health checks
Set the readiness and liveness probes to type HTTP, path
/up, port 3000. See Service Health Checks.6
Add the variables
Click Create, without deploying yet. Then open the Variables section of the environment and add the other variables listed in Set the variables at the environment scope, so the migration job gets them too.
DATABASE_URL already exists from the previous step. Mark keys and passwords as secrets.7
Create the migration job
Click New Service › Create lifecycle job, select the same repository, branch and Dockerfile, and trigger it on the Deploy event (
START) with the CMD arguments ["./bin/rails", "db:migrate"]. Set the number of restarts to 0. See Run the migrations.8
Deploy
Deploy the environment. Qovery deploys the database, then the job, then the application, builds the image from your Dockerfile and gives the application a URL on
qovery.io. Follow the progress in the Deployment logs tab.Troubleshooting
The CLI commands below use the organization and project selected withqovery context set. Run it first, or add --organization and --project to each command.
Deployment fails on the health check
Deployment fails on the health check
The port in Qovery does not match the server:
3000 for Puma, 80 with Thruster in the Rails 8 Dockerfile. Check that Puma binds to 0.0.0.0. Read the error lines with qovery environment deployment logs --environment "<env>" --service "<app>" --errors-only.Blocked hosts error or 403
Blocked hosts error or 403
config.hosts does not include the domain. Set APP_HOST to the qovery.io domain shown in the Console, add your custom domains, and keep /up excluded from host authorization.Missing secret_key_base or ActiveSupport::MessageEncryptor::InvalidMessage
Missing secret_key_base or ActiveSupport::MessageEncryptor::InvalidMessage
RAILS_MASTER_KEY is missing or does not match config/credentials.yml.enc. Set it as a secret at the environment scope, so the application and the migration job both get it.PendingMigrationError or missing tables
PendingMigrationError or missing tables
The migrations did not run against this database. Check that the job and the application read the same
DATABASE_URL, and read the job output with qovery log --job "<job name>".Assets return 404
Assets return 404
assets:precompile did not run at build time, or config.public_file_server.enabled is false in production. Rails 7.1 and later serve public/ by default; an application generated with an older version may still read RAILS_SERVE_STATIC_FILES in config/environments/production.rb, so set that variable to 1 or remove the condition. Check the build logs for the precompile step.Next steps
Preview environments
Get a full copy of the environment for each pull request
Cron jobs
Run rake tasks on a schedule
Auto deploy
Deploy on every push to the branch
Other frameworks
All framework guides