A minimal Astro starter template, pre-configured with Tailwind CSS and fully containerized using Docker Compose.
Everything runs inside Docker. You do not need Node, NPM, or Yarn installed on your local machine.
-
Start the development environment:
docker compose up -d
The first time you run this, it will take a moment to download the Node image and install dependencies.
-
Open the app: Navigate to http://localhost:4321 in your browser.
The source code is mounted as a volume, so any changes you make in the
src/directory will automatically trigger a hot module reload (HMR) in your browser. -
Stop the environment:
docker compose down
Because the project is entirely containerized, all Yarn or Astro commands must be executed inside the running container.
You can do this using docker compose exec app <command>.
Examples:
-
Install a new dependency:
docker compose exec app yarn add <package-name>
-
Run the Astro CLI (e.g., adding an integration):
docker compose exec app yarn astro add react -
View terminal logs:
docker compose logs -f app
The docker-entrypoint.sh is pre-configured to automatically run Drizzle migrations (drizzle-kit migrate or push) when the container starts, provided you have configured it.
To set up a database:
- Choose your database: PostgreSQL is configured by default in
compose.yamland.env.dist. If you prefer MySQL or SQLite, update yourcompose.yamland theDATABASE_URLin your.env.distfile accordingly (see the dashboard athttp://localhost:4321for exact snippets). - Install dependencies inside the container:
- PostgreSQL:
docker compose exec app yarn add pg && docker compose exec app yarn add -D @types/pg drizzle-kit drizzle-orm - MySQL:
docker compose exec app yarn add mysql2 drizzle-orm && docker compose exec app yarn add -D drizzle-kit - SQLite:
docker compose exec app yarn add @libsql/client drizzle-orm && docker compose exec app yarn add -D drizzle-kit
- PostgreSQL:
- Configure Drizzle: Create a
drizzle.config.tsfile in the project root. The entrypoint waits for this file (anddrizzle-kitin yourpackage.json) to exist before attempting to run database syncs automatically on startup.
The template includes built-in support for running scheduled background tasks using the cron service defined in compose.yaml.
To create and run a cron job:
- Create your job script: Add a TypeScript file to the
src/jobs/directory (e.g.,src/jobs/cleanup.ts). - Automatic Scheduling: On startup,
docker-entrypoint.shscans for.tsfiles directly in thesrc/jobs/directory (this is not recursive - subdirectories are ignored) and automatically schedules each to run every minute (* * * * *). They are executed usingyarn tsx. - View Logs: The output of your cron jobs is piped directly to the container's stdout. You can view the logs in real-time by running:
docker compose logs -f cron
Note: The cron container pauses for 10 seconds upon startup to ensure the primary app container has time to complete any pending database migrations before the jobs begin.
The production environment is configured in compose.prod.yaml and uses a multi-stage Dockerfile to build a static site served via Nginx.
To build and test the production image locally:
docker compose -f compose.yaml -f compose.prod.yaml up --build -d