2024-09-02 15:33:17 +02:00
---
2025-01-28 17:52:48 +01:00
title: "Docker Deployment"
description: "Deploy OpnForm using Docker"
2024-09-02 15:33:17 +02:00
---
import CloudVersion from "/snippets/cloud-version.mdx";
<CloudVersion/>
2025-01-28 17:52:48 +01:00
<Tip>
2025-01-29 16:00:01 +01:00
Looking to develop OpnForm locally? Check out our [Docker Development Setup](/deployment/docker-development) guide which provides hot-reload and other development features.
2025-01-28 17:52:48 +01:00
</Tip>
2024-09-02 15:33:17 +02:00
## 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:
2024-09-02 15:33:17 +02:00
```bash
2025-01-29 16:00:01 +01:00
chmod +x scripts/docker-setup.sh
./scripts/docker-setup.sh
2024-09-02 15:33:17 +02:00
```
2025-01-29 16:00:01 +01:00
The script will:
- Create necessary environment files
- Pull required Docker images
- Start all containers in production mode
- Display access information
2024-09-02 15:33:17 +02:00
2025-01-29 16:00:01 +01:00
3. Access your OpnForm instance at `http://localhost`
2024-09-02 15:33:17 +02:00
2024-09-04 12:33:46 +02:00
### Initial Login
2025-01-29 16:00:01 +01:00
After deployment, use these credentials to access the app:
2024-09-04 12:33:46 +02:00
- 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 16:00:01 +01:00
## Architecture
2024-09-02 15:33:17 +02:00
2025-01-29 16:00:01 +01:00
```mermaid
graph TD
A[Nginx Proxy] --> B[Frontend - Nuxt SSR]
A --> C[Backend - Laravel API]
C --> D[PostgreSQL]
C --> E[Redis]
C --> F[Queue Worker]
C --> G[Scheduler]
```
2024-09-02 15:33:17 +02:00
2025-01-29 16:00:01 +01:00
### Components
<Tabs>
<Tab title="Frontend">
The Nuxt frontend service:
- Server-Side Rendered application
- Built with Vue 3 and Tailwind CSS
- Handles dynamic rendering and client-side interactivity
- Optimized for production performance
</Tab>
<Tab title="Backend">
The Laravel API service:
- Handles business logic and data persistence
- Provides REST API endpoints
- Manages file uploads and processing
- Includes required PHP extensions (pgsql, redis, etc.)
- Configured for PostgreSQL and Redis connections
</Tab>
<Tab title="Workers">
Background processing services:
- **API Worker**: Processes queued jobs (emails, exports, etc.)
- **API Scheduler**: Handles scheduled tasks and periodic cleanups
- Both share the same codebase as the main API
</Tab>
<Tab title="Databases">
Data storage services:
- **PostgreSQL**: Primary database for all application data
- **Redis**: Used for:
- Session storage
- Cache
- Queue management
- Real-time features
</Tab>
<Tab title="Proxy">
The Nginx proxy service:
- Routes requests between frontend and backend
- Handles SSL termination
- Manages file upload limits
- Serves static assets
- Configured for optimal performance
</Tab>
</Tabs>
2024-09-02 15:33:17 +02:00
2025-01-29 16:00:01 +01:00
## Docker Images
2024-09-02 15:33:17 +02:00
2025-01-29 16:00:01 +01:00
OpnForm provides pre-built Docker images for easy deployment:
2024-09-02 15:33:17 +02:00
2025-01-29 16:00:01 +01:00
- [OpnForm API Image](https://hub.docker.com/r/jhumanj/opnform-api)
- [OpnForm Client Image](https://hub.docker.com/r/jhumanj/opnform-client)
2025-01-28 12:56:01 +01:00
2025-01-29 16:00:01 +01:00
### Building Custom Images
2025-01-28 12:56:01 +01:00
2025-01-29 16:00:01 +01:00
While we recommend using the official images, you can build custom images if needed:
2025-01-28 12:56:01 +01:00
```bash
2025-01-29 16:00:01 +01:00
# Build all images
2025-01-28 12:56:01 +01:00
docker compose build
2025-01-29 16:00:01 +01:00
# Or build specific images
docker build -t opnform-api:local -f docker/Dockerfile.api .
docker build -t opnform-ui:local -f docker/Dockerfile.client .
2025-01-28 12:56:01 +01:00
```
2025-01-29 16:00:01 +01:00
### Custom Configuration
Create a `docker-compose.override.yml` to customize your deployment:
2025-01-28 12:56:01 +01:00
2025-01-29 16:00:01 +01:00
```yaml
services:
api:
image: opnform-api:local
environment:
PHP_MEMORY_LIMIT: 1G
ui:
image: opnform-ui:local
ingress:
volumes:
- ./custom-nginx.conf:/etc/nginx/conf.d/default.conf
2025-01-28 12:56:01 +01:00
```
2025-01-29 16:00:01 +01:00
## Maintenance
2025-01-28 12:56:01 +01:00
2025-01-29 16:00:01 +01:00
### Updates
2024-09-02 15:33:17 +02:00
2025-01-29 16:00:01 +01:00
1. Pull latest changes:
2024-09-02 15:33:17 +02:00
```bash
2025-01-29 16:00:01 +01:00
git pull origin main
2024-09-02 15:33:17 +02:00
```
2025-01-29 16:00:01 +01:00
2. Update containers:
2024-09-02 15:33:17 +02:00
```bash
2025-01-29 16:00:01 +01:00
docker compose pull
docker compose up -d
2024-09-02 15:33:17 +02:00
```
2025-01-29 16:00:01 +01:00
### Monitoring
2025-01-28 12:56:01 +01:00
2025-01-29 16:00:01 +01:00
View container logs:
```bash
# All containers
docker compose logs -f
2024-09-02 15:33:17 +02:00
2025-01-29 16:00:01 +01:00
# Specific container
docker compose logs -f api
```
2024-09-02 15:33:17 +02:00
2025-01-29 16:00:01 +01:00
Monitor container health:
```bash
docker compose ps
```
2024-09-02 15:33:17 +02:00
2025-01-29 16:00:01 +01:00
## Troubleshooting
### Container Issues
If containers aren't starting:
```bash
# View detailed logs
docker compose logs -f
# Recreate containers
docker compose down
docker compose up -d
2024-09-02 15:33:17 +02:00
```
2025-01-29 16:00:01 +01:00
### Database Issues
2024-09-02 15:33:17 +02:00
2025-01-29 16:00:01 +01:00
If database connections fail:
```bash
# Check database status
docker compose exec db pg_isready
# View database logs
docker compose logs db
```
2024-09-02 15:33:17 +02:00
2025-01-29 16:00:01 +01:00
### Cache Issues
2024-09-02 15:33:17 +02:00
2025-01-29 16:00:01 +01:00
Clear various caches:
```bash
# Clear application cache
docker compose exec api php artisan cache:clear
# Clear config cache
docker compose exec api php artisan config:clear
# Clear route cache
docker compose exec api php artisan route:clear
2024-09-02 15:33:17 +02:00
```
2025-01-29 16:00:01 +01:00
### Permission Issues
Fix storage permissions:
```bash
docker compose exec api chown -R www-data:www-data storage
docker compose exec api chmod -R 775 storage
2024-09-02 15:33:17 +02:00
```