mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-27 19:51:09 -04:00 
			
		
		
		
	Use multi-stage build for Docker image
1. Allows to build the composer dependencies with official composer img 2. php-fpm --nodaemonize: Force to stay in foreground and ignore daemo- nize option from configuration file
This commit is contained in:
		
							
								
								
									
										38
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								Dockerfile
									
									
									
									
									
								
							| @ -1,23 +1,39 @@ | |||||||
| FROM php:7.2-fpm-alpine | FROM composer as composer | ||||||
|  |  | ||||||
|  | # Copy composer files from project root into composer container's working dir | ||||||
|  | COPY composer.* /app/ | ||||||
|  |   | ||||||
|  | # Run composer to build dependencies in vendor folder | ||||||
|  | RUN set -xe \ | ||||||
|  |   && composer install --no-dev --no-scripts --no-suggest --no-interaction --prefer-dist --optimize-autoloader | ||||||
|  |     | ||||||
|  | # Copy everything from project root into composer container's working dir | ||||||
|  | COPY . /app | ||||||
|  |      | ||||||
|  | # Generated optimized autoload files containing all classes from vendor folder and project itself | ||||||
|  | RUN composer dump-autoload --no-dev --optimize --classmap-authoritative | ||||||
|  |  | ||||||
|  | FROM php:7.4.0-fpm-alpine | ||||||
|  |  | ||||||
| # Use the default production configuration | # Use the default production configuration | ||||||
| RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" | RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" | ||||||
|  |  | ||||||
| RUN apk add --no-cache curl git tar unzip libpng-dev libxml2-dev | RUN apk add --no-cache libpng-dev libxml2-dev && \ | ||||||
|  |     docker-php-ext-install bcmath ctype json gd mbstring pdo pdo_mysql tokenizer xml | ||||||
|  |  | ||||||
| RUN docker-php-ext-install bcmath ctype json gd mbstring pdo pdo_mysql tokenizer xml && \ | # Set container's working dir | ||||||
|     curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \ | WORKDIR /app | ||||||
|     composer --version |   | ||||||
|  | # Copy everything from project root into php container's working dir | ||||||
|  | COPY . /app | ||||||
|  |  | ||||||
| WORKDIR /var/www | # Copy vendor folder from composer container into php container | ||||||
|  | COPY --from=composer /app/vendor /app/vendor | ||||||
|  |  | ||||||
| COPY . /var/www | RUN php artisan config:cache && \ | ||||||
|  |  | ||||||
| RUN composer install --optimize-autoloader && \ |  | ||||||
|     php artisan config:cache && \ |  | ||||||
|     chmod -R 755 storage bootstrap/cache && \ |     chmod -R 755 storage bootstrap/cache && \ | ||||||
|     chown -R www-data:www-data storage |     chown -R www-data:www-data storage | ||||||
|  |  | ||||||
| EXPOSE 9000 | EXPOSE 9000 | ||||||
| CMD ["php-fpm"] | CMD ["php-fpm", "--nodaemonize"] | ||||||
|  |  | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ http { | |||||||
|     server { |     server { | ||||||
|         listen       80 default_server; |         listen       80 default_server; | ||||||
|  |  | ||||||
|         root /var/www/public; |         root /app/public; | ||||||
|         index index.php; |         index index.php; | ||||||
|         charset utf-8; |         charset utf-8; | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user