add docker

This commit is contained in:
Yusron alamsyah
2026-03-26 15:54:08 +07:00
parent 6b49ac859d
commit dc8e9a9208
6 changed files with 230 additions and 4 deletions
+40
View File
@@ -0,0 +1,40 @@
# Git
.git
.gitignore
.gitattributes
# Dependencies
node_modules
npm-debug.log
yarn-error.log
pnpm-debug.log
# Build output
.nuxt
dist
.output
build
# IDE
.vscode
.idea
*.swp
*.swo
*~
.DS_Store
# Environment
.env
.env.local
.env.*.local
# OS
Thumbs.db
# Tests
coverage
.nyc_output
# Documentation
README.md
docs
+1 -3
View File
@@ -5,6 +5,4 @@ node_modules
.cache
.output
.env
dist
Dockerfile
docker-compose.yml
dist
+150
View File
@@ -0,0 +1,150 @@
# Docker Setup untuk Healthcare Admin Dashboard
## Deskripsi
File-file Docker ini memungkinkan Anda menjalankan aplikasi Nuxt 3 healthcare admin dashboard dalam kontainer Docker.
## File-file yang Dibuat
1. **Dockerfile** - Production-ready multistage build
2. **Dockerfile.dev** - Development Dockerfile dengan hot-reload
3. **docker-compose.yml** - Orchestration untuk production dan development
4. **.dockerignore** - Files yang akan diabaikan saat build
## Cara Penggunaan
### 1. Production Build & Run
#### Menggunakan Docker:
```bash
# Build image
docker build -t healthcare-app .
# Run container
docker run -p 3000:3000 \
-e NODE_ENV=production \
-e AUTH_ORIGIN=http://localhost:3005 \
healthcare-app
```
#### Menggunakan Docker Compose:
```bash
# Build dan run
docker-compose up
# Run di background
docker-compose up -d
# Stop
docker-compose down
```
### 2. Development Mode
#### Menggunakan Docker Compose dengan dev profile:
```bash
# Run development container
docker-compose --profile dev up app-dev
# Run di background
docker-compose --profile dev up -d app-dev
# View logs
docker-compose --profile dev logs -f app-dev
# Stop
docker-compose --profile dev down
```
#### Menggunakan Docker Compose untuk development dengan hot-reload:
```bash
# Build dev image
docker build -f Dockerfile.dev -t healthcare-app-dev .
# Run dengan volume mounting untuk hot-reload
docker run -p 3030:3030 \
-v $(pwd):/app \
-v /app/node_modules \
-e NODE_ENV=development \
healthcare-app-dev
```
## Environment Variables
Konfigurasi environment variables sesuai kebutuhan:
- `NODE_ENV` - `production` atau `development` (default: production)
- `HOST` - Hostname untuk bind (default: 0.0.0.0)
- `PORT` - Port server (default: 3000 untuk production, 3030 untuk dev)
- `AUTH_ORIGIN` - URL auth server (default: http://localhost:3005)
### Mengatur Environment di docker-compose.yml:
```yaml
environment:
- NODE_ENV=production
- AUTH_ORIGIN=http://your-auth-server:3005
```
Atau melalui `.env` file:
```bash
# Create .env file di project root
echo "AUTH_ORIGIN=http://localhost:3005" > .env
```
## Build & Push ke Registry (Opsional)
```bash
# Build dengan tag
docker build -t your-registry/healthcare-app:latest .
# Push ke registry
docker push your-registry/healthcare-app:latest
# Run dari registry
docker run -p 3000:3000 your-registry/healthcare-app:latest
```
## Troubleshooting
### Container gagal start
```bash
# Check logs
docker logs <container-id>
# Run dengan interactive terminal
docker run -it -p 3000:3000 healthcare-app sh
```
### Port sudah terpakai
```bash
# Gunakan port yang berbeda
docker run -p 8000:3000 healthcare-app
```
### Hot-reload tidak berfungsi di development
Pastikan volume mounting sudah di-setup dengan benar:
```bash
docker run -p 3030:3030 \
-v $(pwd):/app \
-v /app/node_modules \
healthcare-app-dev
```
## Performance & Best Practices
1. **Multi-stage build** digunakan untuk mengecilkan ukuran final image
2. **Dumb-init** digunakan untuk signal handling yang proper
3. **.dockerignore** yang optimal untuk mempercepat build
4. Volume mounting untuk development mode dengan hot-reload
## Spesifikasi
- **Base Image**: Node.js 20 Alpine (lightweight)
- **Production Port**: 3000
- **Development Port**: 3030
- **Package Manager**: npm atau yarn
## Notes
- Pastikan Docker dan Docker Compose sudah terinstall
- Untuk Windows, gunakan WSL2 Docker backend
- AUTH_ORIGIN perlu disesuaikan dengan environment/server Anda
+22
View File
@@ -0,0 +1,22 @@
# Development Dockerfile
FROM node:20-alpine
WORKDIR /app
# Install basic tools
RUN apk add --no-cache git
# Copy package files
COPY package.json yarn.lock* package-lock.json* ./
# Install dependencies
RUN npm install --frozen-lockfile || yarn install --frozen-lockfile
# Copy source code
COPY . .
# Expose dev port
EXPOSE 3030
# Run development server
CMD ["npm", "run", "dev"]
+16
View File
@@ -0,0 +1,16 @@
version: '3.8'
services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "3030:3030"
environment:
- NODE_ENV=production
- HOST=0.0.0.0
- PORT=3030
- AUTH_ORIGIN=http://localhost:3005
restart: unless-stopped
container_name: general-template-app
+1 -1
View File
@@ -5,7 +5,7 @@
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev -o --host --port 3005",
"dev": "nuxt dev -o --host --port 3030",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"