---
title: How to Deploy OpenAI Codex CLI Projects on Vultr Using Dokploy
url: https://docs.vultr.com/how-to-deploy-openai-codex-cli-projects-on-vultr-using-dokploy
description: Build app with Codex CLI, push to GitHub, and deploy on Dokploy with HTTPS.
publish_date: 2026-04-02T16:44:10.124415Z
last_updated: 2026-04-16T00:00:00.077250Z
author: Martin Sustak
header_image: https://lhr1.vultrobjects.com/docs-main-doc-assets-1/2533/720def0c-ff8d-4a97-8d3f-55194ffbec8d.png
---

> Index of every Vultr Docs page in markdown: https://docs.vultr.com/llms.txt

[OpenAI Codex CLI](https://openai.com/index/codex/) is an AI developer terminal tool for creating full-stack production-ready applications. [Dokploy](https://dokploy.com/) is an open-source platform-as-a-service that automates infrastructure provisioning and Docker orchestration for self-hosted environments.

This guide explains how to install the Codex CLI, create a full-stack application, and deploy it on Vultr using Dokploy.

## Prerequisites

* Have an active [OpenAI account](https://openai.com/), or an [API key](https://platform.openai.com/api-keys) from the OpenAI developer platform.
* [Install Node.js](https://nodejs.org/en/download) on your local machine.
* Have access to an [Ubuntu 24.04 server](https://www.vultr.com/servers/ubuntu/) as a [non-root user with sudo privileges](https://docs.vultr.com/how-to-create-a-sudo-user-in-linux).
* [Install Dokploy and create your administrator account](https://docs.vultr.com/how-to-deploy-dokploy-self-hosted-paas-for-docker-applications).
* Set up a domain name, such as `app.example.com`, and point it to your server's public IP address using an [A record](https://docs.vultr.com/products/network/dns/management/manage-records).

## Set Up Codex CLI

Install the Codex CLI and authenticate with your OpenAI account to prepare the development environment.

1. Install the Codex CLI globally using npm.

    ```console
    $ npm install -g @openai/codex
    ```

1. Authenticate the CLI. If you have a ChatGPT subscription, run the following command and complete the browser login flow.

    ```console
    $ codex login
    ```

1. If you use an API key instead, set it as an environment variable. Replace `YOUR_API_KEY` with the key from your OpenAI dashboard.

    ```console
    $ export OPENAI_API_KEY=YOUR_API_KEY
    ```

1. Create a new project directory.

    ```console
    $ mkdir codex-app
    ```

1. Navigate into the directory.

    ```console
    $ cd codex-app
    ```

1. Launch the Codex CLI.

    ```console
    $ codex
    ```

## Create an Application Using AI

Prompt the Codex agent to generate the project files and container configuration.

1. In the prompt field, describe your application and instruct the agent to make it compatible with Dokploy. Include all required features and the desired service stack. Request a `docker-compose.yml` if the application involves multiple services.
1. Wait for the Codex agent to generate the application files.
1. Optionally, test the application on your local machine using the generated Docker configuration. The generated `README.md` file contains local setup instructions.
1. Press :key_ctrl: + :key_c: to exit Codex.
1. Create a new empty repository on [GitHub](https://github.com/new).
1. Initialize the local Git repository.

    ```console
    $ git init
    ```

1. Stage the generated files for commit.

    ```console
    $ git add .
    ```

1. Commit the files to the local repository.

    ```console
    $ git commit -m "Initial commit"
    ```

1. Set the default branch to main.

    ```console
    $ git branch -M main
    ```

1. Add your GitHub repository as a remote. Replace `YOUR_REPOSITORY_URL` with your repository's URL.

    ```console
    $ git remote add origin YOUR_REPOSITORY_URL
    ```

1. Push the source code to GitHub.

    ```console
    $ git push -u origin main
    ```

## Connect GitHub Repository

Connect your GitHub account with Dokploy to grant it access to pull code from your repositories.

1. Navigate to your instance's IP address on port `3000`, for example `192.0.2.1:3000`, in a web browser to open the Dokploy dashboard.
1. Log in to the administrator account.
1. Select **Git** under **Settings** in the left sidebar.
1. Click **GitHub**, then click **Create GitHub App**.
1. Follow the GitHub OAuth prompts to authorize the app and select the repositories Dokploy can access.

## Create a New Project

Projects in Dokploy isolate different application environments.

1. Click **Projects** in the left sidebar.
1. Click **Create Project**, enter a project name, and click **Create**.
1. Click on the newly created project to open it.

## Connect the Code Repository

Deploy the application by specifying the source repository and creating a new Docker Compose service.

1. On your project page, click **Create Service** and select **Compose**.
1. Enter a name for your service and click **Create**.
1. Open your new Compose service.
1. Locate the **Github** configuration section.
1. Select your GitHub account and repository.
1. Set the correct **Branch**.
1. Click **Save** to apply the repository settings.
1. Open the `docker-compose.yml` file in your local repository and make the following two adjustments to the web service before deploying:

    * Remove any `ports:` mappings. Dokploy routes traffic through Traefik, so the web service does not need to bind a port on the host.
    * Add `dokploy-network` to the service's networks so Traefik can reach the container:

    ```yaml
    services:
      web:
        networks:
          - default
          - dokploy-network

    networks:
      dokploy-network:
        external: true
    ```

    Replace `web` with the actual service name from your compose file.

1. Commit and push the changes to your repository.

## Start the Deployment

Dokploy fetches the source code and builds the Docker containers when you trigger a deployment. If your application requires environment variables such as API keys or database credentials, set them under the **Environment** tab before deploying.

1. Switch to the **General** settings tab.
1. Click **Deploy**, then click **Confirm**.
1. Click **View** to monitor the real-time deployment logs.

## Verify Deployment

Connect your domain for a production-ready URL and encrypted traffic. Dokploy provisions a Let's Encrypt SSL certificate through Traefik when you enable HTTPS.

1. Navigate to the **Domains** tab and click **Add Domain**.
1. Select the name of your web service container in the **Service Name** field, for example `web`.
1. Type your custom domain into the **Host** field.
1. Enable the **HTTPS** toggle.
1. Select **Let's Encrypt** from the **Certificate Provider** dropdown.
1. Click **Create**.
1. Click **Validate DNS** to verify your domain's DNS configuration.

## Add a Database

Dokploy supports deploying managed database containers within the same project. The internal connection URL connects the database directly to your application over Docker's internal network without exposing it to the internet.

1. Navigate to your project page.
1. Click **Create Service** and select **Database**.
1. Select the database type that matches your application's requirements.
1. Enter a name for the database and click **Create**.
1. Open the database service page and click **Deploy**.
1. Copy the **Internal Connection URL**.
1. Go to the **Environment** tab in your application's configuration page.
1. Create or update the `DATABASE_URL` variable and paste the copied connection URL as the value.
1. Click **Save**.

## Conclusion

You have successfully created a full-stack application using Codex CLI, pushed the source code to GitHub, and deployed it on Vultr using Dokploy. The application now serves traffic over a custom domain secured with a Let's Encrypt TLS certificate. For more information and advanced configuration options, refer to the [official Dokploy documentation](https://docs.dokploy.com/docs/core).
