### Koyeb Apps Init Examples
Source: https://www.koyeb.com/docs/build-and-deploy/cli/reference
Reference for examples related to initializing Koyeb applications, directing users to the 'koyeb service create' command for detailed examples.
```bash
See examples of koyeb service create --help
```
--------------------------------
### Install Koyeb CLI using Shell Script
Source: https://www.koyeb.com/docs/build-and-deploy/cli/installation
Installs the Koyeb CLI by executing an install script. The binary is placed in ~/.koyeb.
```bash
curl -fsSL https://raw.githubusercontent.com/koyeb/koyeb-cli/master/install.sh | sh
```
--------------------------------
### Install Dependencies and Create requirements.txt
Source: https://www.koyeb.com/docs/deploy/fastapi
Install FastAPI and Uvicorn, then save the project dependencies to requirements.txt.
```bash
pip install fastapi "uvicorn[standard]"
pip freeze > requirements.txt
```
--------------------------------
### Define Start Script in package.json
Source: https://www.koyeb.com/docs/deploy/hapi
Define a 'start' script in the package.json file to automatically start the application when deployed. This script maps to the command used for local testing.
```json
{
. . .
"scripts": {
"start": "node app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
. . .
}
```
--------------------------------
### Install Koyeb CLI with Homebrew
Source: https://www.koyeb.com/docs/build-and-deploy/cli/installation
Use this command to install the Koyeb CLI if you have Homebrew installed.
```bash
brew install koyeb/tap/koyeb
```
--------------------------------
### Example Docker Image from Docker Hub
Source: https://www.koyeb.com/docs/build-and-deploy/prebuilt-docker-images
Example of specifying the latest version of the 'koyeb/demo' app from Docker Hub.
```text
docker.io/koyeb/demo:latest
```
--------------------------------
### Full Example: Launch Server, Expose Port, and Verify
Source: https://www.koyeb.com/docs/sandboxes/sandbox-expose-port
This comprehensive example demonstrates launching an HTTP server, exposing its port, and verifying accessibility by making an HTTP request. It also shows how to manage multiple ports and unexpose them.
```javascript
import { Sandbox } from '@koyeb/sandbox-sdk'
const sandbox = await Sandbox.create({ name: 'expose-port' })
async function main() {
console.log('\nCreating test file...')
await sandbox.filesystem.write_file('/tmp/test.html', '
Hello from Sandbox!
Port 8080
')
console.log('Test file created')
console.log('\nStarting HTTP server on port 8080...')
const process_id = await sandbox.launch_process('python3 -m http.server 8080', { cwd: '/tmp' })
console.log(`Server started with process ID: ${process_id}`)
console.log('Waiting for server to start...')
await new Promise((resolve) => setTimeout(resolve, 3000))
console.log('\nExposing port 8080...')
let exposed = await sandbox.expose_port(8080)
console.log(`Port exposed: ${exposed.port}`)
console.log(`Exposed at: ${exposed.exposed_at}`)
console.log('Waiting for port to be ready...')
await new Promise((resolve) => setTimeout(resolve, 2000))
console.log('\nMaking HTTP request to verify port exposure...')
let res = await fetch(`${exposed.exposed_at}/test.html`)
if (!res.ok) {
throw new Error(`Status: ${res.status}`)
}
console.log(`✓ Request successful! Status: ${res.status}`)
console.log(`✓ Response content: ${await res.text()}`)
console.log('\nRunning processes:')
const processes = await sandbox.list_processes()
for (const process of processes) {
if (process.status === 'running') {
console.log(` ${process.id}: ${process.command} - ${process.status}`)
}
}
console.log('\nSwitching to port 8081...')
await sandbox.filesystem.write_file('/tmp/test2.html', 'Hello from Sandbox!
Port 8081
')
await sandbox.launch_process('python3 -m http.server 8081', { cwd: '/tmp' })
console.log('Waiting for server to start...')
await new Promise((resolve) => setTimeout(resolve, 3000))
exposed = await sandbox.expose_port(8081)
console.log(`Port exposed: ${exposed.port}`)
console.log(`Exposed at: ${exposed.exposed_at}`)
console.log('Waiting for port to be ready...')
await new Promise((resolve) => setTimeout(resolve, 2000))
console.log('\nMaking HTTP request to verify port 8081...')
res = await fetch(`${exposed.exposed_at}/test2.html`)
if (!res.ok) {
throw new Error(`Status: ${res.status}`)
}
console.log(`✓ Request successful! Status: ${res.status}`)
console.log(`✓ Response content: ${await res.text()}`)
console.log('\nUnexposing port...')
await sandbox.unexpose_port()
console.log('Port unexposed')
}
async function cleanup() {
await sandbox.delete()
}
main().catch(console.error).finally(cleanup)
```
--------------------------------
### Create Example Sandbox Directory
Source: https://www.koyeb.com/docs/sandboxes/sandbox-quickstart
Creates a new directory for the sandbox application and navigates into it.
```bash
mkdir example-sandbox
cd example-sandbox
```
--------------------------------
### Create Example Bun App Directory
Source: https://www.koyeb.com/docs/deploy/bun
Create a new directory for your Bun application and navigate into it.
```bash
mkdir example-bun
cd example-bun
```
--------------------------------
### Install Koyeb Sandbox SDK (JavaScript)
Source: https://www.koyeb.com/docs/sandboxes/sandbox-quickstart
Installs the Koyeb Sandbox SDK for Node.js.
```bash
npm install @koyeb/sandbox-sdx
```
--------------------------------
### Nuxt Project Structure Example
Source: https://www.koyeb.com/docs/deploy/nuxt
An example of the directory structure for a minimalistic Nuxt application.
```text
.\n├── app.vue\n├── .gitignore\n├── .npmrc\n├── nuxt.config.ts\n├── package.json\n├── public\n│ └── favicon.ico\n├── README.md\n└── tsconfig.json\n\n1 directory, 8 files
```
--------------------------------
### Install Koyeb Python SDK
Source: https://www.koyeb.com/docs/sandboxes/sandbox-quickstart
Installs the Koyeb Python SDK using pip.
```bash
pip install koyeb-sdk
```
--------------------------------
### Example .koyebignore File
Source: https://www.koyeb.com/docs/build-and-deploy/deploy-with-git
An example .koyebignore file to exclude common non-application files and directories from triggering redeployments.
```ignore
README.md
CONTRIBUTING.md
.env.example
docs/
```
--------------------------------
### Koyeb Apps Get Help Options
Source: https://www.koyeb.com/docs/build-and-deploy/cli/reference
Help option for the 'koyeb apps get' command.
```bash
-h, --help help for get
```
--------------------------------
### Define start script in package.json
Source: https://www.koyeb.com/docs/deploy/hono
Add a 'start' script to your package.json to allow Koyeb's buildpack to start your application. This script uses tsx to run your main TypeScript file.
```json
{
"scripts": {
"start": "tsx src/index.ts",
"dev": "tsx watch src/index.ts"
},
"dependencies": {
"@hono/node-server": "^1.4.1",
"hono": "^3.12.7"
},
"devDependencies": {
"tsx": "^3.12.2"
}
}
```
--------------------------------
### Pay-per-use Example Invoice Breakdown
Source: https://www.koyeb.com/docs/faqs/pricing
This example invoice illustrates the cost breakdown for a month's compute usage across different instance types (Nano, Micro, Small) for a user not subscribed to a paid plan. It shows the calculation based on instance price, quantity, and time in seconds.
```text
Resource| Price per resource| Quantity| Total cost
---|---|---|---
Nano Instance| $0.000001| 5 356 800 (2x 31 days in seconds)| $5.36
Micro Instance| $0.000002| 13 392 000 (5x 31 days in seconds)| $26.78
Small Instance| $0.000004| 8 035 200 (3 x 31 days in seconds)| $32.14
Total| | | $64.28
```
--------------------------------
### Install Flask and Gunicorn, Freeze Requirements
Source: https://www.koyeb.com/docs/deploy/flask
Installs Flask and Gunicorn, then saves the project's dependencies to requirements.txt.
```bash
pip install flask gunicorn
pip freeze > requirements.txt
```
--------------------------------
### Install a New PostgreSQL Extension
Source: https://www.koyeb.com/docs/databases
Use the CREATE EXTENSION command to install a new PostgreSQL extension.
```sql
CREATE EXTENSION
```
--------------------------------
### Install Project Dependencies
Source: https://www.koyeb.com/docs/deploy/beego
Install all necessary project dependencies by resolving the dependency graph using 'go mod tidy'.
```go
go mod tidy
```
--------------------------------
### Remote File URL Configuration Example
Source: https://www.koyeb.com/docs/run-and-scale/log-exporter
Example of setting an environment variable to specify a remote URL for a Vector configuration file.
```bash
REMOTE_FILE_SINK_CONFIG=https://example.com/http-sink.toml
```
--------------------------------
### Add Start Script to package.json
Source: https://www.koyeb.com/docs/deploy/nuxt
Add a 'start' script to package.json to easily deploy the Nuxt project. This script specifies how to run the project using a non-developer server.
```json
{
"name": "nuxt-app",
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"start": "node .output/server/index.mjs",
"postinstall": "nuxt prepare"
},
"devDependencies": {
"@types/node": "^18",
"nuxt": "^3.4.3"
}
}
```
--------------------------------
### Example Subdomain Format
Source: https://www.koyeb.com/docs/reference/edge-network
Illustrates the format of Koyeb subdomains for accessing applications.
```text
--.koyeb.app
```
--------------------------------
### Example Procfile for Yarn Application
Source: https://www.koyeb.com/docs/build-and-deploy/build-from-git
An example of a `Procfile` that uses `yarn start:production` to launch a Node.js application.
```yaml
web: yarn start:production
```
--------------------------------
### Create Dockerfile for Express.js Project
Source: https://www.koyeb.com/docs/deploy/express
This Dockerfile sets up a minimal Node.js environment, copies project files, installs dependencies, exposes a port, and defines the start command for the Express application.
```docker
FROM node:slim
WORKDIR /app
COPY . .
RUN npm ci
ARG PORT
EXPOSE ${PORT:-3000}
CMD ["npm", "run", "start"]
```
--------------------------------
### Create Project Directory and Navigate
Source: https://www.koyeb.com/docs/deploy/php
Sets up the project structure and navigates into the web directory for PHP files.
```bash
mkdir -p example-php/web
cd example-php/web
```
--------------------------------
### Create Dockerfile for Astro Project
Source: https://www.koyeb.com/docs/deploy/astro
A Dockerfile to build and run an Astro project using the Node.js LTS Alpine image. It installs dependencies, builds the project, exposes the port, and starts the application.
```docker
FROM node:lts-alpine
WORKDIR /app
COPY . .
RUN npm ci
RUN npm run build
ARG PORT
EXPOSE ${PORT:-4321}
CMD npm run start
```
--------------------------------
### Create a New Qwik App
Source: https://www.koyeb.com/docs/deploy/qwik
Use the Qwik CLI to create a new project, selecting a basic app starter and installing dependencies.
```bash
npm run qwik add
```
--------------------------------
### Dockerfile for Fastify Application
Source: https://www.koyeb.com/docs/deploy/fastify
This Dockerfile provides the basic configuration to containerize a Node.js Fastify application. It sets the Node.js LTS base image, copies project files, installs dependencies, exposes the application port, and defines the start command.
```dockerfile
FROM node:lts
WORKDIR /app
COPY . .
RUN npm ci
EXPOSE 3000
CMD ["npm", "start"]
```
--------------------------------
### Start a new Django project
Source: https://www.koyeb.com/docs/deploy/django
Use this command to create a new Django project in the current directory.
```bash
django-admin startproject example_django ./
```
--------------------------------
### Dockerfile for Remix App
Source: https://www.koyeb.com/docs/deploy/remix
This Dockerfile defines the build and runtime environment for a Remix application. It uses a multi-stage build process, starting from a Node.js Alpine base image, installing dependencies, building the application, and finally setting up a minimal runner environment.
```docker
FROM node:18-alpine AS base
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./
COPY . .
RUN npm run build && npm cache clean --force
FROM base AS runner
WORKDIR /app
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 remix
COPY --from=builder /app .
USER remix
EXPOSE 3000
ENV PORT 3000
CMD ["npm", "run", "start"]
```
--------------------------------
### Initialize Qwik App from Container Registry
Source: https://www.koyeb.com/docs/deploy/qwik
Deploy a pre-built Qwik container image to Koyeb using the CLI. Replace placeholders with your container image name and tag.
```bash
koyeb app init example-qwik \
--docker :
--ports 3000:http \
--routes /:3000 \
```
--------------------------------
### Initialize Node.js Project
Source: https://www.koyeb.com/docs/deploy/express
Initialize a new Node.js project, setting the entry point to app.js.
```bash
npm init
```
--------------------------------
### Add Start Script to package.json
Source: https://www.koyeb.com/docs/deploy/express
Add a 'start' script to the package.json file to enable running the application with 'npm run start'.
```json
{
"name": "example-expressjs",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "node app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.18.2"
}
}
```
--------------------------------
### Modify package.json Start Script
Source: https://www.koyeb.com/docs/deploy/nestjs
Update the 'start' script in package.json to use 'node dist/main' for production builds, aligning it with the 'start:prod' script.
```json
{
"scripts": {
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "node dist/main",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
...
}
```
--------------------------------
### Initialize App and Service from Git
Source: https://www.koyeb.com/docs/build-and-deploy/deploy-with-git
Basic command to create a Koyeb App and Service from a GitHub repository. Specify the app and service name, Git repository URL, branch, and builder.
```bash
koyeb app init \
--git \
--git-branch \
--git-builder \
. . .
```
--------------------------------
### Install Express
Source: https://www.koyeb.com/docs/deploy/express
Install the Express framework for your Node.js project.
```bash
npm install express
```
--------------------------------
### Initialize Go App with Koyeb CLI
Source: https://www.koyeb.com/docs/deploy/go
Use this command to initialize a new Go application on Koyeb, linking it to a GitHub repository. Ensure you replace placeholders with your specific GitHub username and repository name.
```bash
koyeb app init example-go \
--git github.com// \
--git-branch main \
--ports 8080:http \
--routes /:8080 \
--env PORT=8080
```
--------------------------------
### Install Gradio Package
Source: https://www.koyeb.com/docs/deploy/gradio
Install the Gradio library using pip.
```bash
pip install gradio
```
--------------------------------
### Navigate to Project Directory
Source: https://www.koyeb.com/docs/deploy/qwik
After the project is created, change into the new project directory to begin development.
```bash
cd example-qwik
```
--------------------------------
### Initialize Bun Application
Source: https://www.koyeb.com/docs/deploy/bun
Initialize a new Bun project, selecting 'Library' as the template and 'server.ts' as the entry point.
```bash
bun init
```
--------------------------------
### Install Dependencies
Source: https://www.koyeb.com/docs/deploy/fastify
Install the necessary Node.js dependencies for your Fastify application.
```bash
npm install
```
--------------------------------
### Initialize Beego App from Container Registry using Koyeb CLI
Source: https://www.koyeb.com/docs/deploy/beego
Deploy a pre-built Beego container image to Koyeb using the CLI. Replace the placeholder with your actual container image name and tag.
```bash
koyeb app init example-beego \
--docker :
```
--------------------------------
### Install Streamlit
Source: https://www.koyeb.com/docs/deploy/streamlit
Install the Streamlit library within your activated virtual environment.
```bash
pip install streamlit
```
--------------------------------
### Create Demo Application Directory
Source: https://www.koyeb.com/docs/integrations/databases/upstash
Creates a new directory for the demo application and navigates into it.
```bash
mkdir example-koyeb-upstash
cd example-koyeb-upstash
```
--------------------------------
### Install Hapi Dependency
Source: https://www.koyeb.com/docs/deploy/hapi
Install the Hapi framework and its dependencies within your project.
```bash
npm install @hapi/hapi
```
--------------------------------
### Initialize Koyeb App with PlanetScale
Source: https://www.koyeb.com/docs/integrations/databases/planetscale
Use this command to initialize a new Koyeb application, linking it to a GitHub repository and configuring environment variables for PlanetScale connection. Remember to replace placeholders with your actual PlanetScale credentials.
```bash
koyeb app init express-planetscale \
--git github.com/koyeb/example-express-prisma \
--git-branch main \
--git-build-command "npm run mysql:init" \
--ports 8080:http \
--routes /:8080 \
--env PORT=8080 \
--env DATABASE_URL="mysql://:@us-east.connect.psdb.cloud/?sslaccept=strict"
```
--------------------------------
### Initialize PHP App with Git and Buildpacks
Source: https://www.koyeb.com/docs/deploy/php
Use this command to initialize a new PHP application on Koyeb, deploying from a GitHub repository using native buildpacks. Ensure you replace placeholder values with your specific GitHub username and repository name.
```bash
koyeb app init example-php \
--git github.com// \
--git-branch main \
--ports 3000:http \
--routes /:3000 \
```
--------------------------------
### View Installed PostgreSQL Extensions
Source: https://www.koyeb.com/docs/databases
Query the database to list all currently installed PostgreSQL extensions.
```sql
SELECT * FROM pg_extension;
```
--------------------------------
### Initialize PHP App from Container Registry
Source: https://www.koyeb.com/docs/deploy/php
Deploy a pre-built PHP container image to Koyeb using the CLI. Replace the placeholder with your actual container image name and tag.
```bash
koyeb app init example-php \
--docker :
--ports 3000:http \
--routes /:3000 \
```
--------------------------------
### Initialize Java App from Container Registry via Koyeb CLI
Source: https://www.koyeb.com/docs/deploy/java
Deploy a pre-built Java container image to Koyeb using the CLI. Replace the placeholder with your actual container image and tag.
```bash
koyeb app init example-java \
--docker :
--ports 3000:http \
--routes /:3000 \
```
--------------------------------
### Initialize Remix App with Koyeb CLI
Source: https://www.koyeb.com/docs/deploy/remix
Use this command to initialize your Remix app on Koyeb directly from a Git repository. Replace placeholders with your GitHub username and repository name. Ensure your repository is on the 'main' branch and the app listens on port 3000.
```bash
koyeb app init example-remix \
--git github.com// \
--git-branch main \
--ports 3000:http \
--routes /:3000 \
--env PORT=3000
```
--------------------------------
### Initialize Qwik App from Git with Buildpacks
Source: https://www.koyeb.com/docs/deploy/qwik
Use this command to initialize a Qwik app deployment from a GitHub repository using native buildpacks. Replace placeholders with your repository details.
```bash
koyeb app init example-qwik \
--git github.com// \
--git-branch main \
--ports 3000:http \
--routes /:3000 \
```
--------------------------------
### Initialize Node.js Project
Source: https://www.koyeb.com/docs/deploy/hapi
Initialize a new Node.js project with a basic package.json file.
```bash
npm init --yes
```
--------------------------------
### Initialize Java App with Docker Builder via Koyeb CLI
Source: https://www.koyeb.com/docs/deploy/java
Initialize a Java application deployment using Git and a Dockerfile for building. Replace the `--git-run-command` with `--git-builder docker`.
```bash
koyeb app init example-java \
--git github.com// \
--git-branch main \
--git-builder docker
--ports 3000:http \
--routes /:3000 \
```
--------------------------------
### Update Start Script in package.json
Source: https://www.koyeb.com/docs/deploy/fastify
Modify the 'start' script in your `package.json` to make Fastify listen on all interfaces (0.0.0.0).
```json
{
...
"scripts": {
"start": "fastify start -l info -a 0.0.0.0 app.js",
...
```
--------------------------------
### Initialize Koyeb App with Git
Source: https://www.koyeb.com/docs/deploy/deno
Initialize a Koyeb application using Git for deployment. This command sets up the app with a specified name, Git repository, branch, and port/route configurations.
```bash
koyeb app init example-deno \
--git github.com// \
--git-branch main \
--ports 3000:http \
--routes /:3000 \
```
--------------------------------
### Example API Response for Planets
Source: https://www.koyeb.com/docs/integrations/databases/cockroachdb
This is an example of the JSON response you can expect when accessing the `/planets` endpoint of the deployed application.
```json
[
{
"id": "827696777012871169",
"name": "Mercury"
},
{
"id": "827696777225666561",
"name": "Venus"
},
{
"id": "827696777389539329",
"name": "Mars"
}
]
```
--------------------------------
### Koyeb Apps Describe Help Options
Source: https://www.koyeb.com/docs/build-and-deploy/cli/reference
Help option for the 'koyeb apps describe' command.
```bash
-h, --help help for describe
```
--------------------------------
### Create Basic Hapi Application
Source: https://www.koyeb.com/docs/deploy/hapi
Create a basic Hapi web server that listens on a configurable port and responds with 'Hello World!' on the root path.
```javascript
// app.js
'use strict'
const Hapi = require('@hapi/hapi')
const port = process.env.PORT || 3000
const init = async () => {
const server = Hapi.server({
port: port,
host: '0.0.0.0',
})
server.route({
method: 'GET',
path: '/',
handler: (request, h) => {
return 'Hello World!'
},
})
await server.start()
console.log('Server running on %s', server.info.uri)
}
process.on('unhandledRejection', (err) => {
console.log(err)
process.exit(1)
})
init()
```
--------------------------------
### Koyeb CLI Service Scale Get Options
Source: https://www.koyeb.com/docs/build-and-deploy/cli/reference
Options specific to the `koyeb services scale get` command.
```bash
-a, --app string Service application
-h, --help help for get
```
--------------------------------
### Initialize Bun App with Koyeb CLI
Source: https://www.koyeb.com/docs/deploy/bun
Use this command to initialize a new Bun application deployment on Koyeb via the CLI. Ensure you replace placeholder values with your specific GitHub repository details.
```bash
koyeb app init example-bun \
--git github.com// \
--git-branch main \
--git-builder docker \
--ports 8080:http \
--routes /:8080 \
--env PORT=8080
```
--------------------------------
### Install Upstash Redis and Express
Source: https://www.koyeb.com/docs/integrations/databases/upstash
Installs the necessary npm packages for connecting to Upstash Redis and building a web application with Express.
```bash
npm install @upstash/redis express
```
--------------------------------
### Navigate to Project Directory
Source: https://www.koyeb.com/docs/deploy/remix
After creating the Remix application, move into the newly generated project directory to begin development.
```bash
cd example-remix
```
--------------------------------
### Start Background Process in Sandbox
Source: https://www.koyeb.com/docs/build-and-deploy/cli/reference
Start a command as a background process in the sandbox. Supports custom working directories and environment variables.
```bash
# Start a web server in background
$> koyeb sandbox start myapp/mysandbox python -m http.server 8080
```
```bash
# Start a process with custom working directory
$> koyeb sandbox start myapp/mysandbox --cwd /app npm start
```
--------------------------------
### Create and Activate Virtual Environment
Source: https://www.koyeb.com/docs/deploy/gradio
Set up a Python virtual environment for your project and activate it.
```bash
python3 -m venv venv
source venv/bin/activate
```
--------------------------------
### Go HTTP Server Example
Source: https://www.koyeb.com/docs/deploy/go
A simple Go HTTP server that listens on a specified port (defaults to 8080) and responds with 'Hello from Koyeb' to root requests.
```go
package main
import (
"fmt"
"log"
"net/http"
"os"
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
http.HandleFunc("/", HelloHandler)
log.Println("Listening on port", port)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))
}
func HelloHandler(w http.ResponseWriter, _ *http.Request) {
fmt.Fprintf(w, "Hello from Koyeb")
}
```
--------------------------------
### Neon PostgreSQL Connection String Example
Source: https://www.koyeb.com/docs/integrations/databases/neon
This is an example of a Neon PostgreSQL connection string. Replace placeholders with your actual database credentials.
```sql
postgres://:@:/neondb
```
--------------------------------
### Install Django Dependencies
Source: https://www.koyeb.com/docs/deploy/django
Install Django, Gunicorn, and WhiteNoise using pip. Gunicorn serves the application, and WhiteNoise serves static content.
```bash
pip install Django gunicorn whitenoise
```
--------------------------------
### Initialize Beego App from GitHub using Koyeb CLI
Source: https://www.koyeb.com/docs/deploy/beego
Use this command to initialize a Beego application deployment from a GitHub repository using Koyeb CLI. Replace placeholders with your GitHub username, repository name, and desired branch. The `--git-builder docker` flag can be added to use a Dockerfile for building.
```bash
koyeb app init example-beego \
--git github.com// \
--git-branch main \
```
--------------------------------
### CLI Volume Deletion Example
Source: https://www.koyeb.com/docs/build-and-deploy/cli/reference
To delete a volume, use '!VOLUME' followed by the volume name. This is an example of volume management within the CLI.
```bash
--volume '!myvolume'
```
--------------------------------
### Navigate and Run Astro Dev Server
Source: https://www.koyeb.com/docs/deploy/astro
After creating the project, change into the project directory and start the development server to test the application locally.
```bash
cd example-astro
npm run dev
```
--------------------------------
### CLI Route Deletion Example
Source: https://www.koyeb.com/docs/build-and-deploy/cli/reference
To delete a route, use '!PATH' followed by the route path. This is an example of route management within the CLI.
```bash
--route '!/foo'
```
--------------------------------
### Create a New Java Project with Maven
Source: https://www.koyeb.com/docs/deploy/java
Generates a new Java project using the maven-archetype-quickstart template. This command sets up the basic project structure, including a pom.xml file for dependency management.
```bash
mvn archetype:generate -DgroupId=app.koyeb.example \
-DartifactId=example-java \
-DarchetypeArtifactId=maven-archetype-quickstart \
-DarchetypeVersion=1.4 \
-DinteractiveMode=false
```
--------------------------------
### Koyeb Log Output Example
Source: https://www.koyeb.com/docs/build-and-deploy/troubleshooting-tips
This is an example of how a log entry from a Koyeb instance appears, showing the instance ID, stream, and the message content.
```text
instance-131869ab stdout Hey there, I'm a service running on Koyeb
```
--------------------------------
### Initialize Fastify Project
Source: https://www.koyeb.com/docs/deploy/fastify
Use npm to initialize a new Fastify project. This command generates the basic project structure and files.
```bash
$ npm init fastify
Need to install the following packages:
create-fastify@3.0.0
Ok to proceed? (y) y
generated README.md
generated .gitignore
generated app.js
generated plugins/README.md
generated routes/README.md
generated test/helper.js
generated plugins/sensible.js
generated plugins/support.js
generated routes/root.js
generated routes/example/index.js
generated test/plugins/support.test.js
generated test/routes/example.test.js
generated test/routes/root.test.js
--> reading package.json in .
edited package.json, saving
saved package.json
--> project fastify-test generated successfully
run 'npm install' to install the dependencies
run 'npm start' to start the application
run 'npm run dev' to start the application with pino-colada pretty logging (not suitable for production)
run 'npm test' to execute the unit tests
```
--------------------------------
### Verify NestJS CLI Installation
Source: https://www.koyeb.com/docs/deploy/nestjs
Checks if the NestJS CLI has been installed successfully by displaying environment and CLI version information. It will indicate if you are not in a project directory.
```bash
nest info
```
--------------------------------
### Install NestJS CLI Globally
Source: https://www.koyeb.com/docs/deploy/nestjs
Installs the NestJS command-line utility globally using npm. This tool is used for creating and managing NestJS projects.
```bash
npm install --global @nestjs/cli
```
--------------------------------
### Initialize Hapi App from GitHub with Buildpacks
Source: https://www.koyeb.com/docs/deploy/hapi
Initialize a new Koyeb app from a GitHub repository using native buildpacks. Replace placeholders with your GitHub username and repository name.
```bash
koyeb app init example-hapi \
--git github.com// \
--git-branch main \
```
--------------------------------
### Buildpack Error for Missing Start Command
Source: https://www.koyeb.com/docs/build-and-deploy/build-from-git
This error message indicates that a start command is required for the application to launch, typically when no `Procfile` or default process is defined.
```text
failed to launch: determine start command: when there is no default process a command is required
```
--------------------------------
### Initialize Koyeb App with Git and Environment Variables
Source: https://www.koyeb.com/docs/integrations/databases/upstash
Use this command to initialize a new Koyeb application from a Git repository, configuring ports, routes, and environment variables including Upstash Redis credentials.
```bash
koyeb app init example-koyeb-upstash \
--git github.com// \
--git-branch main \
--ports 3000:http \
--routes /:3000 \
--env PORT=3000 \
--env UPSTASH_REDIS_REST_URL="" \
--env UPSTASH_REDIS_REST_TOKEN=""
```
--------------------------------
### Install Koyeb Pulumi Provider
Source: https://www.koyeb.com/docs/integrations/infrastructure-as-code/pulumi
Install the Koyeb Pulumi provider package using npm. This makes the Koyeb resources available for use in your Pulumi infrastructure code.
```bash
npm install --save @koyeb/pulumi-koyeb
```
--------------------------------
### Initialize Hono App with GitHub Repository (Koyeb CLI)
Source: https://www.koyeb.com/docs/deploy/hono
Use this command to initialize a Hono application deployment from a GitHub repository using the Koyeb CLI. Replace placeholders with your repository details. Supports native buildpacks by default.
```bash
koyeb app init example-hono \
--git github.com// \
--git-branch main \
--ports 3000:http \
--routes /:3000 \
```
--------------------------------
### Modify package.json Start Script
Source: https://www.koyeb.com/docs/deploy/qwik
Update the 'start' script in package.json to use the production server entry point. This ensures Koyeb deploys the production build correctly.
```json
{
...
"scripts": {
"build": "qwik build",
"build.client": "vite build",
"build.preview": "vite build --ssr src/entry.preview.tsx",
"build.server": "vite build -c adapters/express/vite.config.ts",
"build.types": "tsc --incremental --noEmit",
"deploy": "echo 'Run \"npm run qwik add\" to install a server adapter'",
"dev": "vite --mode ssr",
"dev.open": "vite --open --mode ssr",
"dev.debug": "node --inspect-brk ./node_modules/vite/bin/vite.js --mode ssr --force",
"fmt": "prettier --write .",
"fmt.check": "prettier --check .",
"lint": "eslint \"src/**/*.ts*\"",
"preview": "qwik build preview && vite preview --open",
"serve": "node server/entry.express",
"start": "node server/entry.express",
"qwik": "qwik"
},
...
}
```
--------------------------------
### Initialize Gradio App with Koyeb CLI (Dockerfile)
Source: https://www.koyeb.com/docs/deploy/gradio
Initialize a Gradio application on Koyeb using the CLI, specifying Git as the source and using a Dockerfile for the build process.
```bash
koyeb app init example-gradio \
--git github.com// \
--git-branch main \
--git-builder docker
```
--------------------------------
### Initialize Fastify App with Koyeb CLI
Source: https://www.koyeb.com/docs/deploy/fastify
Use this command to initialize a new Fastify application deployment on Koyeb via the CLI. Replace placeholders with your GitHub repository details. It configures the Git source, branch, ports, routes, and environment variables.
```bash
koyeb app init example-fastify \
--git github.com// \
--git-branch main \
--ports 8080:http \
--routes /:8080 \
--env PORT=8080
```
--------------------------------
### Modify package.json for Node.js Start Script
Source: https://www.koyeb.com/docs/deploy/astro
Update the 'start' script in package.json to use Node.js for serving build artifacts. This ensures the application runs correctly after building.
```json
{
"name": "example-astro",
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"start": "node dist/server/entry.mjs",
"build": "astro check && astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"@astrojs/check": "^0.5.10",
"@astrojs/node": "^8.2.5",
"astro": "^4.6.0",
"typescript": "^5.4.5"
}
}
```
--------------------------------
### CLI Volume Update Example
Source: https://www.koyeb.com/docs/build-and-deploy/cli/reference
Update service volumes using the format VOLUME:PATH. This example shows how to associate a volume named 'myvolume' with the '/data' path.
```bash
--volume myvolume:/data
```
--------------------------------
### Create a Hello World Web App in Java
Source: https://www.koyeb.com/docs/deploy/java
Replaces the default App.java content with code to create a simple HTTP server. This web application listens on a configurable port and responds with 'Hello world!' to root requests.
```java
package app.koyeb.example;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
public class App {
public static void main(String[] args) throws Exception {
int port = Integer.parseInt(System.getenv().getOrDefault("PORT", "8888"));
HttpServer server = HttpServer.create(new InetSocketAddress(port), 0);
server.createContext("/", new MyHandler());
server.setExecutor(Executors.newCachedThreadPool());
System.out.println("Listening on port " + port + ".");
server.start();
}
static class MyHandler implements HttpHandler {
@Override
public void handle(HttpExchange t) throws IOException {
String response = "Hello world!";
t.sendResponseHeaders(200, response.length());
OutputStream os = t.getResponseBody();
os.write(response.getBytes());
os.close();
}
}
}
```
--------------------------------
### Install Beego CLI Tool
Source: https://www.koyeb.com/docs/deploy/beego
Install the bee command line tool for Beego projects. This tool is used for initializing projects, managing scripts, and running development servers.
```go
go install github.com/beego/bee/v2@latest
```
--------------------------------
### Initialize Spring Boot App from GitHub using Koyeb CLI
Source: https://www.koyeb.com/docs/deploy/spring-boot
Use this command to initialize a Spring Boot application deployment from a GitHub repository using the Koyeb CLI. It specifies the Git repository, branch, and port mappings. Replace placeholders with your specific details.
```bash
koyeb app init example-spring-boot \
--git github.com// \
--git-branch main \
--ports 3000:http \
--routes /:3000 \
```
--------------------------------
### Run Express App with npm start and Custom Port
Source: https://www.koyeb.com/docs/deploy/express
Run the Express application using 'npm run start' with a custom port specified via an environment variable.
```bash
PORT=8000 npm run start
```
--------------------------------
### Initialize Hono App from Container Registry (Koyeb CLI)
Source: https://www.koyeb.com/docs/deploy/hono
Deploy a pre-built Hono container image on Koyeb using the CLI. Specify your container image and tag, along with ports and routes.
```bash
koyeb app init example-hono \
--docker :
--ports 3000:http \
--routes /:3000 \
```