Added Docker

This commit is contained in:
Tiemen van Olst
2025-09-09 08:52:28 +02:00
parent 7f1595dddd
commit 72d9f5e642
29 changed files with 10623 additions and 193 deletions

175
README.md
View File

@@ -1,75 +1,144 @@
# Nuxt UI Starter
# Nuxt 4 met Database
Look at [Nuxt docs](https://nuxt.com/docs/getting-started/introduction) and [Nuxt UI docs](https://ui.nuxt.com) to learn more.
Een moderne Nuxt 4 applicatie met PostgreSQL database, draaiend via Docker Compose.
## Setup
## Features
Make sure to install the dependencies:
- 🚀 Nuxt 4 met TypeScript
- 🐘 PostgreSQL database
- 🐳 Docker & Docker Compose
- 🎨 Tailwind CSS voor styling
- 📊 Sequelize ORM voor database management
- 🔄 API routes voor CRUD operaties
## Quick Start
### 1. Clone en setup
```bash
# npm
git clone <repository-url>
cd nuxt-deploy
```
### 2. Start met Docker Compose
```bash
docker-compose up --build
```
### 3. Database migratie (eerste keer)
```bash
# In een nieuwe terminal
docker-compose exec nuxt-app npm run db:migrate
```
### 4. Open de applicatie
Ga naar [http://localhost:3000](http://localhost:3000)
## Development
### Lokale development (zonder Docker)
```bash
# Installeer dependencies
npm install
# pnpm
pnpm install
# Start PostgreSQL (via Docker)
docker-compose up postgres -d
# yarn
yarn install
# Setup database
npm run db:migrate
# bun
bun install
```
## Development Server
Start the development server on `http://localhost:3000`:
```bash
# npm
# Start development server
npm run dev
# pnpm
pnpm run dev
# yarn
yarn dev
# bun
bun run dev
```
## Production
### Database management
```bash
# Run migrations
npm run db:migrate
Build the application for production:
# Create database
npm run db:create
# Seed database
npm run db:seed
```
## API Endpoints
### Users
- `GET /api/users` - Alle gebruikers ophalen
- `POST /api/users` - Nieuwe gebruiker aanmaken
### Posts
- `GET /api/posts` - Alle posts ophalen
- `POST /api/posts` - Nieuwe post aanmaken
## Database Schema
### User
- `id` (Int, Primary Key)
- `email` (String, Unique)
- `name` (String, Optional)
- `createdAt` (DateTime)
- `updatedAt` (DateTime)
### Post
- `id` (Int, Primary Key)
- `title` (String)
- `content` (String, Optional)
- `published` (Boolean, Default: false)
- `authorId` (Int, Foreign Key)
- `createdAt` (DateTime)
- `updatedAt` (DateTime)
## Docker Services
- **nuxt-app**: Nuxt 4 applicatie (poort 3000)
- **postgres**: PostgreSQL database (poort 5432)
## Environment Variables
Kopieer `env.example` naar `.env` en pas aan indien nodig:
```bash
# npm
npm run build
# pnpm
pnpm run build
# yarn
yarn build
# bun
bun run build
cp env.example .env
```
Locally preview production build:
## Troubleshooting
### Database connection issues
```bash
# npm
npm run preview
# Check of PostgreSQL draait
docker-compose ps
# pnpm
pnpm run preview
# yarn
yarn preview
# bun
bun run preview
# Check logs
docker-compose logs postgres
```
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
### Sequelize issues
```bash
# Run migrations
docker-compose exec nuxt-app npm run db:migrate
# Reset en herstart database
docker-compose down -v
docker-compose up --build
```
## Production Deployment
Voor productie deployment:
1. Update `docker-compose.yml` met productie instellingen
2. Gebruik environment variables voor secrets
3. Setup reverse proxy (nginx)
4. Configure SSL certificaten
5. Setup database backups
## Tech Stack
- **Frontend**: Nuxt 4, Vue 3, TypeScript
- **Backend**: Nuxt Server API
- **Database**: PostgreSQL 15
- **ORM**: Sequelize
- **Styling**: Tailwind CSS
- **Containerization**: Docker & Docker Compose