Commit 038f236d4060d6f68c0e41f8e8722c84cfe70cec
1 parent
6692316e
Exists in
dev
cleanup
Showing
1 changed file
with
14 additions
and
26 deletions
Show diff stats
docker/PYROS_DOCKER_UPDATE
1 | #!/usr/bin/env bash | 1 | #!/usr/bin/env bash |
2 | 2 | ||
3 | # In docker/ folder | 3 | # In docker/ folder |
4 | -root_folder=$(pwd 2>&1) | 4 | +docker_folder=$(pwd 2>&1) |
5 | 5 | ||
6 | +# PRE-CONDITION : pyros container must be running | ||
7 | +# If no container is running Start it | ||
8 | +if ! [ $(docker ps | grep 'pyros' | wc -l) -eq 4 ] ; then | ||
9 | + echo "pyros-db or pyros weren't running, starting them..." | ||
10 | + ./PYROS_DOCKER_START | ||
11 | + #./PYROS_DOCKER_START.bat | ||
12 | +fi | ||
13 | + | ||
14 | +# Main function git pull & rebuild if necessary | ||
6 | already_uptodate="Déjà à jour." | 15 | already_uptodate="Déjà à jour." |
7 | check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in" "install/requirements.txt" "doc_rst/requirements.in" "doc_rst/requirements.txt") | 16 | check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in" "install/requirements.txt" "doc_rst/requirements.in" "doc_rst/requirements.txt") |
8 | check_files="${check_files[@]}" | 17 | check_files="${check_files[@]}" |
@@ -20,7 +29,6 @@ function git_pull { | @@ -20,7 +29,6 @@ function git_pull { | ||
20 | echo $gitpull_output | 29 | echo $gitpull_output |
21 | # test only | 30 | # test only |
22 | #gitpull_output=$gitpull_output."Dockerfile " | 31 | #gitpull_output=$gitpull_output."Dockerfile " |
23 | - #gitpull_output=$gitpull_output."doc_rst/requirements.txt " | ||
24 | # Check if exists file changed that requires rebuild | 32 | # Check if exists file changed that requires rebuild |
25 | #for file in "${check_files[@]}" | 33 | #for file in "${check_files[@]}" |
26 | for f in $check_files ; do | 34 | for f in $check_files ; do |
@@ -30,10 +38,8 @@ function git_pull { | @@ -30,10 +38,8 @@ function git_pull { | ||
30 | echo "WARNING : One of docker related files ($f) has been changed. You should build again the PyROS Image before going on with the UPDATE..." | 38 | echo "WARNING : One of docker related files ($f) has been changed. You should build again the PyROS Image before going on with the UPDATE..." |
31 | echo "=> Build & start again the PyROS image ? ([y]/n)" | 39 | echo "=> Build & start again the PyROS image ? ([y]/n)" |
32 | read input ; [ -z ${input} ] && input="y" | 40 | read input ; [ -z ${input} ] && input="y" |
33 | - #echo $answer | ||
34 | [ $input != "y" ] && exit 1 | 41 | [ $input != "y" ] && exit 1 |
35 | - #echo $root_folder | ||
36 | - (cd $root_folder && ./PYROS_DOCKER_BUILD && ./PYROS_DOCKER_START) | 42 | + (cd $docker_folder && ./PYROS_DOCKER_BUILD && ./PYROS_DOCKER_START) |
37 | # BUILF only once !!! | 43 | # BUILF only once !!! |
38 | break | 44 | break |
39 | fi | 45 | fi |
@@ -42,41 +48,22 @@ function git_pull { | @@ -42,41 +48,22 @@ function git_pull { | ||
42 | } | 48 | } |
43 | 49 | ||
44 | 50 | ||
45 | -# PRE-CONDITION : pyros container must be running | ||
46 | -# If no container is running Start it | ||
47 | -if ! [ $(docker ps | grep 'pyros' | wc -l) -eq 4 ] ; then | ||
48 | - echo "pyros-db or pyros weren't running, starting them..." | ||
49 | - ./PYROS_DOCKER_START | ||
50 | - #./PYROS_DOCKER_START.bat | ||
51 | -fi | ||
52 | - | ||
53 | # I - Update Guitastro | 51 | # I - Update Guitastro |
54 | echo | 52 | echo |
55 | echo "**********************************" | 53 | echo "**********************************" |
56 | echo "I - Updating Guitastro source code" | 54 | echo "I - Updating Guitastro source code" |
57 | echo "**********************************" | 55 | echo "**********************************" |
58 | echo | 56 | echo |
59 | -# Go to GuitAstro/ folder | ||
60 | git_pull ../vendor/guitastro/ | 57 | git_pull ../vendor/guitastro/ |
61 | -#check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in") | ||
62 | -#git_pull ../vendor/guitastro/ ${check_files[@]} | ||
63 | 58 | ||
64 | 59 | ||
65 | # II - Update PyROS | 60 | # II - Update PyROS |
66 | -#cd $root_folder | ||
67 | echo | 61 | echo |
68 | echo "**********************************" | 62 | echo "**********************************" |
69 | echo "II - Updating PyROS source code" | 63 | echo "II - Updating PyROS source code" |
70 | echo "**********************************" | 64 | echo "**********************************" |
71 | echo | 65 | echo |
72 | -# Go to PYROS/ folder | ||
73 | git_pull ../ | 66 | git_pull ../ |
74 | -# Check if exists file changed that requires rebuild | ||
75 | -#check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in") | ||
76 | - | ||
77 | - | ||
78 | -# TODO : test if git pull worked and if git pull changed dockerfile, requirements.in, docker-compose.yml | ||
79 | -# Tell user to rebuild | ||
80 | 67 | ||
81 | 68 | ||
82 | # III - Update all observatories with git repo | 69 | # III - Update all observatories with git repo |
@@ -91,10 +78,11 @@ for dir in * ; do | @@ -91,10 +78,11 @@ for dir in * ; do | ||
91 | if [ -d $dir/.git ] ; then | 78 | if [ -d $dir/.git ] ; then |
92 | echo "Updating observatory $dir source code" | 79 | echo "Updating observatory $dir source code" |
93 | git_pull $dir | 80 | git_pull $dir |
94 | - #cd ../ | ||
95 | fi | 81 | fi |
96 | done | 82 | done |
97 | -cd ../PYROS/docker/ | 83 | +#cd ../PYROS/docker/ |
84 | +cd $docker_folder | ||
85 | + | ||
98 | 86 | ||
99 | # IV - pyros.py update => update BD + doc | 87 | # IV - pyros.py update => update BD + doc |
100 | echo | 88 | echo |