Dev server via podman

This commit is contained in:
myrmidex 2025-07-29 21:27:19 +02:00
parent d0f54fcf9c
commit 24143d53ac
10 changed files with 242 additions and 4 deletions

View file

@ -57,10 +57,10 @@ #### Docker
```bash
# Using Docker Compose
docker-compose -f docker/docker-compose.yml up --build
docker-compose -f docker/production/docker-compose.yml up --build
# Or using Podman Compose
podman-compose -f docker/docker-compose.yml up --build
podman-compose -f docker/production/docker-compose.yml up --build
```
The application will be available at `http://localhost:5001`.
@ -68,7 +68,9 @@ # Or using Podman Compose
### Development
#### Local Development Setup
I snoone diffone
**Option 1: Laravel Sail (Docker)**
For local development with Laravel Sail:
```bash
@ -87,13 +89,47 @@ # Run migrations
sail artisan migrate
```
**Option 2: Podman Development**
For Fedora Atomic or other Podman-based systems:
```bash
# Quick start with helper script
bash docker/dev/podman/start-dev.sh
# Or manually:
# Install podman-compose if not available
pip3 install --user podman-compose
# Start development environment
podman-compose -f docker/dev/podman/docker-compose.yml up -d
# Run migrations
podman exec incr-dev-app php artisan migrate
```
**Option 3: Sail with Podman (Compatibility Layer)**
To use Laravel Sail commands with Podman:
```bash
# Source the alias script
source docker/dev/podman/podman-sail-alias.sh
# Now you can use sail commands as normal
sail up -d
sail artisan migrate
sail npm run dev
```
The development server will be available at `http://localhost` with hot reload enabled.
## Project Structure
- `app/` - Laravel backend (controllers, models, services)
- `resources/js/` - React frontend components and pages
- `docker/` - Production Docker configuration
- `docker/production/` - Production Docker configuration
- `docker/dev/podman/` - Development Podman configuration
- `database/migrations/` - Database schema definitions
## Contributing

View file

@ -0,0 +1,52 @@
FROM docker.io/library/php:8.2-fpm
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
unzip \
nodejs \
npm \
default-mysql-client \
&& docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Set working directory
WORKDIR /var/www/html
# Install Node.js 20.x (for better compatibility)
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs
# Copy composer files and install PHP dependencies
COPY composer.json composer.lock ./
RUN composer install --no-dev --optimize-autoloader --no-scripts
# Copy package.json and install Node dependencies
COPY package*.json ./
RUN npm ci
# Copy application code
COPY . .
# Set permissions
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html/storage \
&& chmod -R 755 /var/www/html/bootstrap/cache
# Create start script
RUN echo '#!/bin/bash\n\
php artisan serve --host=0.0.0.0 --port=8000 &\n\
npm run dev -- --host 0.0.0.0\n\
wait' > /usr/local/bin/start-dev.sh \
&& chmod +x /usr/local/bin/start-dev.sh
EXPOSE 8000 5173
CMD ["/usr/local/bin/start-dev.sh"]

View file

@ -0,0 +1,72 @@
version: '3.8'
services:
app:
build:
context: ../../..
dockerfile: docker/dev/podman/Dockerfile
container_name: incr-dev-app
restart: unless-stopped
working_dir: /var/www/html
environment:
- APP_ENV=local
- APP_DEBUG=true
- APP_KEY=base64:YOUR_APP_KEY_HERE
- DB_CONNECTION=mysql
- DB_HOST=db
- DB_PORT=3306
- DB_DATABASE=incr_dev
- DB_USERNAME=incr_user
- DB_PASSWORD=incr_password
- VITE_PORT=5173
volumes:
- ../../../:/var/www/html:Z
- /var/www/html/node_modules
- /var/www/html/vendor
ports:
- "8000:8000"
- "5173:5173"
depends_on:
db:
condition: service_healthy
networks:
- incr-dev-network
db:
image: docker.io/library/mysql:8.0
container_name: incr-dev-db
restart: unless-stopped
environment:
- MYSQL_DATABASE=incr_dev
- MYSQL_USER=incr_user
- MYSQL_PASSWORD=incr_password
- MYSQL_ROOT_PASSWORD=root_password
volumes:
- db_data:/var/lib/mysql
ports:
- "3307:3306"
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "incr_user", "-pincr_password"]
timeout: 10s
retries: 10
interval: 10s
start_period: 10s
networks:
- incr-dev-network
redis:
image: docker.io/library/redis:7-alpine
container_name: incr-dev-redis
restart: unless-stopped
ports:
- "6379:6379"
networks:
- incr-dev-network
networks:
incr-dev-network:
driver: bridge
volumes:
db_data:
driver: local

View file

@ -0,0 +1,26 @@
#!/bin/bash
# Podman aliases for Laravel Sail compatibility
# Source this file to use Sail commands with Podman
# Usage: source docker/dev/podman/podman-sail-alias.sh
# Create docker alias pointing to podman
alias docker='podman'
# Create docker-compose alias pointing to podman-compose
alias docker-compose='podman-compose'
# Sail wrapper function that uses podman-compose
sail() {
if [[ -f docker/dev/podman/docker-compose.yml ]]; then
podman-compose -f docker/dev/podman/docker-compose.yml "$@"
else
echo "❌ Podman compose file not found at docker/dev/podman/docker-compose.yml"
return 1
fi
}
echo "✅ Podman aliases set up for Laravel Sail compatibility"
echo "🐳 'docker' → 'podman'"
echo "🔧 'docker-compose' → 'podman-compose'"
echo "⛵ 'sail' → uses podman-compose with dev configuration"

View file

@ -0,0 +1,52 @@
#!/bin/bash
# Podman development environment startup script for incr
set -e
echo "🚀 Starting incr development environment with Podman..."
# Check if .env exists
if [ ! -f .env ]; then
echo "📋 Creating .env file from .env.example..."
cp .env.example .env
echo "⚠️ Please update your .env file with appropriate values, especially APP_KEY"
fi
# Check if podman-compose is available
if ! command -v podman-compose &> /dev/null; then
echo "❌ podman-compose not found. Installing..."
pip3 install --user podman-compose
echo "✅ podman-compose installed"
fi
# Start services
echo "🔧 Starting services..."
podman-compose -f docker/dev/podman/docker-compose.yml up -d
# Wait for database to be ready
echo "⏳ Waiting for database to be ready..."
sleep 10
# Check if APP_KEY is set
if grep -q "APP_KEY=base64:YOUR_APP_KEY_HERE" .env || grep -q "APP_KEY=$" .env; then
echo "🔑 Generating application key..."
podman exec incr-dev-app php artisan key:generate
fi
# Run migrations
echo "🗃️ Running database migrations..."
podman exec incr-dev-app php artisan migrate
# Install/update dependencies if needed
echo "📦 Installing dependencies..."
podman exec incr-dev-app composer install
podman exec incr-dev-app npm install
echo "✅ Development environment is ready!"
echo "🌐 Application: http://localhost:8000"
echo "🔥 Vite dev server: http://localhost:5173"
echo "💾 Database: localhost:3307"
echo ""
echo "To stop: podman-compose -f docker/dev/podman/docker-compose.yml down"
echo "To view logs: podman-compose -f docker/dev/podman/docker-compose.yml logs -f"