-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (52 loc) · 2.6 KB
/
Copy pathDockerfile
File metadata and controls
70 lines (52 loc) · 2.6 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
69
70
# syntax=docker/dockerfile:1
###############################################################################
# Stage 1 — Build the front-end assets with Vite
###############################################################################
FROM node:22-alpine AS frontend
WORKDIR /app
# Install JS deps first (cached unless the lockfile changes)
COPY package.json package-lock.json ./
RUN npm ci
# Copy the sources Vite needs and build the production bundle into public/build
COPY vite.config.ts tsconfig.json components.json ./
COPY resources ./resources
COPY public ./public
RUN npm run build
###############################################################################
# Stage 2 — PHP runtime that serves the Laravel app
###############################################################################
FROM php:8.4-cli AS app
# PHP extensions Laravel needs + pdo_sqlite for the SQLite database.
# (mlocati installer pulls in the right system libs automatically.)
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN install-php-extensions pdo_sqlite mbstring bcmath zip intl gd
# Composer binary from the official image
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
WORKDIR /var/www/html
# Install PHP dependencies first (cached unless composer files change).
# Scripts are deferred until the full app is copied in.
COPY composer.json composer.lock ./
RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --no-interaction
# Copy the application source
COPY . .
# Bring in the compiled front-end assets from the frontend stage
COPY --from=frontend /app/public/build ./public/build
# Finish composer setup (autoloader + package discovery) now that app is present
RUN composer dump-autoload --optimize --no-dev \
&& composer run-script post-autoload-dump || true
# Ship a working .env (key is generated at first boot by the entrypoint)
RUN cp .env.example .env
# Laravel needs to write to storage/ and bootstrap/cache/ at runtime
RUN mkdir -p storage/framework/{cache/data,sessions,views} storage/logs \
&& chown -R www-data:www-data storage bootstrap/cache database \
&& chmod -R 775 storage bootstrap/cache database
ENV APP_ENV=production \
APP_DEBUG=false \
APP_URL=http://localhost:8080 \
DB_CONNECTION=sqlite \
DB_DATABASE=/var/www/html/database/database.sqlite
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
EXPOSE 8080
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8080"]