Skip to content

Commit

Permalink
Finish dockerization feature and configure vite hot reload and host
Browse files Browse the repository at this point in the history
  • Loading branch information
perisicnikola37 committed Mar 13, 2024
1 parent 7f10a84 commit 39871ba
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
25 changes: 14 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM php:8.2-cli

WORKDIR /var/www/html

# Install system dependencies
RUN apt-get update && apt-get install -y \
curl \
libpng-dev \
Expand All @@ -11,30 +12,32 @@ RUN apt-get update && apt-get install -y \
zip \
unzip \
nodejs \
npm
npm \
&& rm -rf /var/lib/apt/lists/*

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

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

# Copy composer files and install dependencies
COPY composer.json composer.lock ./

RUN composer install --no-scripts --no-autoloader

# Copy the rest of the application files
COPY . .

# Generate autoload files
RUN composer dump-autoload

RUN apt-get update && apt-get install -y \
nodejs \
npm

RUN npm install

RUN php artisan config:clear
# Install npm packages and build
RUN npm install && npm run build

# Expose ports for both PHP and npm servers
EXPOSE 9000
EXPOSE 5173

CMD php artisan serve --host=0.0.0.0 --port=9000

# Set up command to run both services
CMD php artisan serve --host=0.0.0.0 --port=9000 & npm run dev --host 0.0.0.0 --port 5173
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"scripts": {
"dev": "vite",
"dev": "vite --host",
"build": "vite build"
},
"devDependencies": {
Expand Down
9 changes: 9 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';

export default defineConfig({
server: {
host: '0.0.0.0',
hmr: {
host: 'localhost',
},
watch: {
usePolling: true
}
},
plugins: [
laravel({
input: 'resources/js/app.js',
Expand Down

0 comments on commit 39871ba

Please sign in to comment.