Skip to content

Instantly share code, notes, and snippets.

@stantonk
Last active May 6, 2020 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stantonk/325996d58748c92786685e13190ac8af to your computer and use it in GitHub Desktop.
Save stantonk/325996d58748c92786685e13190ac8af to your computer and use it in GitHub Desktop.
example of using docker container to package a python application
$ docker build -t show .
$ docker run -v `pwd`:/data show /data/blah.txt
a
b
c
d
e
f
g
a
b
c
d
e
f
g
FROM python:3.7
RUN mkdir -p /data
COPY p.py /p.py
RUN pip install click
WORKDIR /
ENTRYPOINT ["python", "p.py"]
import click
@click.command()
@click.argument('filename', type=click.Path(exists=True))
def show(filename):
"""Print FILENAME if the file exists."""
with open(filename, 'rb') as f:
for l in f:
click.echo((l), nl=False)
if __name__ == '__main__':
show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment