working prod build

acutal serving of built assets not tested yet
This commit is contained in:
rash
2026-03-16 15:19:12 +01:00
parent 3df9d86216
commit 21bd00e7e6
8 changed files with 23 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
doc/ doc/
env/ env/
node_modules/
res/ res/
local/ local/
.git/ .git/

View File

@@ -20,11 +20,11 @@ RUN apt-get update && \
supervisor \ supervisor \
libmaxminddb0 \ libmaxminddb0 \
libmaxminddb-dev \ libmaxminddb-dev \
zlib1g-dev \ zlib1g-dev && \
nodejs \
npm && \
apt-get clean && \ apt-get clean && \
rm -rf /var/lib/apt/lists/* && \ rm -rf /var/lib/apt/lists/* && \
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo bash - && \
apt-get install -y nodejs && \
dpkg-reconfigure locales && \ dpkg-reconfigure locales && \
locale-gen C.UTF-8 && \ locale-gen C.UTF-8 && \
/usr/sbin/update-locale LANG=C.UTF-8 && \ /usr/sbin/update-locale LANG=C.UTF-8 && \
@@ -49,6 +49,10 @@ COPY deployment/docker/production_settings.py /pretix/src/production_settings.py
COPY pyproject.toml /pretix/pyproject.toml COPY pyproject.toml /pretix/pyproject.toml
COPY _build /pretix/_build COPY _build /pretix/_build
COPY src /pretix/src COPY src /pretix/src
COPY package.json /pretix/package.json
COPY package-lock.json /pretix/package-lock.json
COPY tsconfig.json /pretix/tsconfig.json
COPY vite.config.ts /pretix/vite.config.ts
RUN pip3 install -U \ RUN pip3 install -U \
pip \ pip \

View File

@@ -48,3 +48,8 @@ recursive-include src Makefile
recursive-exclude doc * recursive-exclude doc *
recursive-exclude deployment * recursive-exclude deployment *
recursive-exclude res * recursive-exclude res *
include package.json
include package-lock.json
include tsconfig.json
include vite.config.ts

View File

@@ -9,10 +9,10 @@ localegen:
./manage.py makemessages --keep-pot --ignore "pretix/static/npm_dir/*" $(LNGS) ./manage.py makemessages --keep-pot --ignore "pretix/static/npm_dir/*" $(LNGS)
./manage.py makemessages --keep-pot -d djangojs --ignore "pretix/static/npm_dir/*" --ignore "pretix/helpers/*" --ignore "pretix/static/jsi18n/*" --ignore "pretix/static/jsi18n/*" --ignore "pretix/static.dist/*" --ignore "data/*" --ignore "pretix/static/rrule/*" --ignore "build/*" $(LNGS) ./manage.py makemessages --keep-pot -d djangojs --ignore "pretix/static/npm_dir/*" --ignore "pretix/helpers/*" --ignore "pretix/static/jsi18n/*" --ignore "pretix/static/jsi18n/*" --ignore "pretix/static.dist/*" --ignore "data/*" --ignore "pretix/static/rrule/*" --ignore "build/*" $(LNGS)
staticfiles: jsi18n staticfiles: npminstall npmbuild jsi18n
./manage.py collectstatic --noinput ./manage.py collectstatic --noinput
compress: npminstall compress:
./manage.py compress ./manage.py compress
jsi18n: localecompile jsi18n: localecompile
@@ -25,8 +25,8 @@ coverage:
coverage run -m py.test coverage run -m py.test
npminstall: npminstall:
# keep this in sync with pretix/_build.py! npm ci
mkdir -p pretix/static.dist/node_prefix/
cp -r pretix/static/npm_dir/* pretix/static.dist/node_prefix/ npmbuild:
npm ci --prefix=pretix/static.dist/node_prefix npm run build

View File

@@ -36,11 +36,7 @@ def npm_install():
global npm_installed global npm_installed
if not npm_installed: if not npm_installed:
# keep this in sync with Makefile! subprocess.check_call('npm ci', shell=True, cwd=project_root)
node_prefix = os.path.join(here, 'static.dist', 'node_prefix')
os.makedirs(node_prefix, exist_ok=True)
shutil.copytree(os.path.join(here, 'static', 'npm_dir'), node_prefix, dirs_exist_ok=True)
subprocess.check_call('npm ci', shell=True, cwd=node_prefix)
npm_installed = True npm_installed = True

View File

@@ -47,3 +47,5 @@ HAS_MEMCACHED = False
HAS_CELERY = False HAS_CELERY = False
HAS_GEOIP = False HAS_GEOIP = False
SENTRY_ENABLED = False SENTRY_ENABLED = False
VITE_DEV_MODE = False
VITE_IGNORE = False

View File

@@ -12,7 +12,7 @@ from django.utils.safestring import mark_safe
register = template.Library() register = template.Library()
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
_MANIFEST = {} _MANIFEST = {}
MANIFEST_PATH = settings.STATIC_ROOT + "pretalx-manifest.json" MANIFEST_PATH = settings.STATIC_ROOT + "/vite/control/.vite/manifest.json"
# We're building the manifest if we don't have a dev server running AND if we're # We're building the manifest if we don't have a dev server running AND if we're
# not currently running `rebuild` (which creates the manifest in the first place). # not currently running `rebuild` (which creates the manifest in the first place).