
OpenAI Codex CLI is an AI developer terminal tool for creating full-stack production-ready applications. Dokploy 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.
app.example.com, and point it to your server's public IP address using an A record.Install the Codex CLI and authenticate with your OpenAI account to prepare the development environment.
Install the Codex CLI globally using npm.
Authenticate the CLI. If you have a ChatGPT subscription, run the following command and complete the browser login flow.
If you use an API key instead, set it as an environment variable. Replace YOUR_API_KEY with the key from your OpenAI dashboard.
Create a new project directory.
Navigate into the directory.
Launch the Codex CLI.
Prompt the Codex agent to generate the project files and container configuration.
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.
Wait for the Codex agent to generate the application files.
Optionally, test the application on your local machine using the generated Docker configuration. The generated README.md file contains local setup instructions.
Press Ctrl + C to exit Codex.
Create a new empty repository on GitHub.
Initialize the local Git repository.
Stage the generated files for commit.
Commit the files to the local repository.
Set the default branch to main.
Add your GitHub repository as a remote. Replace YOUR_REPOSITORY_URL with your repository's URL.
Push the source code to GitHub.
Connect your GitHub account with Dokploy to grant it access to pull code from your repositories.
3000, for example 192.0.2.1:3000, in a web browser to open the Dokploy dashboard.Projects in Dokploy isolate different application environments.
Deploy the application by specifying the source repository and creating a new Docker Compose service.
On your project page, click Create Service and select Compose.
Enter a name for your service and click Create.
Open your new Compose service.
Locate the Github configuration section.
Select your GitHub account and repository.
Set the correct Branch.
Click Save to apply the repository settings.
Open the docker-compose.yml file in your local repository and make the following two adjustments to the web service before deploying:
ports: mappings. Dokploy routes traffic through Traefik, so the web service does not need to bind a port on the host.dokploy-network to the service's networks so Traefik can reach the container: Replace web with the actual service name from your compose file.
Commit and push the changes to your repository.
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.
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.
web.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.
DATABASE_URL variable and paste the copied connection URL as the value.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.
0 Comments
Be the first to comment and share your perspective with the community.