-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-entrypoint.sh
executable file
·81 lines (67 loc) · 1.84 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# Change to app folder
cd /opt/app
# Set origin
if [[ -n "${APP_GIT_REPOSITORY}" ]]
then
# Use the Git Repository specified
origin="${APP_GIT_REPOSITORY}"
else
# Use the default Git Repository
origin="${APP_GIT_REPOSITORY_DEFAULT}"
fi
# Select Upstream Branch
if [[ -n "${APP_GIT_BRANCH}" ]]
then
upstreambranch="${APP_GIT_BRANCH}"
else
upstreambranch="main"
fi
echo "Upstream Branch set to <$upstreambranch>"
# Setup git repository source
git init --initial-branch=main
git config core.sparseCheckout true
git config init.defaultBranch main
git remote add -f origin $origin
git branch --set-upstream-to=origin/$upstreambranch main
# Reset sparse checkout file list
#rm -f .git/info/sparse-checkout
# Select which folders to checkout
echo "app/" >> .git/info/sparse-checkout
echo "app/lib/" >> .git/info/sparse-checkout
# Fetch origin
git fetch origin
# Decide which version of the App to pull from Github Repository
if [[ -n "${APP_GIT_COMMIT}" ]]
then
# Echo
echo "Checkout Specific Commit Hash <${APP_GIT_COMMIT}> from upstream origin <$origin> in branch <$upstreambranch>"
# Pull a specific commit hash
git checkout $upstreambranch
git merge ${APP_GIT_COMMIT}
elif [[ -n "${APP_GIT_TAG}" ]]
then
# Echo
echo "Checkout Specific Git Tag <${APP_GIT_TAG}> from upstream origin <$origin> in branch <$upstreambranch>"
# Pull a specific tag
git checkout $upstreambranch
git merge ${APP_GIT_TAG}
else
# Echo
echo "Checkout latest version from upstream origin <$origin> in branch <$upstreambranch>"
# Pull latest version
git pull --no-commit origin $upstreambranch --ff-only --depth=1
fi
# Infinite loop to debug
if [[ -v ENABLE_DEBUG_LOOP ]]
then
if [[ "$ENABLE_DEBUG_LOOP" -eq "1" ]]
then
while true
do
sleep 5
done
fi
fi
# Launch App
python -u app/app.py