diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c5ffa5e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,67 @@ +FROM php:8.1-fpm +LABEL maintainer="Amri Karisma " + +# Set working directory +WORKDIR /var/www + +# Add docker php ext repo +ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ + +# Install php extensions +RUN chmod +x /usr/local/bin/install-php-extensions && sync && \ + install-php-extensions mbstring pdo_mysql mysqli zip exif pcntl gd memcached bcmath + + +# Install dependencies +RUN apt-get update && apt-get install -y \ + build-essential \ + libpng-dev \ + libjpeg62-turbo-dev \ + libfreetype6-dev \ + locales \ + nano \ + zip \ + jpegoptim optipng pngquant gifsicle \ + unzip \ + git \ + curl \ + lua-zlib-dev \ + libmemcached-dev \ + nginx \ + mariadb-client \ + supervisor \ + ca-certificates \ + gnupg +RUN mkdir -p /etc/apt/keyrings +RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list + +RUN apt-get update && apt-get install -y nodejs + +# Install composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# Add user for laravel application +RUN addgroup --gid 1000 www \ + && adduser \ + --disabled-password \ + --gecos "" \ + --home "$(pwd)" \ + --ingroup www \ + --no-create-home \ + --uid 1000 \ + www + +# PHP Error Log Files +RUN mkdir /var/log/php +RUN touch /var/log/php/errors.log && chmod 777 /var/log/php/errors.log + +# Copy PHP and Nginx config +COPY --chown=root:root php.ini /usr/local/etc/php/conf.d/app.ini +COPY --chown=root:root nginx.conf /etc/nginx/sites-enabled/default + +# Install Node.js +RUN npm install npm@latest -g + +# Clear cache +RUN apt-get clean && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..fc68ef0 --- /dev/null +++ b/build.sh @@ -0,0 +1,4 @@ +docker build -t kentos93/php_vestora:latest . && \ +docker tag kentos93/php_vestora kentos93/php_vestora:$(date +%s) && \ +docker push --all-tags kentos93/php_vestora && \ +docker rmi -f $(docker images -q kentos93/php_vestora) \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..b91950f --- /dev/null +++ b/nginx.conf @@ -0,0 +1,43 @@ +server { + listen 80; + root /var/www/public; + + client_max_body_size 64M; + + add_header X-Frame-Options "SAMEORIGIN"; + add_header X-Content-Type-Options "nosniff"; + + index index.php index.html; + charset utf-8; + + 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$ { + 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; + fastcgi_buffering off; + } + + location / { + try_files $uri $uri/ /index.php?$query_string; + gzip_static on; + } + + location ~ /\.(?!well-known).* { + deny all; + } +} \ No newline at end of file diff --git a/php.ini b/php.ini new file mode 100644 index 0000000..d88ec53 --- /dev/null +++ b/php.ini @@ -0,0 +1,6 @@ +log_errors=1 +display_errors=1 +post_max_size=64M +upload_max_filesize=64M +display_startup_errors=1 +error_log=/var/log/php/errors.log \ No newline at end of file