Adding Docker
This commit is contained in:
parent
4caa32eac3
commit
6c4f0b62cc
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,3 +11,4 @@ Homestead.json
|
|||||||
Homestead.yaml
|
Homestead.yaml
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
|
*.sqlite
|
||||||
|
69
Dockerfile
Normal file
69
Dockerfile
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
FROM php:7.4-fpm
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
|
WORKDIR /var/www
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN apt-get update \
|
||||||
|
# gd
|
||||||
|
&& apt-get install -y --no-install-recommends build-essential openssl nginx libfreetype6-dev libjpeg-dev libpng-dev libwebp-dev zlib1g-dev libzip-dev gcc g++ make vim unzip curl git jpegoptim optipng pngquant gifsicle locales libonig-dev nodejs npm \
|
||||||
|
&& docker-php-ext-configure gd \
|
||||||
|
&& docker-php-ext-install gd \
|
||||||
|
# gmp
|
||||||
|
&& apt-get install -y --no-install-recommends libgmp-dev \
|
||||||
|
&& docker-php-ext-install gmp \
|
||||||
|
# pdo_mysql
|
||||||
|
&& docker-php-ext-install pdo_mysql mbstring \
|
||||||
|
# pdo
|
||||||
|
&& docker-php-ext-install pdo \
|
||||||
|
# opcache
|
||||||
|
&& docker-php-ext-enable opcache \
|
||||||
|
# zip
|
||||||
|
&& docker-php-ext-install zip \
|
||||||
|
&& apt-get autoclean -y \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
|
&& rm -rf /tmp/pear/
|
||||||
|
|
||||||
|
# Copy files
|
||||||
|
COPY . /var/www
|
||||||
|
|
||||||
|
COPY ./deploy/local.ini /usr/local/etc/php/local.ini
|
||||||
|
|
||||||
|
COPY ./deploy/conf.d/nginx.conf /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
RUN chmod +rwx /var/www
|
||||||
|
|
||||||
|
RUN chmod -R 777 /var/www
|
||||||
|
|
||||||
|
# setup npm
|
||||||
|
RUN npm install -g npm@latest
|
||||||
|
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
# include your other npm run scripts e.g npm rebuild node-sass
|
||||||
|
|
||||||
|
# run your default build command here mine is npm run prod
|
||||||
|
RUN npm run prod
|
||||||
|
|
||||||
|
# setup composer and laravel
|
||||||
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||||
|
|
||||||
|
RUN composer install --working-dir="/var/www"
|
||||||
|
|
||||||
|
RUN composer dump-autoload --working-dir="/var/www"
|
||||||
|
|
||||||
|
RUN php artisan route:clear
|
||||||
|
|
||||||
|
RUN php artisan route:cache
|
||||||
|
|
||||||
|
RUN php artisan config:clear
|
||||||
|
|
||||||
|
RUN php artisan config:cache
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
RUN ["chmod", "+x", "post_deploy.sh"]
|
||||||
|
|
||||||
|
CMD [ "sh", "./post_deploy.sh" ]
|
||||||
|
# CMD php artisan serve --host=127.0.0.1 --port=9000
|
4
deploy/local.ini
Normal file
4
deploy/local.ini
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
upload_max_filesize=40M
|
||||||
|
post_max_size=40M
|
||||||
|
max_execution_time=180
|
||||||
|
memory_limit=-1
|
44
deploy/nginx.conf
Normal file
44
deploy/nginx.conf
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
user root;
|
||||||
|
worker_processes auto;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
access_log /dev/stdout;
|
||||||
|
include mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
server {
|
||||||
|
# we use port 80 here to work with our docker config but you can configure it to any port you want, just remember to update the dockerfile accordingly
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
index index.php index.html;
|
||||||
|
|
||||||
|
# your application here
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
error_log /var/log/nginx/error.log;
|
||||||
|
|
||||||
|
access_log /var/log/nginx/access.log;
|
||||||
|
|
||||||
|
# this should be the path of your public folder in laravel which from our dockerfile it would be /var/www/public
|
||||||
|
root /var/www/public;
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
try_files $uri =404;
|
||||||
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||||
|
fastcgi_pass 127.0.0.1:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
gzip_static on;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
post_deploy.sh
Normal file
8
post_deploy.sh
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# update application cache
|
||||||
|
php artisan optimize
|
||||||
|
|
||||||
|
# start the application
|
||||||
|
|
||||||
|
php-fpm -D && nginx -g "daemon off;"
|
Loading…
Reference in New Issue
Block a user