Commit a618e139 authored by BAIRE Anthony's avatar BAIRE Anthony

store the DOCKER_USER variable inside the .env file

prepare.sh now needs to be sourced only once (when bootstrapping
the containers)
parent f60bc405
......@@ -6,3 +6,4 @@ docker/cover.copy
__pycache__
.coverage
/toolbox/openssh-*.deb
/.env
......@@ -81,7 +81,9 @@ it is tricky to use a relative path with the allgo/docker image).
For convenience, all containers not running as root (rails, mysql, registry)
have their user overridden to the UID:GID of the developer running
docker-compose. This is managed with the `DOCKER_USER` environment variable set
by `prepare.sh`.
[in the `.env`
file](https://docs.docker.com/compose/environment-variables/#the-env-file) by
`prepare.sh`.
For convenience (again), there is an extra external volumes for `dev-rails`,
`dev-controller` and `dev-ssh` so that the source directory of the app is mounted
......@@ -112,12 +114,7 @@ To set up the development environment, run:
sudo chown USER: /data/dev
</pre>
3. source the `prepare.sh` script (to be run every time before you start working)
<pre>
. ./prepare.sh
</pre>
4. bootstrap the environment
3. bootstrap the environment
<pre>
./bootstrap
</pre>
......@@ -134,7 +131,7 @@ To set up the development environment, run:
./bootstrap dev-mysql dev-rails
</pre>
5. for convenience, you may want to alias `docker-compose` as `fig` (because
4. for convenience, you may want to alias `docker-compose` as `fig` (because
`fig` is much faster to type than `docker-compose` and you will have to
type it a lot). Somewhere in your `.bashrc` you should add:
<pre>
......
......@@ -2,7 +2,6 @@
set -e
old_du="$DOCKER_USER"
. prepare.sh
# build base image (if not present)
......@@ -56,8 +55,3 @@ do
fi
done
if [ -z "$old_du" ]
then
echo 'NOTE: the env variable DOCKER_USER is not set. You should run ". prepare.sh" before working'
fi
export DOCKER_USER="`id -u`:`id -g`"
for ctr in registry rails controller ssh mysql smtpsink nginx
do
mkdir -p "./data/$ctr"
done
if [ ! -f "prepare.sh" ] ; then
echo "error: prepare.sh must be run from the same directory"
false
else
# make directories for the external volumes, and with the right
# ownership (the current user)
for ctr in registry rails controller ssh mysql smtpsink nginx
do
mkdir -p "./data/$ctr"
done
# generate a .env file for docker-compose
cat >".env.tmp" <<EOF
DOCKER_USER="`id -u`:`id -g`"
EOF
if [ ! -e .env ] ; then
mv .env.tmp .env
else
if cmp --quiet .env .env.tmp ; then
rm .env.tmp
else
echo "error: config file '.env' already exists and is different from the generate config. Remove it if you want it to be overwritten."
diff -u .env .env.tmp
false
fi
fi
fi
......@@ -7,8 +7,6 @@ if [ -z "$CTR" ] ; then
exit 1
fi
. prepare.sh
set -ex
fig up -d "$CTR"
docker exec -t -i -- "$CTR" /bin/bash
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment