fix styling and try optimize dockerfile
This commit is contained in:
44
Dockerfile
44
Dockerfile
@@ -9,7 +9,6 @@ RUN apt-get update && apt-get install -y \
|
||||
curl \
|
||||
libcurl4-openssl-dev \
|
||||
pkg-config \
|
||||
libpng-dev \
|
||||
libonig-dev \
|
||||
libxml2-dev \
|
||||
libzip-dev \
|
||||
@@ -47,39 +46,38 @@ RUN pecl install redis \
|
||||
# Install Composer
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# Copy existing application directory contents
|
||||
COPY . /var/www/html
|
||||
# Copy only composer files first for caching
|
||||
COPY composer.json composer.lock ./
|
||||
|
||||
# Copy existing application directory permissions
|
||||
COPY --chown=www-data:www-data . /var/www/html
|
||||
# Copy only npm files first for caching
|
||||
COPY package.json package-lock.json ./
|
||||
|
||||
# Install PHP dependencies
|
||||
# Now copy the full Laravel application code
|
||||
COPY . .
|
||||
|
||||
# Install PHP dependencies (cached if lock file unchanged)
|
||||
RUN composer install --optimize-autoloader --no-dev --no-interaction
|
||||
|
||||
# Install Node.js dependencies and build assets
|
||||
RUN npm ci \
|
||||
&& npm run production \
|
||||
&& rm -rf node_modules
|
||||
RUN npm ci && npm run production && rm -rf node_modules
|
||||
|
||||
# Create necessary directories and set permissions
|
||||
RUN mkdir -p /var/www/html/storage/logs \
|
||||
&& mkdir -p /var/www/html/storage/framework/cache \
|
||||
&& mkdir -p /var/www/html/storage/framework/sessions \
|
||||
&& mkdir -p /var/www/html/storage/framework/views \
|
||||
&& mkdir -p /var/www/html/storage/app \
|
||||
&& mkdir -p /var/www/html/bootstrap/cache \
|
||||
# Set proper permissions (for production only do this once)
|
||||
RUN mkdir -p storage/logs \
|
||||
&& mkdir -p storage/framework/{cache,sessions,views} \
|
||||
&& mkdir -p storage/app \
|
||||
&& mkdir -p bootstrap/cache \
|
||||
&& chown -R www-data:www-data /var/www/html \
|
||||
&& chmod -R 775 /var/www/html/storage \
|
||||
&& chmod -R 775 /var/www/html/bootstrap/cache \
|
||||
&& chmod -R 755 /var/www/html/public
|
||||
&& chmod -R 775 storage \
|
||||
&& chmod -R 775 bootstrap/cache \
|
||||
&& chmod -R 755 public
|
||||
|
||||
# Create nginx config
|
||||
# Nginx config
|
||||
COPY ./docker/nginx.conf /etc/nginx/sites-available/default
|
||||
|
||||
# Create supervisor config
|
||||
# Supervisor config
|
||||
COPY ./docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||
|
||||
# Expose port 9000 and start php-fpm server
|
||||
# Expose web port
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|
||||
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|
||||
|
||||
Reference in New Issue
Block a user