Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
FROM node:17.4-alpine As asset_builder

LABEL maintainer="Supernova3339 <[email protected]>"

LABEL description="Laravel Dockerfile"

WORKDIR /app

COPY ./package.json ./
COPY ./package-lock.json ./
COPY ./vite.config.js ./
COPY ./postcss.config.js ./
COPY ./tailwind.config.js ./
COPY ./resources ./resources

RUN npm install \
&& npm run build


FROM php:fpm-alpine
WORKDIR /var/www/html


COPY --from=asset_builder /app/public/build ./public/build

RUN docker-php-ext-install pdo_mysql \
&& docker-php-ext-install mysqli \
&& docker-php-ext-install opcache \
&& apk add --no-cache \
mariadb-client \
sqlite \
nginx

COPY . ./
RUN cp .env.example .env

RUN mkdir ./database/sqlite \
&& chown -R www-data: /var/www/html \
&& rm -rf ./docker

COPY ./docker/config/laravel-php.ini /usr/local/etc/php/conf.d/laravel-php.ini
COPY ./docker/config/nginx.conf /etc/nginx/nginx.conf
COPY ./docker/config/site-nginx.conf /etc/nginx/http.d/default.conf

RUN chmod +x ./docker-entrypoint.sh

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN chown -R www-data:www-data *
RUN chmod -R 777 storage

EXPOSE 80
USER root
CMD ["./docker-entrypoint.sh"]
23 changes: 23 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

composer install --optimize-autoloader --no-dev
cp /app/vendor /var/www/html/vendor -R
cp /app/bootstrap/cache /var/www/html/bootstrap/cache -R
if [ ! -f /var/www/html/database/sqlite/laravel.db ]; then
touch /var/www/html/database/sqlite/laravel.db
fi
chown -R www-data: /var/www/html/database/sqlite

cd /var/www/html
php artisan key:generate


echo "Starting Migrations..."
php artisan migrate --force --no-interaction

echo "Clearing caches..."
php artisan config:cache --no-interaction
php artisan view:cache --no-interaction
chmod -R 777 storage/logs/laravel.log

php-fpm -D && nginx -g 'daemon off;'
6 changes: 6 additions & 0 deletions docker/config/laravel-php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
opcache.memory_consumption = 128
opcache.interned_strings_buffer = 8
opcache.max_accelerated_files = 4000
opcache.revalidate_freq = 60
opcache.fast_shutdown = 1
opcache.enable_cli = 1
31 changes: 31 additions & 0 deletions docker/config/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
user www-data www-data;
worker_processes auto;

error_log /var/log/nginx/error.log notice;
pid /var/run/nginx/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/http.d/*.conf;
}
37 changes: 37 additions & 0 deletions docker/config/site-nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
server {
listen 80;
listen [::]:80;
server_name localhost;
root /var/www/html/public;

gzip on;
gzip_types text/plain application/xml text/css application/javascript application/json font/woff font/woff2;
gzip_proxied no-cache no-store private expired auth;
gzip_min_length 1000;

add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";

index index.php;

charset utf-8;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }

error_page 404 /index.php;

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/html/public/$fastcgi_script_name;
include fastcgi_params;
}

location ~ /\.(?!well-known).* {
deny all;
}
}