-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (51 loc) · 1.64 KB
/
Copy pathDockerfile
File metadata and controls
65 lines (51 loc) · 1.64 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
# ============================================
# Stage 1: Build Frontend
# ============================================
FROM node:20-alpine AS frontend-builder
WORKDIR /build
COPY ./frontend .
RUN npm install
RUN npm run build
# ============================================
# Stage 2: Build Backend (PHP-FPM + Frontend)
# ============================================
FROM 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 \
sqlite3 \
libsqlite3-dev
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN docker-php-ext-install pdo_sqlite mbstring exif pcntl bcmath gd
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Set working directory
WORKDIR /var/www/html
# Copy backend application files
COPY ./backend .
# Copy frontend build output to Laravel public directory
COPY --from=frontend-builder /build/dist /var/www/html/public/dist
# Install PHP dependencies
RUN composer install --no-dev --optimize-autoloader --no-interaction
# Copy entrypoint script
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Create necessary directories and set permissions
RUN mkdir -p storage/framework/{sessions,views,cache} \
&& mkdir -p storage/logs \
&& mkdir -p bootstrap/cache \
&& mkdir -p public/dist \
&& chown -R www-data:www-data storage bootstrap/cache public \
&& chmod -R 775 storage bootstrap/cache public
# Expose PHP-FPM port
EXPOSE 9000
# Set entrypoint
ENTRYPOINT ["docker-entrypoint.sh"]