Skip to content

Commit

Permalink
🐛(docker) use local user ID in the dev image
Browse files Browse the repository at this point in the history
Richie's development image can now be built using a user ID passed as a
build argument. This allows us to run commands with this default user
when starting the docker-compose app service and prevent permission
issues with mounted volumes belonging to the local user.

Fix #305
  • Loading branch information
jmaupetit committed Jul 26, 2018
1 parent ab08122 commit 61eeb0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bootstrap: ## install development dependencies
@echo 'Preparing data directory...';
@mkdir -p data/media data/static
@$(COMPOSE) build base;
@$(COMPOSE) build app;
@$(COMPOSE) build --build-arg UID=$(UID) app;
${MAKE} build-front;
@echo 'Waiting until database is up…';
$(COMPOSE_RUN_APP) dockerize -wait tcp://db:5432 -timeout 60s
Expand Down
12 changes: 9 additions & 3 deletions docker/images/dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# The base image we inherit from is richie:latest, but you can override this by
# passing a build argument to your build command, e.g.:
# passing the BASE_TAG build argument to your build command. You can also
# override the default container running user ID (e.g. 1000) thanks to the UID
# build argument (we recommend using yours). An example follows:
#
# docker build --build-arg BASE_TAG=${CIRCLE_SHA1} .
# docker build \
# --build-arg BASE_TAG=${CIRCLE_SHA1}\
# --build-arg UID=$(id -u) \
# .
#
ARG BASE_TAG=latest

Expand Down Expand Up @@ -29,4 +34,5 @@ RUN curl -sL \
rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz

# Restore the un-privileged user running the application
USER 10000
ARG UID=1000
USER ${UID}

0 comments on commit 61eeb0b

Please sign in to comment.