##// END OF EJS Templates
dev(static-files): new way of building static files
super-admin -
r5233:49f00b60 default
parent child Browse files
Show More
@@ -0,0 +1,39 b''
1 ## HOW TO: ##
2 ##
3 ## build this image add --no-cache for forced-build:
4
5 ## ** BUILD **
6 # docker build --tag rhodecode/static-files-build:16 -f static-build.dockerfile .
7 # docker build --tag rhodecode/static-files-build:18 -f static-build.dockerfile .
8
9 ## run grunt on top of the source code
10 ## cd rhodecode-enterprise-ce
11 ## docker run --rm -v $PWD:/project --workdir=/project rhodecode/static-files-build grunt
12
13 ## ** GENERATE **
14 ## docker run -it --entrypoint bash --rm -v $PWD:/project --workdir=/project rhodecode/static-files-build:16 -c "npm install && grunt -v"
15
16 # THIS WORKS NOW
17 FROM node:16-buster
18 #FROM node:18-buster
19
20 WORKDIR /static_build
21
22 RUN apt-get update \
23 && apt-get install --no-install-recommends --yes \
24 curl \
25 zip \
26 && apt-get autoremove \
27 && apt-get clean \
28 && rm -rf /var/lib/apt/lists/*
29
30 # make node scripts visible
31 ENV \
32 PATH=/static_build/node_modules/.bin:/project/node_modules/.bin:$PATH \
33 NODE_PATH=/node_modules/.bin/node_mod \
34 WEBPACK=/static_build/node_modules/.bin/webpack \
35 GRUNT=/static_build/node_modules/.bin/grunt
36
37 WORKDIR /project
38
39 ENTRYPOINT ["bash"]
@@ -1,205 +1,191 b''
1 1 # required for pushd to work..
2 2 SHELL = /bin/bash
3 3
4 4
5 5 # set by: PATH_TO_OUTDATED_PACKAGES=/some/path/outdated_packages.py
6 6 OUTDATED_PACKAGES = ${PATH_TO_OUTDATED_PACKAGES}
7 7
8 NODE_PATH=./node_modules
9 WEBPACK=./node_binaries/webpack
10 GRUNT=./node_binaries/grunt
11
12 8 .PHONY: clean
13 9 ## Cleanup compiled and cache py files
14 10 clean:
15 11 make test-clean
16 12 find . -type f \( -iname '*.c' -o -iname '*.pyc' -o -iname '*.so' -o -iname '*.orig' \) -exec rm '{}' ';'
17 13 find . -type d -name "build" -prune -exec rm -rf '{}' ';'
18 14
19 15
20 16 .PHONY: test
21 17 ## run test-clean and tests
22 18 test:
23 19 make test-clean
24 20 make test-only
25 21
26 22
27 23 .PHONY: test-clean
28 24 ## run test-clean and tests
29 25 test-clean:
30 26 rm -rf coverage.xml htmlcov junit.xml pylint.log result
31 27 find . -type d -name "__pycache__" -prune -exec rm -rf '{}' ';'
32 28 find . -type f \( -iname '.coverage.*' \) -exec rm '{}' ';'
33 29
34 30
35 31 .PHONY: test-only
36 32 ## Run tests only without cleanup
37 33 test-only:
38 34 PYTHONHASHSEED=random \
39 35 py.test -x -vv -r xw -p no:sugar \
40 36 --cov-report=term-missing --cov-report=html \
41 37 --cov=rhodecode rhodecode
42 38
43 39
44 40 .PHONY: test-only-mysql
45 41 ## run tests against mysql
46 42 test-only-mysql:
47 43 PYTHONHASHSEED=random \
48 44 py.test -x -vv -r xw -p no:sugar \
49 45 --cov-report=term-missing --cov-report=html \
50 46 --ini-config-override='{"app:main": {"sqlalchemy.db1.url": "mysql://root:qweqwe@localhost/rhodecode_test?charset=utf8"}}' \
51 47 --cov=rhodecode rhodecode
52 48
53 49
54 50 .PHONY: test-only-postgres
55 51 ## run tests against postgres
56 52 test-only-postgres:
57 53 PYTHONHASHSEED=random \
58 54 py.test -x -vv -r xw -p no:sugar \
59 55 --cov-report=term-missing --cov-report=html \
60 56 --ini-config-override='{"app:main": {"sqlalchemy.db1.url": "postgresql://postgres:qweqwe@localhost/rhodecode_test"}}' \
61 57 --cov=rhodecode rhodecode
62 58
63 59 .PHONY: ruff-check
64 60 ## run a ruff analysis
65 61 ruff-check:
66 62 ruff check --ignore F401 --ignore I001 --ignore E402 --ignore E501 --ignore F841 --exclude rhodecode/lib/dbmigrate --exclude .eggs --exclude .dev .
67 63
68 64
69 65 .PHONY: docs
70 66 ## build docs
71 67 docs:
72 68 (cd docs; docker run --rm -v $(PWD):/project --workdir=/project/docs sphinx-doc-build-rc make clean html)
73 69
74 70
75 71 .PHONY: docs-clean
76 72 ## Cleanup docs
77 73 docs-clean:
78 74 (cd docs; docker run --rm -v $(PWD):/project --workdir=/project/docs sphinx-doc-build-rc make clean)
79 75
80 76
81 77 .PHONY: docs-cleanup
82 78 ## Cleanup docs
83 79 docs-cleanup:
84 80 (cd docs; docker run --rm -v $(PWD):/project --workdir=/project/docs sphinx-doc-build-rc make cleanup)
85 81
86 82
87 83 .PHONY: web-build
88 84 ## Build JS packages static/js
89 # https://hub.docker.com/r/huli/grunt
90 85 web-build:
91 NODE_PATH=$(NODE_PATH) $(GRUNT)
86 docker run -it --rm -v $(PWD):/project --workdir=/project rhodecode/static-files-build:16 -c "npm install && grunt"
87 # run static file check
88 ./rhodecode/tests/scripts/static-file-check.sh rhodecode/public/
89 rm -rf node_modules
92 90
93 # check required files
94 STATIC_CHECK="/robots.txt /502.html \
95 /js/scripts.min.js /js/rhodecode-components.js \
96 /css/style.css /css/style-polymer.css /css/style-ipython.css"
97
98 for file in $STATIC_CHECK;
99 do
100 if [ ! -f rhodecode/public/$file ]; then
101 echo "Missing $file expected after web-build"
102 exit 1
103 fi
104 done
105 91
106 92 .PHONY: pip-packages
107 93 ## Show outdated packages
108 94 pip-packages:
109 95 python ${OUTDATED_PACKAGES}
110 96
111 97
112 98 .PHONY: build
113 99 ## Build sdist/egg
114 100 build:
115 101 python -m build
116 102
117 103
118 104 .PHONY: dev-sh
119 105 ## make dev-sh
120 106 dev-sh:
121 107 sudo echo "deb [trusted=yes] https://apt.fury.io/rsteube/ /" | sudo tee -a "/etc/apt/sources.list.d/fury.list"
122 108 sudo apt-get update
123 109 sudo apt-get install -y zsh carapace-bin
124 110 rm -rf /home/rhodecode/.oh-my-zsh
125 111 curl https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
126 112 echo "source <(carapace _carapace)" > /home/rhodecode/.zsrc
127 113 PROMPT='%(?.%F{green}√.%F{red}?%?)%f %B%F{240}%1~%f%b %# ' zsh
128 114
129 115
130 116 .PHONY: dev-cleanup
131 117 ## Cleanup: pip freeze | grep -v "^-e" | grep -v "@" | xargs pip uninstall -y
132 118 dev-cleanup:
133 119 pip freeze | grep -v "^-e" | grep -v "@" | xargs pip uninstall -y
134 120 rm -rf /tmp/*
135 121
136 122
137 123 .PHONY: dev-env
138 124 ## make dev-env based on the requirements files and install develop of packages
139 125 dev-env:
140 126 pip install build virtualenv
141 127 pushd ../rhodecode-vcsserver/ && make dev-env && popd
142 128 pip wheel --wheel-dir=/home/rhodecode/.cache/pip/wheels -r requirements.txt -r requirements_rc_tools.txt -r requirements_test.txt -r requirements_debug.txt
143 129 pip install --no-index --find-links=/home/rhodecode/.cache/pip/wheels -r requirements.txt -r requirements_rc_tools.txt -r requirements_test.txt -r requirements_debug.txt
144 130 pip install -e .
145 131
146 132
147 133 .PHONY: sh
148 134 ## shortcut for make dev-sh dev-env
149 135 sh:
150 136 (make dev-env; make dev-sh)
151 137
152 138
153 139 .PHONY: dev-srv
154 140 ## run develop server instance, docker exec -it $(docker ps -q --filter 'name=dev-enterprise-ce') /bin/bash
155 141 dev-srv:
156 142 pserve --reload .dev/dev.ini
157 143
158 144
159 145 .PHONY: dev-srv-g
160 146 ## run gunicorn multi process workers
161 147 dev-srv-g:
162 148 gunicorn --workers=2 --paste .dev/dev.ini --bind=0.0.0.0:10020 --config=.dev/gunicorn_config.py
163 149
164 150
165 151 # Default command on calling make
166 152 .DEFAULT_GOAL := show-help
167 153
168 154 .PHONY: show-help
169 155 show-help:
170 156 @echo "$$(tput bold)Available rules:$$(tput sgr0)"
171 157 @echo
172 158 @sed -n -e "/^## / { \
173 159 h; \
174 160 s/.*//; \
175 161 :doc" \
176 162 -e "H; \
177 163 n; \
178 164 s/^## //; \
179 165 t doc" \
180 166 -e "s/:.*//; \
181 167 G; \
182 168 s/\\n## /---/; \
183 169 s/\\n/ /g; \
184 170 p; \
185 171 }" ${MAKEFILE_LIST} \
186 172 | LC_ALL='C' sort --ignore-case \
187 173 | awk -F '---' \
188 174 -v ncol=$$(tput cols) \
189 175 -v indent=19 \
190 176 -v col_on="$$(tput setaf 6)" \
191 177 -v col_off="$$(tput sgr0)" \
192 178 '{ \
193 179 printf "%s%*s%s ", col_on, -indent, $$1, col_off; \
194 180 n = split($$2, words, " "); \
195 181 line_length = ncol - indent; \
196 182 for (i = 1; i <= n; i++) { \
197 183 line_length -= length(words[i]) + 1; \
198 184 if (line_length <= 0) { \
199 185 line_length = ncol - indent - length(words[i]) - 1; \
200 186 printf "\n%*s ", -indent, " "; \
201 187 } \
202 188 printf "%s ", words[i]; \
203 189 } \
204 190 printf "\n"; \
205 191 }'
General Comments 0
You need to be logged in to leave comments. Login now