Skip to content

Commit

Permalink
Docker dependency management and sanity checking
Browse files Browse the repository at this point in the history
  • Loading branch information
fsufitch committed Feb 15, 2019
1 parent c3b905a commit 7b6fd95
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM ubuntu:latest
FROM python:3.7

RUN apt-get update
RUN apt-get install -y ffmpeg

RUN python -m pip install pipenv

COPY . /var/movie-meme-generator/
WORKDIR /var/movie-meme-generator

RUN pipenv install

ENTRYPOINT [ "pipenv", "run", "python", "movie-meme-generator.py" ]
3 changes: 3 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ verify_ssl = true
[dev-packages]

[packages]
requests = "*"
pyyaml = "*"
pillow = "*"

[requires]
python_version = "3.7"
110 changes: 110 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Movie Meme Generator
==========

WIP. Currently just a sanity check script for all dependencies.
See if it works:

docker build -t movie-meme-generator .
docker run movie-meme-generator
4 changes: 4 additions & 0 deletions movie-meme-generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from moviememes.sanitycheck import run_sanity_checks

if __name__ == '__main__':
run_sanity_checks()
Empty file added moviememes/__init__.py
Empty file.
40 changes: 40 additions & 0 deletions moviememes/sanitycheck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import PIL, requests, subprocess, sys, traceback

def python_version_check():
print("Checking Python version...")
print("Running on:", sys.version)
print("OK")

def requests_check():
print("Testing requests library...")
response = requests.get('http://example.org')
if response.status_code == 200:
print("OK")
else:
print(f"ERROR: Example query returned non-200 code: {response.status_code}")

def ffmpeg_check():
print("Testing ffmpeg availability...")
try:
subprocess.check_call(['ffmpeg', '-version'])
print("OK")
except Exception as e:
print("ERROR running `ffmpeg -version`")
traceback.print_exc()

def pillow_check():
print("Testing Pillow availability...")
print("Using: ", PIL.PILLOW_VERSION)
print("OK")

SANITY_CHECKS = [
python_version_check,
pillow_check,
requests_check,
ffmpeg_check,
]

def run_sanity_checks():
for sanity_check in SANITY_CHECKS:
sanity_check()
print()
1 change: 1 addition & 0 deletions resources/placeholder.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Do not remove me

0 comments on commit 7b6fd95

Please sign in to comment.