-
Notifications
You must be signed in to change notification settings - Fork 1
435 invalidator #441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
435 invalidator #441
Conversation
| RUN STATIC_HASH=$(find app/static -type f -exec md5sum {} \; | md5sum | cut -d' ' -f1) && \ | ||
| echo $STATIC_HASH >> /APP_STATIC_HASH | ||
|
|
||
| ENV APP_STATIC_HASH_FILE=/APP_STATIC_HASH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Кажется, особого смысла держать файл с хэшем нет (т.к. это строка небольшой длины) - хэш можно записать в ENV переменную (возможно, даже не на сборке, а на запуске приложения?), и получить его в приложении
| config_raw.read(config_path) | ||
| Config.c = DictToObject(config_raw._sections) | ||
|
|
||
| class VersionCache: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Думаю, данная логика и класс всё-таки лишние - достаточно добавить версию в app.config (конфигурация Flask- приложения) и брать её оттуда
| from app.api.trainings import api_trainings | ||
| from app.api.version import api_version | ||
| from app.config import Config | ||
| from app.config import Config, VersionCache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VersionCache здесь нигде не используется
|
|
||
| def versioned_url(filename): | ||
| v = VersionCache().get_version() | ||
| return url_for('static', filename=filename) + f'?v={v}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Сейчас url с версией выглядит как ?v=[%27d41d8cd98f00b204e9800998ecf8427e%27] - результат self.version=f.read().split() - вероятно, вы хотели там strip (убрать пробелы)
Реализован подсчет хэша всех static-файлов на запуске в Dockerfile, сохранение значения в классе VersionCache, а также функция versioned_url, заменяющая url_for('static',...) и приписывающая к запросу ?v=$hash