fix(docker): implement multi-stage build and serve dist folder
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
27
Dockerfile
27
Dockerfile
@@ -1,22 +1,27 @@
|
|||||||
#FROM php:8.0-apache
|
# Stage 1: Build the React Application
|
||||||
|
FROM node:20 AS build
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
RUN npm ci
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Stage 2: Serve the application with Apache
|
||||||
FROM --platform=linux/amd64 php:8.4-apache
|
FROM --platform=linux/amd64 php:8.4-apache
|
||||||
WORKDIR /var/www/html
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
#COPY index.php index.php
|
# Enable necessary Apache modules
|
||||||
|
RUN a2enmod rewrite headers
|
||||||
|
|
||||||
RUN mkdir /app
|
|
||||||
COPY vhost.conf /etc/apache2/sites-available/000-default.conf
|
COPY vhost.conf /etc/apache2/sites-available/000-default.conf
|
||||||
|
|
||||||
# COPY adf/saveData.php /var/www/html/saveData.php
|
# Copy the built application from the build stage
|
||||||
|
COPY --from=build /app/dist /app/dist
|
||||||
|
|
||||||
WORKDIR /app
|
# Ensure correct permissions
|
||||||
|
RUN chown -R www-data:www-data /app
|
||||||
|
|
||||||
COPY . .
|
# Keep original PHP extensions just in case
|
||||||
|
|
||||||
# ADD extras/dockerstart.sh /usr/local/servicemix/bin/
|
|
||||||
# RUN chmod 755 /usr/local/bin/dockerstart.sh
|
|
||||||
|
|
||||||
RUN chown -R www-data:www-data /app && a2enmod rewrite
|
|
||||||
RUN docker-php-ext-install mysqli pdo pdo_mysql
|
RUN docker-php-ext-install mysqli pdo pdo_mysql
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|||||||
13
vhost.conf
13
vhost.conf
@@ -3,13 +3,22 @@ LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so
|
|||||||
|
|
||||||
<VirtualHost *:80>
|
<VirtualHost *:80>
|
||||||
ServerName localhost
|
ServerName localhost
|
||||||
DocumentRoot /app
|
DocumentRoot /app/dist
|
||||||
|
|
||||||
<Directory "/app">
|
<Directory "/app/dist">
|
||||||
Options Indexes FollowSymLinks Includes execCGI
|
Options Indexes FollowSymLinks Includes execCGI
|
||||||
AllowOverride All
|
AllowOverride All
|
||||||
Require all granted
|
Require all granted
|
||||||
allow from all
|
allow from all
|
||||||
|
|
||||||
|
<IfModule mod_rewrite.c>
|
||||||
|
RewriteEngine On
|
||||||
|
RewriteBase /
|
||||||
|
RewriteRule ^index\.html$ - [L]
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteRule . /index.html [L]
|
||||||
|
</IfModule>
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
ErrorLog ${APACHE_LOG_DIR}/error.log
|
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||||
|
|||||||
Reference in New Issue
Block a user