forked from muccg/docker-devpi
-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-entrypoint.sh
executable file
·49 lines (41 loc) · 1.64 KB
/
docker-entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
defaults() {
: "${DEVPISERVER_SERVERDIR=/data/server}"
: "${DEVPI_CLIENTDIR=/data/client}"
: "${DEVPISERVER_SECRET=$DEVPISERVER_SERVERDIR/.secret.txt}"
export DEVPISERVER_SERVERDIR DEVPI_CLIENTDIR DEVPISERVER_SECRET
echo "DEVPISERVER_SERVERDIR is ${DEVPISERVER_SERVERDIR}"
echo "DEVPI_CLIENTDIR is ${DEVPI_CLIENTDIR}"
echo "DEVPISERVER_SECRET is ${DEVPISERVER_SECRET}"
}
initialise_devpi() {
# devpi-gen-config
echo "=== Initialise devpi-server ==="
devpi-init --role=standalone --serverdir=/data/server --storage=sqlite --keyfs-cache-size=64000 --root-passwd="${DEVPI_PASSWORD}"
devpi-server --start --restrict-modify=root --host=127.0.0.1 --port=3141
sleep 1
devpi use http://localhost:3141
devpi login root --password="${DEVPI_PASSWORD}"
devpi index -y -c public pypi_whitelist='*'
devpi-server --stop
}
defaults
if [ "$1" = 'devpi' ] && [ $# -eq 1 ]; then
# First run initialization
if [ ! -f "${DEVPISERVER_SERVERDIR}/.serverversion" ]; then
echo "=== Initializing devpi-server ==="
initialise_devpi
sleep 2
fi
# Secret file (if missing/deleted)
if [ ! -f "${DEVPISERVER_SECRET}" ]; then
echo "=== Creating server secret ==="
python -c 'import base64; import os; print(base64.b64encode(os.urandom(32)).decode("ascii"), end="")' \
> "${DEVPISERVER_SECRET}"
chmod u=r,go=- -- "${DEVPISERVER_SECRET}"
fi
echo "=== Launching devpi-server ==="
exec devpi-server --secretfile="${DEVPISERVER_SECRET}" --restrict-modify=root --host=0.0.0.0 --port=3141
fi
echo "=== Running user provided command ==="
exec "$@"