Deploying an Aurelia App
Aurelia is a modern, open-source front-end framework for building browser-based applications. It features a powerful data-binding engine, modular architecture, and a focus on web standards, making it ideal for scalable and maintainable single-page applications (SPAs).
This guide explains how to deploy an Aurelia application to Klutch.sh, both with and without a Dockerfile. It covers installation, sample code, and deployment steps.
Prerequisites
- Node.js & npm installed (Download)
- Git and GitHub account
- Klutch.sh account
Getting Started: Create an Aurelia App
- Install Aurelia CLI globally:
Terminal window npm install -g aurelia-cli - Create a new Aurelia app:
Terminal window au new my-aurelia-appcd my-aurelia-appnpm install - Start the development server:
Your app should be running at http://localhost:8080.
Terminal window au run --watch
Sample Code (src/app.html & src/app.js)
Replace the contents of src/app.html
with:
<template> <h1>Hello from Aurelia on Klutch.sh!</h1></template>
Replace the contents of src/app.js
with:
export class App {}
Deploying Without a Dockerfile
Aurelia apps are static sites after build. Klutch.sh can deploy static sites directly.
- Push your Aurelia app to a GitHub repository.
- Log in to Klutch.sh.
- Create a new project.
- Create a new app:
- Select your Aurelia GitHub repository and branch
- Choose “Static Site” as the app type
- Set build command:
au build --env prod
- Set output directory:
dist
- Configure region, compute, and environment variables as needed
- Click “Create” to deploy. Klutch.sh will build and serve your static Aurelia app.
Deploying With a Dockerfile
If you need custom server logic or want to use a Dockerfile:
- Add a
Dockerfile
to your project root. Example:# Build stageFROM node:20-alpine AS builderWORKDIR /appCOPY package*.json ./RUN npm install -g aurelia-cli && npm installCOPY . .RUN au build --env prod# Production stageFROM nginx:alpineCOPY --from=builder /app/dist /usr/share/nginx/htmlEXPOSE 80CMD ["nginx", "-g", "daemon off;"] - Push your code (with Dockerfile) to GitHub.
- In Klutch.sh, create a new app and select the Dockerfile option when prompted.
- Set service details and environment variables as needed.
- Click “Create” to deploy. Klutch.sh will build your Docker image and serve your Aurelia app via Nginx.
Resources
Deploying Aurelia to Klutch.sh is fast and flexible. Use static site deployment for most cases, or Dockerfile for custom setups.