-
Notifications
You must be signed in to change notification settings - Fork 1
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 #16 from chilipot/integration/v0.1.0
Release Version 0.1.0
- Loading branch information
Showing
37 changed files
with
2,437 additions
and
36 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,33 @@ | ||
FROM python:3.7-alpine AS base-image | ||
|
||
LABEL Author="Daniel Guddemi [email protected]" | ||
|
||
ENV PYTHONUNBUFFERED 1 | ||
|
||
COPY ./requirements.txt /songflong/requirements.txt | ||
|
||
RUN apk update && \ | ||
apk add --no-cache --virtual .build-deps build-base linux-headers git g++ gcc libc-dev libxslt-dev && \ | ||
apk add --no-cache libxslt jpeg-dev zlib-dev && \ | ||
pip wheel --wheel-dir=/root/wheels -r /songflong/requirements.txt &&\ | ||
apk del .build-deps | ||
|
||
FROM python:3.7-alpine | ||
|
||
COPY --from=base-image /root/wheels /root/wheels | ||
|
||
COPY ./requirements.txt /songflong/requirements.txt | ||
COPY ./songflong.ini /songflong/songflong.ini | ||
|
||
WORKDIR /songflong | ||
|
||
RUN apk add --no-cache libxslt ffmpeg git && \ | ||
pip install \ | ||
--no-index \ | ||
--find-links=/root/wheels \ | ||
-r requirements.txt &&\ | ||
apk del git | ||
|
||
COPY ./run.py /songflong/run.py | ||
COPY ./worker.py /songflong/worker.py | ||
COPY ./app /songflong/app |
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 @@ | ||
FROM python:3.7.0-alpine | ||
|
||
RUN pip install rq-dashboard | ||
|
||
EXPOSE 9181 | ||
|
||
CMD ["rq-dashboard"] |
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 @@ | ||
FROM node:9.5 as builder | ||
|
||
RUN mkdir /usr/src/app | ||
WORKDIR /usr/src/app | ||
|
||
COPY static/ /usr/src/app | ||
|
||
ENV PATH /usr/src/app/node_modules/.bin:$PATH | ||
|
||
ADD ./static/package.json /usr/src/app/package.json | ||
RUN npm install | ||
RUN npm install -g [email protected] | ||
RUN npm run build | ||
|
||
FROM nginx:1.13.3-alpine | ||
|
||
RUN rm -rf /usr/share/nginx/html/* | ||
|
||
COPY --from=builder /usr/src/app/build /usr/share/nginx/html | ||
COPY config/nginx.conf /etc/nginx/conf.default | ||
|
||
EXPOSE 80 | ||
|
||
CMD ["nginx", "-g", "daemon off;"] |
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 |
---|---|---|
@@ -1,5 +1,14 @@ | ||
## Bug Fixes | ||
*Sorry David* | ||
# SongFlong | ||
|
||
There are bugs in the 9.5.2 version of "pytube". You need to install the requirement and then manually implement the fixes in the files. They're are located in the virtualenv/lib/python3.7/site-packages/pytube | ||
https://github.com/nficano/pytube/pull/453/files/fac934b149bc2d49ea54d566e0639d9b4c2862d2 | ||
## Setup | ||
*SongFlong is built to run inside a Docker swarm and routing issues can occur if ran locally.* | ||
|
||
To run it locally, you need to manually replace the hostname of the Redis connection. This has to be done for the main Flask app and for the Worker. Changing it to `localhost` should suffice. | ||
|
||
To run it using Docker, all you need to do is install Docker and Docker-Compose. | ||
``` | ||
docker-compose up --build --scale worker=3 | ||
``` | ||
|
||
The `--build` flag is not necessary; it does stuff that I don't feel like explaining to David (just look it up). | ||
The `--scale` can be modified to replicate as many workers as you want. Removing it completely will default to just 1. |
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 |
---|---|---|
@@ -1,14 +1,17 @@ | ||
import os | ||
|
||
from flask import Flask | ||
from flask_cors import CORS | ||
from redis import StrictRedis | ||
from rq import Queue | ||
|
||
|
||
def create_app(): | ||
app = Flask(__name__) | ||
app.config["FFMPEG_PATH"] = os.environ.get("FFMPEG_PATH", default="/usr/bin/ffmpeg") | ||
app.q = Queue(connection=StrictRedis()) | ||
app = Flask(__name__, static_folder="../temp") | ||
CORS(app) | ||
app.config["FFMPEG_PATH"] = os.environ.get( | ||
"FFMPEG_PATH", default="/usr/bin/ffmpeg") | ||
app.q = Queue(connection=StrictRedis(host='redis', port='6379')) | ||
from app.routes import JOBS | ||
app.register_blueprint(JOBS) | ||
return app |
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 |
---|---|---|
@@ -1,29 +1,38 @@ | ||
from flask import jsonify, send_file, Blueprint | ||
from flask import jsonify, Blueprint, send_from_directory, current_app | ||
|
||
from app import job_service | ||
|
||
JOBS = Blueprint('jobs', __name__) | ||
|
||
|
||
@JOBS.route('/') | ||
def index(): | ||
return "Hello, World!", 200 | ||
@JOBS.route('/ping') | ||
def ping(): | ||
return "pong", 200 | ||
|
||
|
||
@JOBS.route('/submit/<string:song_name>') | ||
def submit(song_name): | ||
jobs = job_service.setup_jobs(song_name) | ||
return jsonify(job_ids=jobs) | ||
if jobs: | ||
return jsonify(job_ids=jobs) | ||
else: | ||
return {"status", 'Unable to find video stream!'}, 424 | ||
|
||
|
||
@JOBS.route('/results/<string:job_id>') | ||
def results(job_id): | ||
job = job_service.get_job(job_id) | ||
|
||
if job.is_failed: | ||
return 'Job has failed!', 400 | ||
return {"status": 'Job has failed!'}, 400 | ||
|
||
if job.is_finished: | ||
return send_file(filename_or_fp=str(job.result.absolute())) | ||
return jsonify(job.result) | ||
|
||
return 'Job has not finished!', 202 | ||
return {"status": 'Job has not finished!'}, 202 | ||
|
||
|
||
@JOBS.route('/video/<string:video_path>') | ||
def get_video(video_path): | ||
# Serve directly from a better web server | ||
return send_from_directory(directory=current_app.static_folder, filename=video_path) |
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import logging | ||
|
||
logging.basicConfig(level=logging.INFO, | ||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') | ||
log_format = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') | ||
handler = logging.StreamHandler() | ||
handler.setLevel(logging.INFO) | ||
|
||
logger = logging.getLogger(__name__) | ||
logger = logging.getLogger('songflong_builder') | ||
logger.addHandler(handler) |
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
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
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,17 @@ | ||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
server { | ||
listen 80; | ||
server_name localhost; | ||
sendfiles on; | ||
|
||
|
||
location / { | ||
root /usr/share/nginx/html/; | ||
index index.html; | ||
|
||
try_files $uri; | ||
} | ||
} |
Oops, something went wrong.