Your First Deployment
This guide will walk you through deploying your first application with FTL. We'll cover the basic deployment workflow and essential commands.
Prerequisites
Before starting your first deployment, ensure you have:
- Installed FTL on your local machine
- Created your configuration file (
ftl.yaml
) - A Docker image of your application
- SSH access to your target server
- A domain name pointing to your server's IP address
Deployment Steps
1. Server Setup
First, prepare your server with the required dependencies:
ftl setup
This command will:
- Install Docker and other required packages
- Configure system settings
- Set up Docker networks
- Configure firewall rules
2. Building Your Application
Build your application's Docker image. FTL provides two ways to handle images:
Direct SSH Transfer (Default)
If you don't specify an image
field in your service configuration, FTL will:
- Build the image locally
- Transfer it directly to your server via SSH
- Optimize transfers using layer caching
services:
- name: web
build:
context: .
dockerfile: Dockerfile
This method is simpler as it doesn't require registry setup.
Registry-based Deployment
If you specify an image
field, FTL will use a Docker registry:
ftl build
Registry Authentication
- Only username/password authentication is supported
- Token-based authentication will fail
- You'll be prompted for registry credentials during server setup
TIP
When using registry-based deployment, you can skip pushing to registry with:
ftl build --skip-push
3. Deploying Your Application
Deploy your application to the configured servers:
ftl deploy
The deployment process:
- Connects to your server(s) via SSH
- Transfers images directly or pulls from registry (depending on configuration)
- Sets up volumes and networks
- Starts dependencies (if any)
- Launches your services with health checks
- Configures the Nginx reverse proxy
- Sets up SSL certificates (if domain is configured)
4. Verifying the Deployment
After deployment, verify your application is running:
Check the application status:
bashftl status
View application logs:
bashftl logs
Access your application through the configured domain
Common First Deployment Issues
SSL Certificate Generation
If SSL certificate generation fails:
- Ensure your domain points to the server's IP address
- Check that ports 80 and 443 are accessible
- Verify the email address in your configuration
Container Health Checks
If containers fail health checks:
- Verify your health check endpoint is responding
- Check the application logs for errors
- Ensure the health check path is correct in
ftl.yaml
Network Issues
If you can't access your application:
- Verify your domain's DNS settings
- Check server firewall configuration
- Ensure your application is listening on the configured port
Example Deployment
Here's a complete example of deploying a simple web application:
Configuration (
ftl.yaml
):yamlproject: name: my-web-app domain: myapp.example.com email: [email protected] servers: - host: myapp.example.com user: deploy ssh_key: ~/.ssh/id_rsa services: - name: web build: context: . dockerfile: Dockerfile port: 3000 health_check: path: /health interval: 10s timeout: 5s retries: 3 routes: - path: / strip_prefix: false
This example uses direct SSH transfer. For registry-based deployment, add the
image
field:yamlservices: - name: web image: registry.example.com/my-web-app:latest build: context: . dockerfile: Dockerfile port: 3000 health_check: path: /health interval: 10s timeout: 5s retries: 3 routes: - path: / strip_prefix: false
Deployment commands:
bash# Setup server ftl setup # Build and deploy ftl build ftl deploy # Check status and logs ftl status ftl logs
Deployment Workflow Tips
Start Small
- Begin with a simple service configuration
- Add dependencies and complexity gradually
- Test each addition separately
Use Environment Variables
bash# Create a .env file for local development echo "API_KEY=development-key" > .env # Deploy with production values API_KEY=production-key ftl deploy
Monitor Deployments
- Watch the logs during deployment
- Check health status after deployment
- Verify all routes are working
Next Steps
After your first successful deployment:
- Learn about Zero-downtime Deployments
- Explore Health Checks configuration
- Set up SSL Management
- Configure Logging and Monitoring
WARNING
Remember to always test deployments in a staging environment before deploying to production.
Reference
For more detailed information, see: