Skip to content

Commit b9fac8f

Browse files
committed
feat: docker entrypoint takes env variables for config
1 parent 5d34500 commit b9fac8f

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ FROM python:3
22

33
WORKDIR /usr/src/app
44

5-
COPY requirements.txt ./
5+
COPY . .
6+
67
RUN pip install --no-cache-dir -r requirements.txt
7-
RUN git clone https://github.com/SilverLineFramework/libsilverline.git
8-
COPY libsilverline/requirements.txt ./
8+
WORKDIR /usr/src/app/libsilverline
99
RUN pip install --no-cache-dir -r requirements.txt
1010

11-
COPY . .
12-
1311
WORKDIR /usr/src/app
1412

1513
RUN chmod +x wait-for-it.sh

docker-entrypoint.sh

100644100755
Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
#!/bin/bash
22

3-
make migrate
4-
python manage.py runserver 0.0.0.0:8000
3+
config_file=${RTCONF_CONF_FILE:-config.json}
4+
echo "Config file: "$config_file
5+
pwd_file=$(grep '"pwd"' $config_file | cut -d'"' -f 4)
6+
echo "Pwd file : "$pwd_file
7+
8+
if [[ ! -z "${RTCONF_PWD_FILE_CONTENTS}" ]]; then
9+
echo "Creating mqtt_pwd.txt from env."
10+
echo ${RTCONF_PWD_FILE_CONTENTS} > $pwd_file
11+
fi
12+
13+
for key in $(tail -n +2 config.json | head -n -1 | cut -d':' -f1 | sed 's/\"//g')
14+
do
15+
conf_key=RTCONF_`echo $key | tr '[:lower:]' '[:upper:]'`
16+
if [[ ! -z "${!conf_key}" ]]; then
17+
echo "Replacing conf: "${conf_key}:${!conf_key}
18+
sed -i "s/\"$key\"\:.*/\"$key\"\:${!conf_key},/" $config_file
19+
fi
20+
done
21+
22+
#make migrate
23+
#python manage.py runserver 0.0.0.0:8000

0 commit comments

Comments
 (0)