forked from rivenmedia/riven
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
39 lines (32 loc) · 1.15 KB
/
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
#!/bin/bash
echo "Starting Container with ${PUID:-1000}:${PGID:-1000} permissions..."
if ! [ "$PUID" -eq "$PUID" ] 2> /dev/null; then
echo "PUID is not a valid integer. Exiting..."
exit 1
fi
if ! [ "$PGID" -eq "$PGID" ] 2> /dev/null; then
echo "PGID is not a valid integer. Exiting..."
exit 1
fi
: ${USERNAME:=iceberg}
: ${GROUPNAME:=iceberg}
if ! getent group ${PGID} >/dev/null; then
addgroup -g $PGID $GROUPNAME > /dev/null
else
GROUPNAME=$(getent group ${PGID} | cut -d: -f1)
fi
if ! getent passwd ${PUID} >/dev/null; then
adduser -D -u $PUID -G $GROUPNAME $USERNAME > /dev/null
else
USERNAME=$(getent passwd ${PUID} | cut -d: -f1)
fi
USER_HOME="/home/${USERNAME}"
mkdir -p ${USER_HOME}
chown ${USERNAME}:${GROUPNAME} ${USER_HOME}
chown -R ${USERNAME}:${GROUPNAME} /iceberg
export XDG_CONFIG_HOME="${USER_HOME}/.config"
export POETRY_CACHE_DIR="${USER_HOME}/.cache/pypoetry"
su -m $USERNAME -c "poetry config virtualenvs.create false"
ORIGIN=${ORIGIN:-http://localhost:3000}
echo "Container Initialization complete."
exec su -m $USERNAME -c "cd /iceberg/backend && poetry run python3 main.py & ORIGIN=$ORIGIN node /iceberg/frontend/build"