diff --git a/Dockerfile b/Dockerfile index 21dcad79a82..9dfdaf7feb1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,13 +10,24 @@ ENV BUILD_INFO=/build-info.json SHELL ["/bin/bash", "-xue", "-c"] ENV OLYMPIA_UID=9500 +# give olympia access to the HOME directory +ENV HOME=/data/olympia +ENV DEPS_DIR=${HOME}/deps +ENV NPM_DEPS_DIR=${HOME}/node_modules + RUN < settings_local.py -DJANGO_SETTINGS_MODULE="settings_local" make -f Makefile-docker update_assets +make -f Makefile-docker update_assets EOF FROM base AS production @@ -194,4 +199,4 @@ COPY --from=info ${BUILD_INFO} ${BUILD_INFO} # Copy compiled locales from builder COPY --from=locales --chown=olympia:olympia ${HOME}/locale ${HOME}/locale # Copy dependencies from `pip_production` -COPY --from=pip_production --chown=olympia:olympia /deps /deps +COPY --from=pip_production --chown=olympia:olympia ${DEPS_DIR} ${DEPS_DIR} diff --git a/Makefile-docker b/Makefile-docker index 87c2ef8c6bc..a329887349b 100644 --- a/Makefile-docker +++ b/Makefile-docker @@ -8,16 +8,6 @@ export PYTHON_COMMAND=python3 export PIP_COMMAND=$(PYTHON_COMMAND) -m pip APP=src/olympia/ -NODE_MODULES := $(NPM_CONFIG_PREFIX)node_modules/ - -REQUIRED_FILES := \ - Makefile \ - Makefile-os \ - Makefile-docker \ - /deps/package.json \ - /deps/package-lock.json \ - /addons-server-docker-container \ - # Build list of dependencies to install DEPS = pip prod # If we're running a development image, then we should install the development dependencies @@ -72,14 +62,8 @@ data_load: ./manage.py data_load $(ARGS) .PHONY: update_assets -update_assets: - # Copy files required in compress_assets to the static folder - # If changing this here, make sure to adapt tests in amo/test_commands.py - $(PYTHON_COMMAND) manage.py compress_assets - $(PYTHON_COMMAND) manage.py generate_jsi18n_files - # Collect static files: This MUST be run last or files will be missing - $(PYTHON_COMMAND) manage.py collectstatic --noinput - +update_assets: ## Update the static assets + $(HOME)/scripts/update_assets.py .PHONY: update_deps update_deps: ## Update the dependencies @@ -94,7 +78,7 @@ setup-ui-tests: lint: ## lint the code ruff check . ruff format --check . - NODE_PATH=$(NODE_MODULES) npm exec $(NPM_ARGS) -- prettier --check '**' + npm exec $(NPM_ARGS) -- prettier --check '**' curlylint src/ lint-codestyle: lint @@ -199,15 +183,15 @@ test_failed: ## rerun the failed tests from the previous run .PHONY: run_js_tests run_js_tests: ## Run the JavaScript test suite (requires compiled/compressed assets). - NODE_PATH=$(NODE_MODULES) npm exec $(NPM_ARGS) -- jest tests/js + npm exec $(NPM_ARGS) -- jest tests/js .PHONY: watch_js_tests watch_js_tests: ## Run+watch the JavaScript test suite (requires compiled/compressed assets). - NODE_PATH=$(NODE_MODULES) npm exec $(NPM_ARGS) -- jest --watch + npm exec $(NPM_ARGS) -- jest --watch .PHONY: format format: ## Autoformat our codebase. - NODE_PATH=$(NODE_MODULES) npm exec $(NPM_ARGS) -- prettier --write '**' + npm exec $(NPM_ARGS) -- prettier --write '**' ruff check --fix-only . ruff format . @@ -218,7 +202,7 @@ extract_locales: ## extracts and merges translation strings .PHONE: compile_locales compile_locales: ## compiles translation strings $(PIP_COMMAND) install --progress-bar=off --no-deps -r requirements/locale.txt - ./locale/compile-mo.sh ./locale/ + $(HOME)/scripts/compile_locales.py .PHONY: help_submake help_submake: diff --git a/Makefile-os b/Makefile-os index e3079503fcd..1eba7b16701 100644 --- a/Makefile-os +++ b/Makefile-os @@ -153,17 +153,17 @@ docker_clean_build_cache: ## Remove buildx build cache .PHONY: clean_docker clean_docker: docker_compose_down docker_mysqld_volume_remove docker_clean_images docker_clean_volumes docker_clean_build_cache ## Remove all docker resources taking space on the host machine -.PHONY: docker_update_deps -docker_update_deps: docker_mysqld_volume_create ## Update the dependencies in the container based on the docker tag and target +.PHONY: docker_sync_host +docker_sync_host: docker_mysqld_volume_create ## Update the dependencies in the container based on the docker tag and target docker compose run \ --rm \ --no-deps \ $(DOCKER_RUN_ARGS) \ web \ - make update_deps + ./scripts/sync_host_files.py .PHONY: up_pre -up_pre: setup docker_pull_or_build docker_update_deps ## Pre-up the environment, setup files, volumes and host state +up_pre: setup docker_pull_or_build docker_sync_host ## Pre-up the environment, setup files, volumes and host state .PHONY: up_start up_start: docker_mysqld_volume_create ## Start the docker containers diff --git a/docker-compose.yml b/docker-compose.yml index 4e847cacc98..27a7d852013 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -46,9 +46,9 @@ services: volumes: # used by: web, worker, nginx - ${HOST_MOUNT_SOURCE:?}:/data/olympia - - ${HOST_MOUNT_SOURCE:?}deps:/deps - - data_site_static:/data/olympia/site-static - - ${HOST_MOUNT_SOURCE:?}storage:/data/olympia/storage + - ${HOST_MOUNT_SOURCE:?}deps:/data/olympia/deps + - ./site-static:/data/olympia/site-static + - ./storage:/data/olympia/storage worker: <<: *olympia command: [ @@ -64,8 +64,8 @@ services: ] volumes: - ${HOST_MOUNT_SOURCE:?}:/data/olympia - - ${HOST_MOUNT_SOURCE:?}deps:/deps - - ${HOST_MOUNT_SOURCE:?}storage:/data/olympia/storage + - ${HOST_MOUNT_SOURCE:?}deps:/data/olympia/deps + - ./storage:/data/olympia/storage extra_hosts: - "olympia.test:127.0.0.1" restart: on-failure:5 diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index e3f59fcdc48..1a8bf6764fd 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -30,10 +30,10 @@ fi NEW_HOST_UID=$(get_olympia_uid) OLYMPIA_ID_STRING="${NEW_HOST_UID}:$(get_olympia_gid)" -# If we are on production mode, update the ownership of /data/olympia and /deps to match the new id +# If we are on production mode, update the ownership of /data/olympia to match the new id if [[ "${HOST_MOUNT}" == "production" ]]; then - echo "Updating ownership of /data/olympia and /deps to ${OLYMPIA_ID_STRING}" - chown -R ${OLYMPIA_ID_STRING} /data/olympia /deps + echo "Updating ownership of /data/olympia to ${OLYMPIA_ID_STRING}" + chown -R ${OLYMPIA_ID_STRING} /data/olympia fi cat <