Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
amrikarisma committed Dec 13, 2023
0 parents commit 02a6659
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 0 deletions.
67 changes: 67 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
FROM php:8.1-fpm
LABEL maintainer="Amri Karisma <amrikarisma@live.com>"

# 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/*
4 changes: 4 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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)
43 changes: 43 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}
6 changes: 6 additions & 0 deletions php.ini
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 02a6659

Please sign in to comment.