Deploying an Ember.js App
Ember.js is a powerful, opinionated JavaScript framework for building ambitious web applications. It features a strong convention-over-configuration philosophy, a robust CLI, and a large ecosystem, making it ideal for scalable single-page applications (SPAs).
This guide explains how to deploy an Ember.js 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 Ember.js App
- Install Ember CLI globally:
Terminal window npm install -g ember-cli - Create a new Ember.js app:
Terminal window ember new my-ember-appcd my-ember-app - Start the development server:
Your app should be running at http://localhost:4200.
Terminal window ember serve
Sample Code (app/components/hello-world.js & app/templates/components/hello-world.hbs)
Create a simple component:
app/components/hello-world.js
import Component from '@glimmer/component';
export default class HelloWorldComponent extends Component {}
app/templates/components/hello-world.hbs
<h1>Hello from Ember.js on Klutch.sh!</h1>
Add <HelloWorld />
to your app/templates/application.hbs
to display it.
Deploying Without a Dockerfile
Ember.js apps are static sites after build. Klutch.sh can deploy static sites directly.
- Push your Ember.js app to a GitHub repository.
- Log in to Klutch.sh.
- Create a new project.
- Create a new app:
- Select your Ember.js GitHub repository and branch
- Choose “Static Site” as the app type
- Set build command:
ember build --environment=production
- Set output directory:
dist
- Configure region, compute, and environment variables as needed
- Click “Create” to deploy. Klutch.sh will build and serve your static Ember.js 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 ember-cli && npm installCOPY . .RUN ember build --environment=production# 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 Ember.js app via Nginx.
Resources
Deploying Ember.js to Klutch.sh is fast and flexible. Use static site deployment for most cases, or Dockerfile for custom setups.