2025-01-28 17:52:48 +01:00
---
title: "Docker Development Setup"
description: "Set up OpnForm locally for development using Docker"
---
import CloudVersion from "/snippets/cloud-version.mdx";
<CloudVersion/>
## Overview
2025-01-29 18:20:19 +01:00
OpnForm provides a minimal Docker-based development environment optimized for local development. While the full architecture is detailed in our [Docker Deployment](/deployment/docker) guide, the development setup is intentionally lighter and focused on developer experience.
2025-01-28 17:52:48 +01:00
## Prerequisites
- Docker and Docker Compose installed on your machine
- Git installed
- Basic understanding of Docker concepts
## Quick Start
1. Clone the repository:
```bash
git clone https://github.com/JhumanJ/OpnForm.git
cd OpnForm
```
2025-01-29 16:00:01 +01:00
2. Run the setup script in development mode:
2025-01-28 17:52:48 +01:00
```bash
2025-01-29 16:00:01 +01:00
chmod +x scripts/docker-setup.sh
./scripts/docker-setup.sh --dev
2025-01-28 17:52:48 +01:00
```
2025-01-29 16:00:01 +01:00
This script will:
- Create necessary environment files
- Pull or build required Docker images
- Start all containers in development mode
- Display access information
2025-01-28 17:52:48 +01:00
2025-01-29 16:00:01 +01:00
3. Access your development environment:
2025-01-28 17:52:48 +01:00
- Frontend: http://localhost:3000
- API: http://localhost/api
### Initial Login
After starting the development environment, use these credentials to access the app:
- Email: `admin@opnform.com`
- Password: `password`
You will be prompted to change your email and password after your first login.
<Note>Public registration is disabled in the self-hosted version. Use the admin account to invite additional users.</Note>
2025-01-29 18:20:19 +01:00
## Architecture
While the full architecture is detailed in our [Docker Deployment](/deployment/docker) guide, the development setup is intentionally lighter and focused on developer experience.
### Differences from Production
- **No Redis**: Uses file-based caching and sessions instead
- Simpler setup
- No additional service to maintain
- Slightly slower but sufficient for development
- **No Queue Workers**: Uses synchronous job processing
- Jobs run immediately in the main process
- Easier debugging of background tasks
- No need to restart workers after code changes
- **No Scheduler**: Scheduled tasks don't run automatically
- Run scheduled tasks manually when needed
- Less resource usage
- Cleaner logs
2025-01-28 17:52:48 +01:00
2025-01-29 18:20:19 +01:00
### Development Features
2025-01-28 17:52:48 +01:00
2025-01-29 18:20:19 +01:00
The development setup includes:
#### Frontend Development
2025-01-29 16:00:01 +01:00
- **Hot Module Replacement (HMR)**: Changes to Vue components and styles are instantly reflected without page reload
- **Vue DevTools**: Full integration for component inspection and state management debugging ([learn more](https://devtools.vuejs.org/))
- **Source Maps**: Enabled for easier debugging
- **Fast Refresh**: Preserves component state during updates
- **Error Overlay**: Displays errors directly in the browser
2025-01-28 17:52:48 +01:00
2025-01-29 18:20:19 +01:00
#### Backend Development
2025-01-29 16:00:01 +01:00
- **PHP Hot Reload**: Changes to PHP files are immediately available
- **Xdebug Integration**: Ready for step-by-step debugging
- **Artisan Commands**: Direct access to Laravel's CLI tools
2025-01-28 17:52:48 +01:00
2025-01-29 16:00:01 +01:00
### Development URLs
- **Frontend**: http://localhost:3000
- Direct access to Nuxt dev server
- Includes HMR websocket connection
- Vue DevTools available
- **API**: http://localhost/api
- Handled by Nginx reverse proxy
- Automatic routing to PHP-FPM
- Supports file uploads and long requests
## File Structure
The development setup mounts your local directories into the containers:
```
OpnForm/
├── api/ # Laravel API (mounted to api container)
│ ├── vendor/ # Preserved in container
│ └── storage/ # Mounted for logs and uploads
├── client/ # Nuxt frontend (mounted to ui container)
│ └── node_modules/ # Preserved in container
└── docker/ # Docker configuration files
```
2025-01-28 17:52:48 +01:00
## Common Tasks
### Running Commands
To run commands in the containers:
```bash
# Laravel Artisan commands
2025-01-29 18:20:19 +01:00
docker compose -f docker-compose.dev.yml exec api php artisan [command]
2025-01-28 17:52:48 +01:00
# NPM commands
2025-01-29 18:20:19 +01:00
docker compose -f docker-compose.dev.yml exec ui npm [command]
2025-01-29 16:00:01 +01:00
# Database commands
2025-01-29 18:20:19 +01:00
docker compose -f docker-compose.dev.yml exec db psql -U forge
2025-01-28 17:52:48 +01:00
```
### Accessing Logs
View container logs:
```bash
# All containers
2025-01-29 18:20:19 +01:00
docker compose -f docker-compose.dev.yml logs -f
2025-01-28 17:52:48 +01:00
2025-01-29 16:00:01 +01:00
# Specific container (e.g., frontend)
2025-01-29 18:20:19 +01:00
docker compose -f docker-compose.dev.yml logs -f ui
2025-01-28 17:52:48 +01:00
```
2025-01-29 16:00:01 +01:00
### Database Access
2025-01-28 17:52:48 +01:00
The PostgreSQL database is accessible:
- From containers: `host=db`
- From your machine: `localhost:5432`
2025-01-29 16:00:01 +01:00
- Default credentials:
```
Host: localhost
Port: 5432
Database: forge
Username: forge
Password: forge
```
2025-01-28 17:52:48 +01:00
## Troubleshooting
### Container Issues
If containers aren't starting properly:
```bash
2025-01-29 16:00:01 +01:00
# Clean everything and restart
./scripts/docker-setup.sh --dev
2025-01-28 17:52:48 +01:00
```
### Permission Issues
2025-01-29 16:00:01 +01:00
If you encounter permission issues:
2025-01-28 17:52:48 +01:00
```bash
# Fix storage permissions
2025-01-29 18:20:19 +01:00
docker compose -f docker-compose.dev.yml exec api chmod -R 775 storage
2025-01-28 17:52:48 +01:00
# Fix vendor permissions
2025-01-29 18:20:19 +01:00
docker compose -f docker-compose.dev.yml exec api chmod -R 775 vendor
2025-01-29 16:00:01 +01:00
```
### HMR Issues
If hot reload isn't working:
1. Check browser console for WebSocket errors
2. Ensure ports 3000 and 24678 are available
3. Try restarting the UI container:
```bash
2025-01-29 18:20:19 +01:00
docker compose -f docker-compose.dev.yml restart ui
2025-02-27 08:55:50 +01:00
```
## Environment Variables
For detailed information about environment variables and how to update them in Docker, see our [Environment Variables](/configuration/environment-variables#docker-environment-variables) documentation.