Skip to content

Commit

Permalink
feat: add docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
pushpak1300 committed Jan 11, 2025
1 parent 1155c1f commit adf9420
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 2 deletions.
67 changes: 67 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Stage 1: Frontend Assets build
FROM oven/bun:1-slim AS node-builder
WORKDIR /app
COPY . .
RUN bun install --frozen-lockfile
RUN bun run build

# Stage 2: Final image
FROM dunglas/frankenphp:1.4.0-php8.3-alpine AS base

# Create required directories with proper permissions
RUN mkdir -p /data/caddy /config/caddy /home/.local/share/caddy && \
chmod -R 755 /data /config /home/.local && \
# Add non-root user
addgroup -g 1000 appgroup && \
adduser -u 1000 -G appgroup -h /app -s /bin/sh -D appuser && \
# Give ownership of Caddy directories
chown -R appuser:appgroup /data /config /home/.local

# Set Caddy environment variables
ENV XDG_CONFIG_HOME=/config \
XDG_DATA_HOME=/data

# Install composer and PHP extensions
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
RUN install-php-extensions \
pcntl \
intl \
pdo_mysql \
zip \
bcmath && \
# Cleanup
rm -rf /tmp/* /var/cache/apk/*

# Environment configuration
ENV APP_ENV=production \
APP_DEBUG=false \
OCTANE_SERVER=frankenphp

# Configure PHP for production
COPY docker/php/production.ini $PHP_INI_DIR/conf.d/
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

# Set up application
WORKDIR /app
COPY --chown=appuser:appgroup . .
COPY --from=node-builder --chown=appuser:appgroup /app/public/build/ ./public/build/

# Install dependencies and optimize
RUN composer install --prefer-dist --optimize-autoloader && \
php artisan optimize && \
php artisan view:cache && \
php artisan config:cache && \
php artisan route:cache && \
php artisan event:cache && \
# Set proper permissions
chown -R appuser:appgroup /app && \
chmod -R 755 storage bootstrap/cache && \
rm -rf tests node_modules docker .git* && \
composer clear-cache

USER appuser

# Expose port
EXPOSE 8000

ENTRYPOINT ["php", "artisan", "octane:start", "--host=0.0.0.0"]
Binary file modified bun.lockb
Binary file not shown.
7 changes: 7 additions & 0 deletions docker/php/production.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; Production PHP configuration
memory_limit = 256M
max_execution_time = 60
opcache.enable=0
opcache.enable_cli=0
realpath_cache_size=4096K
realpath_cache_ttl=600
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"vite": "~6.0.3",
"vue": "^3.5.13",
"vue-sonner": "^1.3.0",
"ziggy-js": "^2.4.2",
"zod": "^3.23.8"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createInertiaApp } from '@inertiajs/vue3'
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'

import { createApp, h } from 'vue'
import { ZiggyVue } from '../../vendor/tightenco/ziggy'
import { ZiggyVue } from 'ziggy-js';
import './bootstrap'
import '../css/app.css'

Expand Down
2 changes: 1 addition & 1 deletion resources/views/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<meta name="twitter:title" content="Larasonic - Your Laravel VILT Boilerplate" />
<meta name="twitter:description" content="A modern Laravel boilerplate that boosts your developer experience with built-in tools and integrations. Clone and start building!" />
<meta name="twitter:image" content="https://larasonic.com/images/og.webp" />
<meta name="twitter:site" content="@YourTwitterHandle" />
<meta name="twitter:site" content="@pushpak1300" />

<!-- Scripts -->
@routes
Expand Down

0 comments on commit adf9420

Please sign in to comment.