Skip to content

Commit

Permalink
Add request caching to Dockerfile generator
Browse files Browse the repository at this point in the history
When developing parts of the Dockerfile generation pipeline, and thus regenerating Dockerfiles over and over, many
unnecessary HTTP requests are being made to https://api.adoptium.net, since the data is mostly unchanged. Adding a
request cache with an expiration time of an hour allows this regeneration to run in under a second in most case, while
not compromising on the correctness.
  • Loading branch information
rassie committed Apr 22, 2024
1 parent ad4564c commit a5427a4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ official-eclipse-temurin
library/
.vscode/
__pycache__/
/adoptium_cache.sqlite
3 changes: 3 additions & 0 deletions generate_dockerfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@

import os

import requests_cache
import requests
import yaml
from jinja2 import Environment, FileSystemLoader

requests_cache.install_cache("adoptium_cache", expire_after=3600)

# Setup the Jinja2 environment
env = Environment(loader=FileSystemLoader("docker_templates"))

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Jinja2==3.1.3
PyYAML==6.0.1
Requests==2.31.0
requests-cache==1.2.0

0 comments on commit a5427a4

Please sign in to comment.