Skip to content

Commit e910e30

Browse files
committed
Stop recompiling assets to enable relative url
As a result, an Internet connection is no longer required to use relative URLs. To enable relative url, we execute `gitlab:assets:compile`. This have been removed in official documentation in v10.0.0 (first committed to gitlab-foss, then ported to gitlab(-ee)) - EE: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/1139/ - CE: https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/8831 An internet connection was required when enabling relative urls to install the node modules required for compilation. I reviewed the rake task `gitlab:assets:compile` and investigated whether it was necessary to compile all assets just because the relative url changed, and found that this rake task is internally a separate rake task `gitlab:assets :fix_urls` which rewrite the reference URL in the css. I removed rake task `gitlab:assets:compile` at runtime and confirmed that the gitlab application worked normally as before. I have confirmed that at least the following functions work properly. - Administrator password reset at first login - Create empty project - Edit/add and commit files using web IDE - Create merge request/issue - Attach files to comments - Create empty group - Move existing project to group In addition, we no longer need to do following things - persist node_modules, recompiled assets and caches - apply patches to gitlab itself to avoid removing (symlink to) node_modules/ This change also reduces startup time in certain cases when the relative URL feature is enabled (when assets are compiled; for example, when performing a version upgrade or changing the relative URL) (on my environment, `gitlab:assets:fix_urls` took about 20 seconds)
1 parent 0d39d55 commit e910e30

File tree

4 files changed

+1
-33
lines changed

4 files changed

+1
-33
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ LABEL \
8484

8585
EXPOSE 22/tcp 80/tcp 443/tcp
8686

87-
VOLUME ["${GITLAB_DATA_DIR}", "${GITLAB_LOG_DIR}","${GITLAB_HOME}/gitlab/node_modules"]
87+
VOLUME ["${GITLAB_DATA_DIR}", "${GITLAB_LOG_DIR}"]
8888
WORKDIR ${GITLAB_INSTALL_DIR}
8989
ENTRYPOINT ["/sbin/entrypoint.sh"]
9090
CMD ["app:start"]
File renamed without changes.
File renamed without changes.

assets/runtime/functions

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,25 +1756,6 @@ initialize_datadir() {
17561756
chmod 700 ${GITLAB_DATA_DIR}/.ssh
17571757
chmod 600 ${GITLAB_DATA_DIR}/.ssh/authorized_keys
17581758
chown -R ${GITLAB_USER}: ${GITLAB_DATA_DIR}/.ssh
1759-
1760-
# recompile and persist assets when relative_url is in use
1761-
if [[ -n ${GITLAB_RELATIVE_URL_ROOT} ]]; then
1762-
mkdir -p ${GITLAB_TEMP_DIR}/cache
1763-
chmod 755 ${GITLAB_TEMP_DIR}/cache
1764-
chown ${GITLAB_USER}: ${GITLAB_TEMP_DIR}/cache
1765-
1766-
mkdir -p ${GITLAB_TEMP_DIR}/assets
1767-
chmod 755 ${GITLAB_TEMP_DIR}/assets
1768-
chown ${GITLAB_USER}: ${GITLAB_TEMP_DIR}/assets
1769-
1770-
# symlink ${GITLAB_INSTALL_DIR}/tmp/cache -> ${GITLAB_TEMP_DIR}/cache
1771-
rm -rf ${GITLAB_INSTALL_DIR}/tmp/cache
1772-
exec_as_git ln -s ${GITLAB_TEMP_DIR}/cache ${GITLAB_INSTALL_DIR}/tmp/cache
1773-
1774-
# symlink ${GITLAB_INSTALL_DIR}/public/assets -> ${GITLAB_TEMP_DIR}/assets
1775-
rm -rf ${GITLAB_INSTALL_DIR}/public/assets
1776-
exec_as_git ln -s ${GITLAB_TEMP_DIR}/assets ${GITLAB_INSTALL_DIR}/public/assets
1777-
fi
17781759
}
17791760

17801761
sanitize_datadir() {
@@ -2250,19 +2231,6 @@ migrate_database() {
22502231
# clear cache if relative_url has changed.
22512232
[[ -f ${GITLAB_TEMP_DIR}/GITLAB_RELATIVE_URL_ROOT ]] && CACHE_GITLAB_RELATIVE_URL_ROOT=$(cat ${GITLAB_TEMP_DIR}/GITLAB_RELATIVE_URL_ROOT)
22522233
if [[ ! -f ${GITLAB_TEMP_DIR}/GITLAB_RELATIVE_URL_ROOT || ${GITLAB_RELATIVE_URL_ROOT} != ${CACHE_GITLAB_RELATIVE_URL_ROOT} ]]; then
2253-
# assets need to be recompiled when GITLAB_RELATIVE_URL_ROOT is used
2254-
if [[ -n ${GITLAB_RELATIVE_URL_ROOT} ]]; then
2255-
if [[ ! -d ${GITLAB_HOME}/gitlab/node_modules ]]; then
2256-
mkdir -p ${GITLAB_HOME}/gitlab/node_modules
2257-
chown -R ${GITLAB_USER}: ${GITLAB_HOME}/gitlab/node_modules
2258-
fi
2259-
echo "Prepare recompile assets... Installing missing node_modules for assets"
2260-
chown -R ${GITLAB_USER}: ${GITLAB_HOME}/gitlab/node_modules
2261-
exec_as_git yarn install --production --pure-lockfile
2262-
echo "Recompiling assets (relative_url in use), this could take a while..."
2263-
exec_as_git bundle exec rake gitlab:assets:compile NODE_OPTIONS="--max-old-space-size=8192" >/dev/null 2>&1
2264-
fi
2265-
22662234
echo "Clearing cache..."
22672235
exec_as_git bundle exec rake cache:clear >/dev/null 2>&1
22682236
echo "${GITLAB_RELATIVE_URL_ROOT}" > ${GITLAB_TEMP_DIR}/GITLAB_RELATIVE_URL_ROOT

0 commit comments

Comments
 (0)