dev(static-files): new way of building static files

This commit is contained in:
RhodeCode Admin 2023-12-19 09:04:49 +01:00
parent bc67143575
commit ac490e81d9
2 changed files with 43 additions and 18 deletions

View file

@ -5,10 +5,6 @@ SHELL = /bin/bash
# set by: PATH_TO_OUTDATED_PACKAGES=/some/path/outdated_packages.py # set by: PATH_TO_OUTDATED_PACKAGES=/some/path/outdated_packages.py
OUTDATED_PACKAGES = ${PATH_TO_OUTDATED_PACKAGES} OUTDATED_PACKAGES = ${PATH_TO_OUTDATED_PACKAGES}
NODE_PATH=./node_modules
WEBPACK=./node_binaries/webpack
GRUNT=./node_binaries/grunt
.PHONY: clean .PHONY: clean
## Cleanup compiled and cache py files ## Cleanup compiled and cache py files
clean: clean:
@ -86,22 +82,12 @@ docs-cleanup:
.PHONY: web-build .PHONY: web-build
## Build JS packages static/js ## Build JS packages static/js
# https://hub.docker.com/r/huli/grunt
web-build: web-build:
NODE_PATH=$(NODE_PATH) $(GRUNT) docker run -it --rm -v $(PWD):/project --workdir=/project rhodecode/static-files-build:16 -c "npm install && grunt"
# run static file check
./rhodecode/tests/scripts/static-file-check.sh rhodecode/public/
rm -rf node_modules
# check required files
STATIC_CHECK="/robots.txt /502.html \
/js/scripts.min.js /js/rhodecode-components.js \
/css/style.css /css/style-polymer.css /css/style-ipython.css"
for file in $STATIC_CHECK;
do
if [ ! -f rhodecode/public/$file ]; then
echo "Missing $file expected after web-build"
exit 1
fi
done
.PHONY: pip-packages .PHONY: pip-packages
## Show outdated packages ## Show outdated packages

39
static-build.dockerfile Normal file
View file

@ -0,0 +1,39 @@
## HOW TO: ##
##
## build this image add --no-cache for forced-build:
## ** BUILD **
# docker build --tag rhodecode/static-files-build:16 -f static-build.dockerfile .
# docker build --tag rhodecode/static-files-build:18 -f static-build.dockerfile .
## run grunt on top of the source code
## cd rhodecode-enterprise-ce
## docker run --rm -v $PWD:/project --workdir=/project rhodecode/static-files-build grunt
## ** GENERATE **
## docker run -it --entrypoint bash --rm -v $PWD:/project --workdir=/project rhodecode/static-files-build:16 -c "npm install && grunt -v"
# THIS WORKS NOW
FROM node:16-buster
#FROM node:18-buster
WORKDIR /static_build
RUN apt-get update \
&& apt-get install --no-install-recommends --yes \
curl \
zip \
&& apt-get autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# make node scripts visible
ENV \
PATH=/static_build/node_modules/.bin:/project/node_modules/.bin:$PATH \
NODE_PATH=/node_modules/.bin/node_mod \
WEBPACK=/static_build/node_modules/.bin/webpack \
GRUNT=/static_build/node_modules/.bin/grunt
WORKDIR /project
ENTRYPOINT ["bash"]