-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
68 lines (52 loc) · 1.94 KB
/
Dockerfile
File metadata and controls
68 lines (52 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
FROM php:8.4-cli-alpine
LABEL maintainer="Daniel Neto"
LABEL description="Laravel Forge MCP Server"
# Install system dependencies
RUN apk add --no-cache \
git \
unzip \
&& rm -rf /var/cache/apk/*
# Configure PHP for MCP (disable ALL output to stdout)
RUN echo "display_errors = Off" >> /usr/local/etc/php/conf.d/mcp.ini && \
echo "display_startup_errors = Off" >> /usr/local/etc/php/conf.d/mcp.ini && \
echo "log_errors = On" >> /usr/local/etc/php/conf.d/mcp.ini && \
echo "error_log = /dev/stderr" >> /usr/local/etc/php/conf.d/mcp.ini && \
echo "error_reporting = 0" >> /usr/local/etc/php/conf.d/mcp.ini && \
echo "opcache.enable = 1" >> /usr/local/etc/php/conf.d/mcp.ini && \
echo "opcache.enable_cli = 0" >> /usr/local/etc/php/conf.d/mcp.ini
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Set working directory
WORKDIR /app
# Copy composer files first for better caching
COPY composer.json composer.lock ./
# Install PHP dependencies (with caching)
RUN composer install \
--no-dev \
--no-interaction \
--no-progress \
--no-scripts \
--prefer-dist \
--optimize-autoloader
# Copy application code
COPY . .
# Run post-install scripts
RUN composer dump-autoload --optimize
# Create .env from example if not exists
RUN if [ ! -f .env ]; then cp .env.example .env; fi
# Generate application key if not set
RUN php artisan key:generate --ansi --force
# Set permissions
RUN chown -R www-data:www-data /app
# Switch to non-root user for security
USER www-data
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD php artisan --version || exit 1
# Environment for MCP (no stdout pollution)
ENV APP_ENV=production
ENV APP_DEBUG=false
ENV LOG_CHANNEL=stderr
ENV LOG_LEVEL=error
# Run MCP server on stdin/stdout (stderr for any errors)
CMD ["php", "-d", "display_errors=Off", "-d", "error_reporting=0", "artisan", "mcp:start", "forge"]