Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ohnotnow committed Jan 30, 2020
0 parents commit 8640512
Show file tree
Hide file tree
Showing 105 changed files with 73,926 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
npm-debug
Dockerfile
stack.yml
npm-debug.log
yarn-error.log
.dockerignore
**/mix-manifest.json
.env
.DS_Store
.idea
.git/
node_modules/
vendor/
/public/hot
/public/storage
/public/js/*
/public/css/*
/public/chunks/*
/storage/*.key
/storage/framework/views/*
/storage/framework/sessions/*
/storage/framework/testing/*
/storage/framework/cache/data/*
/storage/debugbar/*
/storage/logs/*
/storage/medialibrary/*
/storage/app/*
/tests/Browser/console/*
/tests/Browser/images/*
/tests/Browser/screenshots/*
/bootstrap/cache/*

15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
46 changes: 46 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/storage/app/*
/vendor
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
13 changes: 13 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
php:
preset: laravel
disabled:
- unused_use
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true
45 changes: 45 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM node:12-buster-slim as JSLAND

# fix for laravel mix webpack paths
RUN ln -s /home/node/public /public

USER node
WORKDIR /home/node
# make sure the paths the build output expects are there
RUN mkdir -p /home/node/public/css /home/node/public/js
# copy in our js/css/html
COPY package*.json webpack.mix.js /home/node/
COPY resources/ /home/node/resources/
# install node stuff and build our assets
RUN npm ci && npm run prod

FROM uogsoe/soe-php-apache:7.4 as PHPLAND

ENV PYTHON_VERSION 3.7

WORKDIR /var/www/html/

# make sure background processes can write to our workdir as www-data
RUN chown www-data:www-data /var/www/html

# install the packages we need
RUN apt-get update && apt-get install -y --no-install-recommends gosu ffmpeg curl python${PYTHON_VERSION} && ln -s /usr/bin/python${PYTHON_VERSION} /usr/bin/python
RUN curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl && chmod a+rx /usr/local/bin/youtube-dl
# make sure our db directory exists and will be writeable
RUN mkdir /tmp/sqlite && chown www-data:www-data /tmp/sqlite

# copy all our code in
COPY --chown=www-data:www-data . /var/www/html/
RUN chmod +x /var/www/html/app-start /var/www/html/app-healthcheck
COPY --from=JSLAND /home/node/public/js/ /var/www/html/public/js/
COPY --from=JSLAND /home/node/public/css/ /var/www/html/public/css/

# install php deps
RUN composer install --no-dev --no-suggest

RUN php artisan storage:link

# and off we go
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "/var/www/html/app-healthcheck" ]
ENTRYPOINT [ "/var/www/html/app-start" ]

7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2020 ohwhatnow

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# YTDLWeb

[WIP] Simple web front-end to download files using [youtube-dl](http://ytdl-org.github.io/youtube-dl/).

![screenshot](./screenshot.png)

## Using

Docs to be done...

## Demo with docker

You should be able to run :
```bash
docker-compose up --build
```
And then after a little time when everything is running point your browser at http://localhost:3000 .

25 changes: 25 additions & 0 deletions app-healthcheck
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -eo pipefail

role=${CONTAINER_ROLE:-app}

if [ "$role" = "app" ]; then

curl -f http://localhost/_healthz || exit 1
exit 0

elif [ "$role" = "queue" ]; then

php /var/www/html/artisan horizon:status | grep -q 'Horizon is running' || exit 1
exit 0

elif [ "$role" = "migrations" ]; then

# nothing to do here
exit 0

else
echo "Could not match the container role \"$role\""
exit 1
fi
37 changes: 37 additions & 0 deletions app-start
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

set -e

role=${CONTAINER_ROLE:-app}
env=${APP_ENV:-production}

until echo 'PING' | nc -w 1 redis 6379 | grep -q PONG
do
echo "Waiting for Redis connection..."
sleep 5
done

php /var/www/html/artisan config:cache

if [ "$role" = "app" ]; then

exec apache2-foreground

elif [ "$role" = "queue" ]; then

chown www-data:www-data storage/app/downloads
gosu www-data nice php /var/www/html/artisan queue:work --timeout=3500

elif [ "$role" = "migrations" ]; then

gosu www-data touch /tmp/sqlite/database.sqlite
gosu www-data php /var/www/html/artisan migrate --force
while [ true ]
do
sleep 86400
done

else
echo "Could not match the container role \"$role\""
exit 1
fi
42 changes: 42 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
}

/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
}
10 changes: 10 additions & 0 deletions app/DownloadedFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class DownloadedFile extends Model
{
protected $guarded = [];
}
55 changes: 55 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace App\Exceptions;

use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];

/**
* Report or log an exception.
*
* @param \Exception $exception
* @return void
*
* @throws \Exception
*/
public function report(Exception $exception)
{
parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Exception
*/
public function render($request, Exception $exception)
{
return parent::render($request, $exception);
}
}
Loading

0 comments on commit 8640512

Please sign in to comment.