Make Docker runs friendlier to the contents of the host filesystem, particularly for Linux users.

This commit is contained in:
Kris Maglione 2015-08-06 22:36:40 -07:00
Родитель d881f53917
Коммит 4804f14dff
3 изменённых файлов: 20 добавлений и 0 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -37,6 +37,7 @@ tags
vagrantconfig_local.yaml
vagrant/manifests/classes/custom.pp
node_modules
.npm/
commonplace_projects
media/fireplace
media/rocketfuel

Просмотреть файл

@ -1,6 +1,7 @@
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
entrypoint: ./scripts/start-docker.sh
ports:
- "8000:8000"
volumes:
@ -17,6 +18,7 @@ web:
- REDIS_LOCATION=redis:6379
- MYSQL_ROOT_PASSWORD='docker'
- MYSQL_DATABASE='olympia'
- PYTHONDONTWRITEBYTECODE=1
memcached:
image: memcached

17
scripts/start-docker.sh Executable file
Просмотреть файл

@ -0,0 +1,17 @@
#!/bin/sh
# The current directory is a mounted volume, and is owned by the
# user running Docker on the host machine.
#
# We don't want to trample all over the contents of this directory
# with files owned by root. So create a new user with the same UID,
# and drop privileges before running any commands.
# Get the numeric user ID of the current directory.
uid=$(ls -nd . | awk '{ print $3 }')
# Create an `olympia` user with that ID, and the current directory
# as its home directory.
useradd -Md $(pwd) -u $uid olympia
# Switch to that user and execute our actual command.
exec su olympia -c 'exec "$@"' sh "$@"