Skip to content

Commit

Permalink
serve generated static by nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
hyzhak committed May 15, 2017
1 parent 9e53225 commit ef820a9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions configs/generated_static.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GENERATED_STATIC_DIR=/usr/src/generated_static
GENERATED_STATIC_PATH=/generated_static
4 changes: 2 additions & 2 deletions nasabot/geo/animation/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async def main():
# 4. return already exist file
# 5. store popularity of files and remove files that is rare used.
hash_of_settings = uuid.uuid4()
dir_path = os.getcwd()
target_path = os.environ.get('GENERATED_STATIC_DIR', os.path.join(os.getcwd(), 'tmp'))
await pipeline(
source=source.GIBSSource(
'https://gibs.earthdata.nasa.gov/wmts/{projection}/best/{layer}/default/{date}/{resolution}/{z}/{y}/{x}.jpg',
Expand All @@ -38,7 +38,7 @@ async def main():
datetime.datetime.now() - datetime.timedelta(days=1),
),
target=target.Gif(
os.path.join(dir_path, 'tmp', 'animation-{}.gif'.format(hash_of_settings)),
os.path.join(target_path, 'animation-{}.gif'.format(hash_of_settings)),
)
)

Expand Down
4 changes: 4 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM nginx

RUN rm /etc/nginx/conf.d/default.conf
COPY sites-enabled/ /etc/nginx/conf.d
8 changes: 8 additions & 0 deletions nginx/sites-enabled/bot.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
server {
listen 80;
# serve static files
location / {
root /usr/src/generated_static;
expires 30d;
}
}

0 comments on commit ef820a9

Please sign in to comment.