Skip to content

Commit

Permalink
add basic support to run it locally using Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
ascandroli committed Sep 7, 2024
1 parent 09fa832 commit 3ba26f6
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
WORKERS=4
PORT=8000
B2_KEY_ID=[YOUR_KEY_ID]
B2_APP_KEY=[YOUR_APP_KEY]
B2_BUCKET=[YOUR_BUCKET]
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ COPY . ./
# webserver, with one worker process and 8 threads.
# For environments with multiple CPU cores, increase the number of workers
# to be equal to the cores available.
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 app:application
CMD exec gunicorn --bind :$PORT --workers $WORKERS --threads 8 app:application
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ EOF
crontab crontab
```

## running it locally using Docker

* You will have to provide your own Backblaze bucket, key id and app key.
* Copy `.env.example` to `.env` and fill it in with your data
```
cp .env.example .env
```
* run it:
`docker-compose up`
* open it: on http://localhost:8080
* nginx (frontend) is running on port 8080
* gunicorn (backend) will be running on the port specified in the `.env ` file
### Local development
Expand Down
6 changes: 3 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def read(filename):
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), filename)) as f:
return f.read().strip()

B2_KEY_ID = read('b2_key_id')
B2_APP_KEY = read('b2_app_key')
B2_BUCKET = 'huffduff-video'
B2_KEY_ID = os.environ['B2_KEY_ID']
B2_APP_KEY = os.environ['B2_APP_KEY']
B2_BUCKET = os.environ['B2_BUCKET']
B2_BASE = 'https://f000.backblazeb2.com/file/%s/' % B2_BUCKET

DOMAIN_BLACKLIST = frozenset((
Expand Down
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3'

services:
nginx:
image: nginx
volumes:
- ./static:/usr/share/nginx/html
ports:
- "8080:80"

gunicorn:
build: .
environment:
- WORKERS=${WORKERS}
- PORT=${PORT}
- B2_BUCKET=${B2_BUCKET}
- B2_APP_KEY=${B2_APP_KEY}
- B2_KEY_ID=${B2_KEY_ID}
ports:
- "${PORT}:${PORT}"
2 changes: 1 addition & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ <h1>huffduff-video</h1>
</section>
<section>

<form method="post" action="/get">
<form method="post" action="http://localhost:8000/get">
<label for="url">Or enter a video URL here:</label>

<input type="url" name="url" placeholder="URL" />
Expand Down

0 comments on commit 3ba26f6

Please sign in to comment.