-
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 #1 from nadahasnim/develop
feat/first_release
- Loading branch information
Showing
149 changed files
with
76,028 additions
and
146 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# excludes from the docker image/build | ||
|
||
# 1. Ignore Laravel-specific files we don't need | ||
bootstrap/cache/* | ||
storage/framework/cache/* | ||
storage/framework/sessions/* | ||
storage/framework/views/* | ||
storage/logs/* | ||
*.env* | ||
.rr.yml | ||
rr | ||
vendor | ||
|
||
# 2. Ignore common files/directories we don't need | ||
fly.toml | ||
.vscode | ||
.idea | ||
**/*node_modules | ||
**.git | ||
**.gitignore | ||
**.gitattributes | ||
**.sass-cache | ||
**/*~ | ||
**/*.log | ||
**/.DS_Store | ||
**/Thumbs.db | ||
public/hot |
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,15 @@ | ||
#!/usr/bin/env sh | ||
|
||
# Run user scripts, if they exist | ||
for f in /var/www/html/.fly/scripts/*.sh; do | ||
# Bail out this loop if any script exits with non-zero status code | ||
bash "$f" || break | ||
done | ||
chown -R www-data:www-data /var/www/html | ||
|
||
if [ $# -gt 0 ]; then | ||
# If we passed a command, run it as root | ||
exec "$@" | ||
else | ||
exec supervisord -c /etc/supervisor/supervisord.conf | ||
fi |
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,7 @@ | ||
FOLDER=/var/www/html/storage/app | ||
if [ ! -d "$FOLDER" ]; then | ||
echo "$FOLDER is not a directory, copying storage_ content to storage" | ||
cp -r /var/www/html/storage_/. /var/www/html/storage | ||
echo "deleting storage_..." | ||
rm -rf /var/www/html/storage_ | ||
fi |
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,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
/usr/bin/php /var/www/html/artisan config:cache --no-ansi -q | ||
/usr/bin/php /var/www/html/artisan route:cache --no-ansi -q | ||
/usr/bin/php /var/www/html/artisan view:cache --no-ansi -q |
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,93 @@ | ||
# syntax = docker/dockerfile:experimental | ||
|
||
# Default to PHP 8.2, but we attempt to match | ||
# the PHP version from the user (wherever `flyctl launch` is run) | ||
# Valid version values are PHP 7.4+ | ||
ARG PHP_VERSION=8.2 | ||
ARG NODE_VERSION=18 | ||
FROM fideloper/fly-laravel:${PHP_VERSION} as base | ||
|
||
# PHP_VERSION needs to be repeated here | ||
# See https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact | ||
ARG PHP_VERSION | ||
|
||
LABEL fly_launch_runtime="laravel" | ||
|
||
# copy application code, skipping files based on .dockerignore | ||
COPY . /var/www/html | ||
|
||
RUN composer install \ | ||
&& mkdir -p storage/logs \ | ||
&& php artisan optimize:clear \ | ||
&& chown -R www-data:www-data /var/www/html \ | ||
&& sed -i 's/protected \$proxies/protected \$proxies = "*"/g' app/Http/Middleware/TrustProxies.php \ | ||
&& echo "MAILTO=\"\"\n* * * * * www-data /usr/bin/php /var/www/html/artisan schedule:run" > /etc/cron.d/laravel \ | ||
&& cp .fly/entrypoint.sh /entrypoint \ | ||
&& chmod +x /entrypoint | ||
|
||
# If we're using Octane... | ||
RUN if grep -Fq "laravel/octane" /var/www/html/composer.json; then \ | ||
rm -rf /etc/supervisor/conf.d/fpm.conf; \ | ||
if grep -Fq "spiral/roadrunner" /var/www/html/composer.json; then \ | ||
mv /etc/supervisor/octane-rr.conf /etc/supervisor/conf.d/octane-rr.conf; \ | ||
if [ -f ./vendor/bin/rr ]; then ./vendor/bin/rr get-binary; fi; \ | ||
rm -f .rr.yaml; \ | ||
else \ | ||
mv .fly/octane-swoole /etc/services.d/octane; \ | ||
mv /etc/supervisor/octane-swoole.conf /etc/supervisor/conf.d/octane-swoole.conf; \ | ||
fi; \ | ||
rm /etc/nginx/sites-enabled/default; \ | ||
ln -sf /etc/nginx/sites-available/default-octane /etc/nginx/sites-enabled/default; \ | ||
fi | ||
|
||
# Multi-stage build: Build static assets | ||
# This allows us to not include Node within the final container | ||
FROM node:${NODE_VERSION} as node_modules_go_brrr | ||
|
||
RUN mkdir /app | ||
|
||
RUN mkdir -p /app | ||
WORKDIR /app | ||
COPY . . | ||
COPY --from=base /var/www/html/vendor /app/vendor | ||
|
||
# Use yarn or npm depending on what type of | ||
# lock file we might find. Defaults to | ||
# NPM if no lock file is found. | ||
# Note: We run "production" for Mix and "build" for Vite | ||
RUN if [ -f "vite.config.js" ]; then \ | ||
ASSET_CMD="build"; \ | ||
else \ | ||
ASSET_CMD="production"; \ | ||
fi; \ | ||
if [ -f "yarn.lock" ]; then \ | ||
yarn install --frozen-lockfile; \ | ||
yarn $ASSET_CMD; \ | ||
elif [ -f "pnpm-lock.yaml" ]; then \ | ||
corepack enable && corepack prepare pnpm@latest-7 --activate; \ | ||
pnpm install --frozen-lockfile; \ | ||
pnpm run $ASSET_CMD; \ | ||
elif [ -f "package-lock.json" ]; then \ | ||
npm ci --no-audit; \ | ||
npm run $ASSET_CMD; \ | ||
else \ | ||
npm install; \ | ||
npm run $ASSET_CMD; \ | ||
fi; | ||
|
||
# From our base container created above, we | ||
# create our final image, adding in static | ||
# assets that we generated above | ||
FROM base | ||
|
||
# Packages like Laravel Nova may have added assets to the public directory | ||
# or maybe some custom assets were added manually! Either way, we merge | ||
# in the assets we generated above rather than overwrite them | ||
COPY --from=node_modules_go_brrr /app/public /var/www/html/public-npm | ||
RUN rsync -ar /var/www/html/public-npm/ /var/www/html/public/ \ | ||
&& rm -rf /var/www/html/public-npm \ | ||
&& chown -R www-data:www-data /var/www/html/public | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["/entrypoint"] |
59 changes: 59 additions & 0 deletions
59
app/Http/Controllers/Auth/AuthenticatedSessionController.php
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,59 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Auth; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Http\Requests\Auth\LoginRequest; | ||
use App\Providers\RouteServiceProvider; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Support\Facades\Route; | ||
use Inertia\Inertia; | ||
|
||
class AuthenticatedSessionController extends Controller | ||
{ | ||
/** | ||
* Display the login view. | ||
* | ||
* @return \Inertia\Response | ||
*/ | ||
public function create() | ||
{ | ||
return Inertia::render('Auth/Login', [ | ||
'canResetPassword' => Route::has('password.request'), | ||
'status' => session('status'), | ||
]); | ||
} | ||
|
||
/** | ||
* Handle an incoming authentication request. | ||
* | ||
* @param \App\Http\Requests\Auth\LoginRequest $request | ||
* @return \Illuminate\Http\RedirectResponse | ||
*/ | ||
public function store(LoginRequest $request) | ||
{ | ||
$request->authenticate(); | ||
|
||
$request->session()->regenerate(); | ||
|
||
return redirect()->intended(RouteServiceProvider::HOME); | ||
} | ||
|
||
/** | ||
* Destroy an authenticated session. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\Http\RedirectResponse | ||
*/ | ||
public function destroy(Request $request) | ||
{ | ||
Auth::guard('web')->logout(); | ||
|
||
$request->session()->invalidate(); | ||
|
||
$request->session()->regenerateToken(); | ||
|
||
return redirect('/'); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
app/Http/Controllers/Auth/ConfirmablePasswordController.php
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,45 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Auth; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Providers\RouteServiceProvider; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Validation\ValidationException; | ||
use Inertia\Inertia; | ||
|
||
class ConfirmablePasswordController extends Controller | ||
{ | ||
/** | ||
* Show the confirm password view. | ||
* | ||
* @return \Inertia\Response | ||
*/ | ||
public function show() | ||
{ | ||
return Inertia::render('Auth/ConfirmPassword'); | ||
} | ||
|
||
/** | ||
* Confirm the user's password. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return mixed | ||
*/ | ||
public function store(Request $request) | ||
{ | ||
if (! Auth::guard('web')->validate([ | ||
'email' => $request->user()->email, | ||
'password' => $request->password, | ||
])) { | ||
throw ValidationException::withMessages([ | ||
'password' => __('auth.password'), | ||
]); | ||
} | ||
|
||
$request->session()->put('auth.password_confirmed_at', time()); | ||
|
||
return redirect()->intended(RouteServiceProvider::HOME); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
app/Http/Controllers/Auth/EmailVerificationNotificationController.php
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,27 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Auth; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Providers\RouteServiceProvider; | ||
use Illuminate\Http\Request; | ||
|
||
class EmailVerificationNotificationController extends Controller | ||
{ | ||
/** | ||
* Send a new email verification notification. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\Http\RedirectResponse | ||
*/ | ||
public function store(Request $request) | ||
{ | ||
if ($request->user()->hasVerifiedEmail()) { | ||
return redirect()->intended(RouteServiceProvider::HOME); | ||
} | ||
|
||
$request->user()->sendEmailVerificationNotification(); | ||
|
||
return back()->with('status', 'verification-link-sent'); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
app/Http/Controllers/Auth/EmailVerificationPromptController.php
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,24 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Auth; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Providers\RouteServiceProvider; | ||
use Illuminate\Http\Request; | ||
use Inertia\Inertia; | ||
|
||
class EmailVerificationPromptController extends Controller | ||
{ | ||
/** | ||
* Display the email verification prompt. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return mixed | ||
*/ | ||
public function __invoke(Request $request) | ||
{ | ||
return $request->user()->hasVerifiedEmail() | ||
? redirect()->intended(RouteServiceProvider::HOME) | ||
: Inertia::render('Auth/VerifyEmail', ['status' => session('status')]); | ||
} | ||
} |
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,73 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Auth; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Auth\Events\PasswordReset; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Support\Facades\Password; | ||
use Illuminate\Support\Str; | ||
use Illuminate\Validation\Rules; | ||
use Illuminate\Validation\ValidationException; | ||
use Inertia\Inertia; | ||
|
||
class NewPasswordController extends Controller | ||
{ | ||
/** | ||
* Display the password reset view. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Inertia\Response | ||
*/ | ||
public function create(Request $request) | ||
{ | ||
return Inertia::render('Auth/ResetPassword', [ | ||
'email' => $request->email, | ||
'token' => $request->route('token'), | ||
]); | ||
} | ||
|
||
/** | ||
* Handle an incoming new password request. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\Http\RedirectResponse | ||
* | ||
* @throws \Illuminate\Validation\ValidationException | ||
*/ | ||
public function store(Request $request) | ||
{ | ||
$request->validate([ | ||
'token' => 'required', | ||
'email' => 'required|email', | ||
'password' => ['required', 'confirmed', Rules\Password::defaults()], | ||
]); | ||
|
||
// Here we will attempt to reset the user's password. If it is successful we | ||
// will update the password on an actual user model and persist it to the | ||
// database. Otherwise we will parse the error and return the response. | ||
$status = Password::reset( | ||
$request->only('email', 'password', 'password_confirmation', 'token'), | ||
function ($user) use ($request) { | ||
$user->forceFill([ | ||
'password' => Hash::make($request->password), | ||
'remember_token' => Str::random(60), | ||
])->save(); | ||
|
||
event(new PasswordReset($user)); | ||
} | ||
); | ||
|
||
// If the password was successfully reset, we will redirect the user back to | ||
// the application's home authenticated view. If there is an error we can | ||
// redirect them back to where they came from with their error message. | ||
if ($status == Password::PASSWORD_RESET) { | ||
return redirect()->route('login')->with('status', __($status)); | ||
} | ||
|
||
throw ValidationException::withMessages([ | ||
'email' => [trans($status)], | ||
]); | ||
} | ||
} |
Oops, something went wrong.