net/http, with a PostgreSQL database and migrations that run before each release. Qovery builds the image from your Dockerfile and runs it on a Kubernetes cluster in your own cloud account.
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 Go module in a GitHub, GitLab or Bitbucket repository, with a
go.modand ago.sum. - A Qovery account and a cluster: create one in your cloud account, connect your own cluster, or try it on your laptop.
- These modules in
go.mod:github.com/jackc/pgx/v5andgithub.com/golang-migrate/migrate/v4.
Prepare the server
Listen on the port fromPORT, answer a health check, read the database URL from the environment, and add a migrate subcommand that applies the migrations embedded in the binary:
main.go
":"+port listens on all interfaces, so Kubernetes can reach the server. Put the migrations in a migrations folder next to main.go, in the golang-migrate file format, for example 000001_create_items.up.sql and 000001_create_items.down.sql. //go:embed compiles them into the binary, so the image needs no other file.
Add a production Dockerfile
Create aDockerfile at the root of the repository:
Dockerfile
- The first stage compiles with the official
golang:1.27-alpineimage. Match the Go version to thegoline of yourgo.mod. - Copying
go.modandgo.sumbefore the code keeps the downloaded modules cached when only the code changes. CGO_ENABLED=0builds a static binary, which runs without a C library.-trimpathand-ldflags="-s -w"remove local paths and debug symbols.- The final image,
gcr.io/distroless/static-debian13:nonroot, holds only the binary, CA certificates and time zone data, with no shell. It runs as a non-root user. CMD ["/server"]starts the binary directly, so it receives the stop signal.
.dockerignore with at least .git to keep the build context small.
Port and health check
The application listens on port8080 and answers GET /healthz with 200. Use both values when you create the application in Qovery.
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.
postgresql:// URL as is. The migrate subcommand only swaps its scheme for pgx5://, the name the golang-migrate pgx driver registers.
Set the variables
Add the other variables your application reads, and mark keys and passwords as secrets.
Run the migrations
Run themigrate subcommand in a lifecycle job built from the same repository and Dockerfile, triggered on the Deploy event, with these CMD arguments:
schema_migrations table, so a run with nothing new exits successfully.
Running the migrations at server startup instead works for a single instance, but every instance then runs them at boot, and a failed migration leaves the application crashing in a loop.
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
8080 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
/healthz, port 8080. 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 ["/server", "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, project and environment selected withqovery context set. Run it first, or add --organization, --project and --environment to each command.
Deployment fails on the health check
Deployment fails on the health check
The server listens on another port than the one set in Qovery, or on
127.0.0.1. Listen on ":"+port and check that the port in Qovery is 8080. Read the error lines with qovery environment deployment logs --environment "<env>" --service "<app>" --errors-only.no such file or directory at startup
no such file or directory at startup
The binary was built with cgo, so it needs a C library that the distroless
static image does not have. Keep CGO_ENABLED=0. If a dependency needs cgo, use gcr.io/distroless/base-debian13:nonroot as the final image instead.relation does not exist
relation does not exist
The migrations did not run against this database. Check that the job and the application read the same
DATABASE_URL at the environment scope, and read the job output with qovery log --job "<job name>".Dirty database version
Dirty database version
A migration failed halfway, and golang-migrate refuses to run until the version is fixed. Correct the migration, then set the version back with the migrate CLI
force command against the database, and redeploy.Next steps
Preview environments
Get a full copy of the environment for each pull request
Autoscaling
Set the number of instances and the resources
Auto deploy
Deploy on every push to the branch
Other frameworks
All framework guides