Created
September 29, 2020 15:28
-
-
Save ofen/e320f0a4303e9a52b3bd016f93826880 to your computer and use it in GitHub Desktop.
AIOHTTP alpine docker
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/env python3 | |
from aiohttp import web, ClientSession | |
PORT=8080 | |
async def on_startup(app): | |
print('Listening on port "%d"' % PORT) | |
app['session'] = ClientSession() | |
async def on_cleanup(app): | |
await app['session'].close() | |
async def on_shutdown(app): | |
print('Shutting down...') | |
async def health(request): | |
return web.json_response({'status_code': 200, 'response': 'OK'}) | |
app = web.Application() | |
app.router.add_route('GET', '/health', health) | |
web.run_app( | |
app, | |
print=None, | |
port=PORT, | |
access_log_format='%a "%r" %s %b "%{Referer}i" "%{User-Agent}i"' | |
) |
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 python:3-alpine | |
WORKDIR /app | |
COPY . . | |
RUN adduser appuser --disabled-password \ | |
--gecos "" --home /nonexistent \ | |
--shell /sbin/nologin --no-create-home \ | |
--uid 1000 \ | |
&& YARL_NO_EXTENSIONS=1 MULTIDICT_NO_EXTENSIONS=1 pip install --no-cache-dir -r requirements.txt | |
USER appuser:appuser | |
ENTRYPOINT ["./app.py"] |
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
aiohttp==3.6.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment