Skip to content

Conversation

@t33nsy
Copy link
Collaborator

@t33nsy t33nsy commented Oct 10, 2025

Реализован подсчет хэша всех static-файлов на запуске в Dockerfile, сохранение значения в классе VersionCache, а также функция versioned_url, заменяющая url_for('static',...) и приписывающая к запросу ?v=$hash

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
Copy link
Collaborator

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:
Copy link
Collaborator

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
Copy link
Collaborator

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}'
Copy link
Collaborator

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 (убрать пробелы)

@t33nsy t33nsy linked an issue Dec 5, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants