-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from madhuryadutta/dev
PR: Improvements, Features, and Updates
- Loading branch information
Showing
562 changed files
with
653,495 additions
and
1,835 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Use PHP 8.2 with Apache as base image | ||
FROM php:8.2-apache | ||
|
||
# Update package lists and install required dependencies | ||
RUN apt-get update \ | ||
&& apt-get install -y git libzip-dev zip unzip libpq-dev \ | ||
&& apt-get clean | ||
# RUN apt-get install -y git libzip-dev zip unzip npm | ||
|
||
# Install PHP extensions | ||
|
||
RUN docker-php-ext-install pdo pdo_mysql pdo_pgsql zip | ||
|
||
# Enable Apache modules | ||
RUN a2enmod rewrite \ | ||
&& a2enmod headers | ||
|
||
# Install Composer globally | ||
|
||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | ||
|
||
RUN groupadd -r app -g 1000 && useradd -u 1000 -r -g app -m -d /app -s /sbin/nologin -c "App user" app && \ | ||
chmod 755 /var/www/html | ||
|
||
RUN php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer | ||
|
||
# Set PHP configurations for file uploads | ||
|
||
RUN echo "file_uploads = On\n" \ | ||
"memory_limit = 500M\n" \ | ||
"upload_max_filesize = 500M\n" \ | ||
"post_max_size = 500M\n" \ | ||
"max_execution_time = 600\n" \ | ||
> /usr/local/etc/php/conf.d/uploads.ini | ||
|
||
# Set Apache server name | ||
|
||
RUN echo 'ServerName 127.0.0.1' >> /etc/apache2/apache2.conf | ||
|
||
USER app | ||
|
||
# COPY docker/entrypoint.sh /var/www/html/entrypoint.sh | ||
# COPY docker/entrypoint.sh /var/www/html/docker/entrypoint.sh | ||
|
||
# Set working directory | ||
WORKDIR /var/www/html | ||
|
||
USER root | ||
|
||
# Copy application files to the container | ||
|
||
COPY . . | ||
|
||
# Install production dependencies | ||
RUN composer install --optimize-autoloader --no-dev | ||
|
||
# # Install Node.js and npm | ||
RUN curl -sL https://deb.nodesource.com/setup_20.x | bash - | ||
RUN apt-get install -y nodejs | ||
RUN npm install | ||
|
||
# Build frontend assets | ||
|
||
RUN npm run build | ||
|
||
# Adjust permissions for certain directories | ||
|
||
RUN chmod o+w ./storage/ -R | ||
RUN chmod o+w ./public/ -R | ||
RUN chmod o+w ./bootstrap/ -R | ||
|
||
# Copy Apache configuration files | ||
|
||
COPY docker/web/default.conf /etc/apache2/sites-available/000-default.conf | ||
COPY docker/web/default.conf /etc/apache2/sites-enabled/000-default.conf | ||
COPY docker/web/mpm_prefork.conf /etc/apache2/mods-available/mpm_prefork.conf | ||
|
||
# Copy the entrypoint script into the container | ||
COPY docker/entrypoint.sh /usr/local/bin/ | ||
|
||
# Grant execution permissions to the entrypoint script | ||
RUN chmod +x /usr/local/bin/entrypoint.sh | ||
|
||
# Expose port 80 | ||
EXPOSE 80 | ||
|
||
# Set the entrypoint to execute the entrypoint script | ||
ENTRYPOINT ["entrypoint.sh"] | ||
|
||
# # Start Apache in the foreground | ||
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: vendor/bin/heroku-php-nginx -C nginx_app.conf /public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Api; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\Category; | ||
use Illuminate\Http\Request; | ||
|
||
class CategoryController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
$category = Category::all(); | ||
|
||
return response()->json($category); | ||
} | ||
|
||
public function show($id) | ||
{ | ||
$category = Category::find($id); | ||
|
||
if (! empty($category)) { | ||
return response()->json($category, 200); | ||
} else { | ||
return response()->json(['message' => 'Category Not Found'], 404); | ||
} | ||
} | ||
|
||
public function store(Request $request) | ||
{ | ||
$category = new Category; | ||
$category->parent_id = $request['parentCategory']; | ||
$category->category_name = $request['categoryName']; | ||
$category->is_active = $request['is_active']; | ||
$category->save(); | ||
|
||
return response()->json(['message' => 'Category Added'], 201); | ||
} | ||
|
||
public function update(Request $request, $id) | ||
{ | ||
if (Category::where('id', $id)->exists()) { | ||
|
||
$category = Category::find($id); | ||
$category->parent_id = is_null($request['parentCategory']) ? $category->parent_id : $request['parentCategory']; | ||
$category->category_name = is_null($request['categoryName']) ? $category->category_name : $request['categoryName']; | ||
$category->is_active = is_null($request['is_active']) ? $category->is_active : $request['is_active']; | ||
$category->save(); | ||
|
||
return response()->json(['message' => 'Category Updated'], 200); | ||
} else { | ||
return response()->json(['message' => 'Category Not Found'], 404); | ||
} | ||
} | ||
|
||
// Deafult: soft delete | ||
public function destroy($id) | ||
{ | ||
if (Category::where('id', $id)->exists()) { | ||
$category = Category::find($id); | ||
$category->is_active = 0; | ||
$category->save(); | ||
|
||
return response()->json([ | ||
'message' => 'category deleted.', | ||
], 202); | ||
} else { | ||
return response()->json(['message' => 'category not found'], 404); | ||
} | ||
} | ||
// Hard Delete | ||
|
||
// public function destroy($id) | ||
// { | ||
// if (Category::where('id', $id)->exists()) { | ||
// $category = Category::find($id); | ||
// $category->delete(); | ||
// return response()->json([ | ||
// "message" => "category deleted." | ||
// ], 202); | ||
// } else { | ||
// return response()->json(['message' => 'category not found'], 404); | ||
// } | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Api; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Support\Facades\DB; | ||
use Illuminate\Support\Facades\Log; | ||
|
||
class HealthCheckController extends Controller | ||
{ | ||
public function check() | ||
{ | ||
try { | ||
// Perform any necessary health checks here | ||
// For example, check database connection | ||
DB::connection()->getPdo(); | ||
|
||
return response()->json(['status' => 'ok']); | ||
} catch (\Exception $e) { | ||
Log::error('Health Check Failed: '.$e->getMessage()); | ||
|
||
return response()->json(['status' => 'error', 'message' => 'Health check failed.'], 500); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.