Skip to content

Commit 39871ba

Browse files
Finish dockerization feature and configure vite hot reload and host
1 parent 7f10a84 commit 39871ba

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

Dockerfile

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ FROM php:8.2-cli
22

33
WORKDIR /var/www/html
44

5+
# Install system dependencies
56
RUN apt-get update && apt-get install -y \
67
curl \
78
libpng-dev \
@@ -11,30 +12,32 @@ RUN apt-get update && apt-get install -y \
1112
zip \
1213
unzip \
1314
nodejs \
14-
npm
15+
npm \
16+
&& rm -rf /var/lib/apt/lists/*
1517

18+
# Install PHP extensions
1619
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
1720
&& docker-php-ext-install -j$(nproc) gd pdo pdo_mysql zip
1821

22+
# Install Composer
1923
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
2024

25+
# Copy composer files and install dependencies
2126
COPY composer.json composer.lock ./
22-
2327
RUN composer install --no-scripts --no-autoloader
2428

29+
# Copy the rest of the application files
2530
COPY . .
2631

32+
# Generate autoload files
2733
RUN composer dump-autoload
2834

29-
RUN apt-get update && apt-get install -y \
30-
nodejs \
31-
npm
32-
33-
RUN npm install
34-
35-
RUN php artisan config:clear
35+
# Install npm packages and build
36+
RUN npm install && npm run build
3637

38+
# Expose ports for both PHP and npm servers
3739
EXPOSE 9000
40+
EXPOSE 5173
3841

39-
CMD php artisan serve --host=0.0.0.0 --port=9000
40-
42+
# Set up command to run both services
43+
CMD php artisan serve --host=0.0.0.0 --port=9000 & npm run dev --host 0.0.0.0 --port 5173

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"scripts": {
4-
"dev": "vite",
4+
"dev": "vite --host",
55
"build": "vite build"
66
},
77
"devDependencies": {

vite.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ import laravel from 'laravel-vite-plugin';
33
import vue from '@vitejs/plugin-vue';
44

55
export default defineConfig({
6+
server: {
7+
host: '0.0.0.0',
8+
hmr: {
9+
host: 'localhost',
10+
},
11+
watch: {
12+
usePolling: true
13+
}
14+
},
615
plugins: [
716
laravel({
817
input: 'resources/js/app.js',

0 commit comments

Comments
 (0)