Traditional content management systems like WordPress bundle your content, templates and frontend code into a single application. This creates performance bottlenecks and limits how you can deliver content across different platforms.
You will build a headless CMS setup using Strapi to manage content and Astro to generate your frontend. This separation gives you faster page loads, better security and the flexibility to use your content anywhere. We will deploy both applications on a VPS using Docker containers.
Docker Compose lets you define both Strapi and its database in a single configuration file. This approach keeps your applications isolated and makes deployment repeatable.
ssh username@your-server-ip replacing username with your actual username and your-server-ip with your VPS IP address.mkdir ~/astro-strapi && cd ~/astro-strapi to create and enter a new directory for your project files.nano docker-compose.yml to open a new file in the text editor.File: docker-compose.yml
version: '3'
services:
strapi:
image: strapi/strapi:latest
environment:
DATABASE_CLIENT: postgres
DATABASE_HOST: db
DATABASE_PORT: 5432
DATABASE_NAME: strapi
DATABASE_USERNAME: strapi
DATABASE_PASSWORD: your-secure-password
ports:
- '1337:1337'
volumes:
- ./app:/srv/app
depends_on:
- db
db:
image: postgres:15
environment:
POSTGRES_DB: strapi
POSTGRES_USER: strapi
POSTGRES_PASSWORD: your-secure-password
volumes:
- ./data:/var/lib/postgresql/data
your-secure-password in both locations to a strong password. This secures your database connection.Ctrl+X, then Y, then Enter to save the file and close the editor.docker-compose up -d to download the images and start both services in the background.Strapi is now running on port 1337. The database stores its data in the ./data directory, which persists between container restarts.
You need to complete Strapi’s initial setup and create a content type before you can build your Astro frontend. This establishes the API structure that Astro will consume.
http://your-server-ip:1337/admin replacing your-server-ip with your VPS IP address.Your content is now available via Strapi’s REST API at http://your-server-ip:1337/api/articles. Astro will fetch from this endpoint to build your pages.
Astro fetches content from Strapi during the build process and generates static HTML files. You will create a basic site structure and configure it to pull from your Strapi API.
npm create astro@latest frontend and follow the prompts. Choose the “Empty” template when asked.cd frontend && npm install to install the required packages.nano src/pages/index.astro and add code to fetch and display your articles from the Strapi API..env file with STRAPI_URL=http://your-server-ip:1337 to store your Strapi endpoint. Replace your-server-ip with your actual IP address.npm run build to generate static files in the dist directory. Astro fetches your content and creates HTML pages at build time.dist to your web server directory or configure Nginx to serve them. Your static site is now live.When you publish new content in Strapi, rebuild your Astro site to regenerate the static files with updated content. Your setup now separates content management from frontend delivery.
You have deployed a modern website using Strapi for content management and Astro for frontend delivery. Your setup separates content from presentation, generates static HTML for fast loading and keeps your admin interface isolated from your public site.
Monitor your Docker containers with docker-compose logs and set up automated backups of the ./data directory. Our VPS hosting gives you full control over your server environment for custom deployments like this.
If you run into any trouble, get in touch and our team will be happy to help.
Get scalable resources with our VPS hosting with root access and optional software.
Get VPS HostingPerfect for websites and small businesses unlimited bandwidth with cPanel hosting.
Get cPanel Hosting