Skip to content

Commit

Permalink
Ditch the /deps volume (#22332)
Browse files Browse the repository at this point in the history
* Ditch the /deps volume

* TMP: remove update deps at the beggingin

* TMP: add comment
  • Loading branch information
KevinMind authored Jun 10, 2024
1 parent ee78a43 commit be592a2
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private/

# do not ignore the following files
!docker-compose.ci.yml
!docker-compose.deps.yml
!docker-compose.private.yml
!private/README.md
!deps/.keep
Expand Down
2 changes: 1 addition & 1 deletion Makefile-os
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ docker_extract_deps: ## Extract dependencies from the docker image to a local vo
docker compose run --rm --quiet-pull web make update_deps

.PHONY: up
up: setup docker_mysqld_volume_create docker_extract_deps docker_compose_up ## Create and start docker compose
up: setup docker_mysqld_volume_create docker_compose_up ## Create and start docker compose

.PHONY: down
down: docker_compose_down ## Stop the docker containers
Expand Down
1 change: 0 additions & 1 deletion docker-compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ services:
- HOST_UID=9500
volumes:
- /data/olympia
- /deps

worker:
<<: *web
12 changes: 12 additions & 0 deletions docker-compose.deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Using this file enables a mount of ./deps to /deps in the web/worker containers.
# This allows the /deps folder to be exposed on the host machine enabling editing of those files
# from the host. It is disabled by default.
services:
web: &web
volumes:
- ./deps:/deps
- ./package.json:/deps/package.json
- ./package-lock.json:/deps/package-lock.json

worker:
<<: *web
15 changes: 12 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,22 @@ services:
- supervisord -n -c /data/olympia/docker/supervisor-celery.conf
volumes:
- .:/data/olympia
- /data/olympia/src/olympia.egg-info
- storage:/data/olympia/storage
- ./deps:/deps
- ./package.json:/deps/package.json
- ./package-lock.json:/deps/package-lock.json
extra_hosts:
- "olympia.test:127.0.0.1"
restart: on-failure:5
# entrypoint.sh takes some time
# we can wait for supervisor to start
# indicating the service is ready
healthcheck:
test: [
"CMD-SHELL",
"if [ -f /data/olympia/supervisord.pid ]; then echo 'File exists'; else echo 'File not found'; exit 1; fi"
]
interval: 5s
timeout: 10s
retries: 30

web:
<<: *worker
Expand Down
11 changes: 7 additions & 4 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ fi

OLYMPIA_USER="olympia"

function get_olympia_uid() { echo "$(id -u "$OLYMPIA_USER")"; }
function get_olympia_gid() { echo "$(id -g "$OLYMPIA_USER")"; }

if [[ -n "${HOST_UID:-}" ]]; then
usermod -u ${HOST_UID} ${OLYMPIA_USER}
echo "${OLYMPIA_USER} UID: ${OLYMPIA_UID} -> ${HOST_UID}"
fi

uid=$(id -u $OLYMPIA_USER)
gid=$(id -g $OLYMPIA_USER)
# Ensure the olympia user has access to the /deps directory
time chown -R "$(get_olympia_uid):$(get_olympia_gid)" /deps
fi

cat <<EOF | su -s /bin/bash $OLYMPIA_USER
echo "Running command as ${OLYMPIA_USER} ${uid}:${gid}"
echo "Running command as ${OLYMPIA_USER} $(get_olympia_uid):$(get_olympia_gid)"
set -xue
$@
EOF

0 comments on commit be592a2

Please sign in to comment.