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