Created
March 21, 2018 09:33
-
-
Save skateinmars/c66758c261071b428722ac45bb65d897 to your computer and use it in GitHub Desktop.
Example dockerfile with simplest possible python server
This file contains hidden or 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 gliderlabs/alpine:3.4 | |
ENV PORT 80 | |
RUN apk-install python | |
ADD . /app | |
WORKDIR /app | |
CMD python /app/server.py | |
EXPOSE 80 |
This file contains hidden or 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
#!/usr/bin/python | |
# This file is only provided as an example on how to organize your services. | |
# Delete it when starting to implement your service code. | |
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer | |
import os | |
PORT = int(os.environ['PORT']) | |
class Handler(BaseHTTPRequestHandler): | |
# Handler for the GET requests | |
def do_GET(self): | |
self.send_response(200) | |
self.end_headers() | |
self.wfile.write("Hello World!") | |
return | |
server = HTTPServer(('', PORT), Handler) | |
print 'Started HTTP server on port', PORT | |
server.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment