Deploy Your First App
Deploy a simple web application to Gordon in under 10 minutes.
What You'll Learn
- Building a container image
- Pushing to Gordon's registry
- Configuring routes
- Deploying your app
Prerequisites
- Gordon running on your VPS
- Docker installed locally
- Domain configured (e.g.,
app.mydomain.com)
Steps
1. Create a Simple App
Create a new directory with a simple Node.js app:
mkdir my-first-app
cd my-first-app
Create server.js:
const http = require('http');
const port = process.env.PORT || 3000;
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(`
<html>
<body>
<h1>Hello from Gordon!</h1>
<p>Deployed at: ${new Date().toISOString()}</p>
</body>
</html>
`);
});
server.listen(port, '0.0.0.0', () => {
console.log(`Server running on port ${port}`);
});
Create Dockerfile:
FROM node:18-alpine
WORKDIR /app
COPY server.js .
ENV PORT=3000
EXPOSE 3000
CMD ["node", "server.js"]
2. Build the Image
docker build -t my-first-app .
3. Tag for Gordon Registry
Replace registry.mydomain.com with your Gordon registry domain:
docker tag my-first-app registry.mydomain.com/my-first-app:latest
4. Configure the Route
On your Gordon server, edit ~/.config/gordon/gordon.toml:
[routes]
"app.mydomain.com" = "my-first-app:latest"
Reload Gordon:
gordon reload
5. Push to Deploy
Login to your registry (if auth enabled):
docker login registry.mydomain.com
Push the image:
docker push registry.mydomain.com/my-first-app:latest
6. Verify Deployment
Visit https://app.mydomain.com in your browser.
You should see "Hello from Gordon!" with the deployment timestamp.
Common Issues
"unauthorized" on push
Enable registry authentication or check credentials:
gordon auth token generate --subject deploy --expiry 0
docker login -u deploy -p <token> registry.mydomain.com
App not accessible
Check the container is running:
docker ps | grep my-first-appCheck Gordon logs:
gordon logs -fEnsure DNS points to your server
Wrong port
If your app uses a different port, expose it in Dockerfile:
ENV PORT=8080
EXPOSE 8080
Updating Your App
Make changes, then rebuild and push:
# Edit server.js
docker build -t my-first-app .
docker tag my-first-app registry.mydomain.com/my-first-app:latest
docker push registry.mydomain.com/my-first-app:latest
Gordon automatically deploys the update with zero downtime.