Created
June 12, 2015 16:37
-
-
Save lukasklein/8b1252adfd4316a27524 to your computer and use it in GitHub Desktop.
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
docker: | |
image: jpetazzo/dind | |
privileged: true | |
environment: | |
- PORT=4444 | |
transcoder: | |
build: transcoder | |
restart: always | |
command: /usr/local/bin/gunicorn -w 2 -b :8000 app:app | |
links: | |
- docker | |
nginx: | |
restart: always | |
build: ./nginx/ | |
ports: | |
- "8080:80" | |
links: | |
- transcoder |
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
FROM tutum/nginx | |
RUN rm /etc/nginx/sites-enabled/default | |
ADD sites-enabled/ /etc/nginx/sites-enabled |
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
server { | |
listen 80; | |
server_name transcodertest.productgang.com; | |
charset utf-8; | |
location / { | |
proxy_pass http://transcoder:8000; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
} | |
} |
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
from docker import Client | |
from flask import Flask, Response, request | |
app = Flask(__name__) | |
docker_client = Client(base_url='http://docker:4444') | |
@app.route('/', methods=['GET', ]) | |
def transcode(): | |
url = request.args.get('url', '') | |
container = docker_client.create_container( | |
image='cellofellow/ffmpeg', | |
command=['ffmpeg', '-hide_banner', '-loglevel', 'quiet', '-i', url, '-codec:a', 'libmp3lame', '-b:a', '160k', '-f', 'mp3', '-'], | |
) | |
docker_client.start(container) | |
output = docker_client.attach( | |
container=container, | |
stdout=True, | |
stream=True, | |
logs=True, | |
) | |
return Response(output, mimetype='audio/mpeg') | |
if __name__ == '__main__': | |
app.run() |
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
FROM python:3.4.3-onbuild |
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
flask==0.10.1 | |
gunicorn==19.3.0 | |
docker-py==1.2.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment