Explita InfraExplita Infra
Deploy

Deploying Your First App

Learn how to prepare, initialize, and deploy Docker applications with zero downtime

This guide walks you through preparing a codebase, generating an explita.json configuration, running your first production deployment, and monitoring logs.


1. Preparing Your Dockerfile

Explita Deploy builds your applications using standard Dockerfiles. Here is a production-ready example for a Next.js or Node.js application:

FROM node:22-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app ./
EXPOSE 3000
CMD ["npm", "start"]

Tip: Explita automatically inspects the EXPOSE directive in your Dockerfile to auto-detect the default container port.


2. Initializing Project Config (eda init)

Run eda init inside your project root:

eda init

The command prompts you for:

  • Application Name: Defaults to the name in your package.json or current folder.
  • Container Port: Defaults to 3000 (or the port detected in your Dockerfile).
  • Custom Domain(s): Optional domain names you wish to bind.

This creates an explita.json file in your repository:

{
  "$schema": "https://infra.explita.ng/config/schema.json",
  "name": "my-web-app",
  "port": 3000,
  "healthCheck": {
    "path": "/",
    "timeout": 15,
    "interval": 2,
    "retries": 10
  },
  "preDeploy": "npx prisma migrate deploy",
  "domains": ["myapp.com"],
  "tunnel": true
}

Key Configuration Fields

FieldTypeDescription
namestringUnique application identifier registered on the server.
portnumberPort your application listens on inside the container.
healthCheck.pathstringHTTP endpoint probed by the deploy engine before routing traffic (default /).
preDeploystringCommand executed inside a temporary container before traffic swap (e.g. database migrations).
domainsstring[]Array of production custom domains to attach with automated SSL.
tunnelbooleanAutomatically provisions a public HTTPS tunnel under *.tunnel.explita.ng.
volumesstring[]Persistent host volume bindings (e.g. ["/var/data:/app/uploads"]).

3. Deploying to the Server

Once explita.json is in place, deploy your code by simply running:

eda

If you are deploying for the first time without an existing explita.json:

eda -n my-web-app -p 3000 -t

What Happens During Deployment:

  1. Source Archiving: Local source code (ignoring .git, node_modules, and patterns in .dockerignore) is packed into a compressed tarball.
  2. Uploading: The archive is streamed securely to the remote Explita Deploy server.
  3. Docker Build: Docker BuildKit compiles your image with layer caching (web-app:v1.0.0).
  4. Pre-Deploy Hook: If configured, commands like database migrations (npx prisma migrate deploy) run in an ephemeral container.
  5. Container Start: The new container starts on the internal explita-net bridge network on a dynamically allocated port.
  6. Health Check Probing: The control plane repeatedly probes http://container:<port>/ until it returns a 2xx or 3xx HTTP status code.
  7. Zero-Downtime Traffic Swap: Once healthy, Caddy atomically shifts 100% of incoming domain and tunnel traffic to the new container. The previous container is kept alive for a brief grace period to finish active requests, then cleanly stopped.

4. Monitoring Logs & Live Stream

Build & Deploy Logs

View the build log from the most recent deployment:

eda logs

Live Runtime Application Logs

Stream live container stdout/stderr over WebSocket in real time:

eda logs --live

Print the last 100 lines and continue streaming:

eda logs --live --tail 100

Resource Utilization (eda stats / eda top)

Inspect CPU, memory, and network I/O in real time:

# Snapshot resource usage
eda stats

# Interactive live terminal dashboard
eda top

5. Remote Container Shell & Execution

Need to run a command or inspect files inside the live container? You don't need SSH access to the host VPS:

Interactive Remote Shell (eda sh)

Open an interactive terminal directly inside your running container:

eda sh
# Or explicitly request bash:
eda sh -s bash

One-Off Command Execution (eda exec)

Run non-interactive administrative commands:

eda exec -- npm run db:seed
eda exec -- ls -la /app

6. Lifecycle Management

Control the container state on the server:

# Restart the container
eda restart

# Temporarily stop the container
eda stop

# Start a stopped container
eda start

# Adjust resource quotas
eda set --memory 1g --cpus 1.5

Now that you know how to deploy applications, learn how to run isolated branch previews with cloned databases!

On this page