Blame view

docker/PYROS_DOCKER_UPDATE 2.74 KB
e64cdd09   ALEXIS-PC\alexis   improving check a...
1
#!/usr/bin/env bash
e1e75163   Alexis Koralewski   fixing issue with...
2

ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
3
# In docker/ folder
038f236d   Etienne Pallier   cleanup
4
docker_folder=$(pwd 2>&1)
ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
5

038f236d   Etienne Pallier   cleanup
6
7
8
9
10
11
12
13
14
# PRE-CONDITION : pyros container must be running
# If no container is running Start it
if ! [ $(docker ps | grep 'pyros' | wc -l) -eq 4 ] ; then
    echo "pyros-db or pyros weren't running, starting them..."
    ./PYROS_DOCKER_START
    #./PYROS_DOCKER_START.bat
fi

# Main function git pull & rebuild if necessary
156992e1   Etienne Pallier   Refactorisation P...
15
already_uptodate="Déjà à jour."
6692316e   Etienne Pallier   BUILD auto in PYR...
16
check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in" "install/requirements.txt" "doc_rst/requirements.in" "doc_rst/requirements.txt")
156992e1   Etienne Pallier   Refactorisation P...
17
18
19
20
21
22
23
check_files="${check_files[@]}"
function git_pull {
    dir=$1
    #echo $check_files
    cd $dir
    gitpull_output=$(git pull 2>&1)
    # IF git pull error (other than $already_uptodate) => stop
6692316e   Etienne Pallier   BUILD auto in PYR...
24
    if [[ $? -eq 1  && "$gitpull_output" != "$already_uptodate" ]]; then
156992e1   Etienne Pallier   Refactorisation P...
25
26
27
28
29
        echo "Git pull failed. Error message is:"
        echo $gitpull_output
        exit 1
    fi
    echo $gitpull_output
6692316e   Etienne Pallier   BUILD auto in PYR...
30
31
    # test only
    #gitpull_output=$gitpull_output."Dockerfile "
156992e1   Etienne Pallier   Refactorisation P...
32
33
34
35
    # Check if exists file changed that requires rebuild
    #for file in "${check_files[@]}"
    for f in $check_files ; do
        #echo "check $f"
6692316e   Etienne Pallier   BUILD auto in PYR...
36
37
38
39
40
        #if [ $f == "doc_rst/requirements.txt" ] ; then    
        if grep -q "$f" <<< "$gitpull_output" ; then    
            echo "WARNING : One of docker related files ($f) has been changed. You should build again the PyROS Image before going on with the UPDATE..."
            echo "=> Build & start again the PyROS image ? ([y]/n)"
            read input ; [ -z ${input} ] && input="y"
6692316e   Etienne Pallier   BUILD auto in PYR...
41
            [ $input != "y" ] && exit 1
038f236d   Etienne Pallier   cleanup
42
            (cd $docker_folder && ./PYROS_DOCKER_BUILD && ./PYROS_DOCKER_START)
6692316e   Etienne Pallier   BUILD auto in PYR...
43
44
            # BUILF only once !!!
            break
156992e1   Etienne Pallier   Refactorisation P...
45
46
47
48
49
50
        fi
    done
    cd - > /dev/null
}


ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
51
52
53
54
55
56
# I - Update Guitastro
echo
echo "**********************************"
echo "I - Updating Guitastro source code"
echo "**********************************"
echo
156992e1   Etienne Pallier   Refactorisation P...
57
git_pull ../vendor/guitastro/
156992e1   Etienne Pallier   Refactorisation P...
58

7407f600   Etienne Pallier   petites ameliorat...
59

ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
60
# II - Update PyROS
ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
61
62
63
64
65
echo
echo "**********************************"
echo "II - Updating PyROS source code"
echo "**********************************"
echo
156992e1   Etienne Pallier   Refactorisation P...
66
git_pull ../
0a1f1d83   Alexis Koralewski   Add file checking...
67

f11ebe06   Etienne Pallier   Dockerfile cleanu...
68

ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
69
70
71
72
73
74
75
76
77
# III - Update all observatories with git repo
echo
echo "**********************************"
echo "III - Updating PyROS Observatory(ies)"
echo "**********************************"
echo
# Go to PYROS observatories folder
cd ../../PYROS_OBSERVATORY/
for dir in * ; do
156992e1   Etienne Pallier   Refactorisation P...
78
    if [ -d $dir/.git ] ; then 
a56e6e0e   Etienne Pallier   comments and shor...
79
        echo "Updating observatory $dir source code"
156992e1   Etienne Pallier   Refactorisation P...
80
        git_pull $dir
a56e6e0e   Etienne Pallier   comments and shor...
81
    fi
3be8b2fc   Alexis Koralewski   Add git pull of o...
82
done
038f236d   Etienne Pallier   cleanup
83
84
85
#cd ../PYROS/docker/
cd $docker_folder

3be8b2fc   Alexis Koralewski   Add git pull of o...
86

ec1e5b33   Etienne Pallier   bugfix PYROS_DOCK...
87
88
89
90
91
92
# IV - pyros.py update => update BD + doc
echo
echo "**********************************"
echo "IV - Updating PyROS Doc & Database"
echo "**********************************"
echo
1b11a72f   Alexis Koralewski   Update docker scr...
93
docker compose exec pyros python3 pyros.py update