Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove need to run invoke update after docker pull #6524

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5205846
first implementation of improved docker
ChristianSchindler Jan 21, 2024
65f6a51
Merge branch 'master' of https://github.com/inventree/InvenTree into …
matmair Feb 19, 2024
c7fae4c
move execute skript
matmair Feb 19, 2024
28d06a4
reintroduce seperate worker task
matmair Feb 19, 2024
34a2586
reset work command
matmair Feb 19, 2024
6c33c5f
run database checks
matmair Feb 19, 2024
028b61f
Merge branch 'inventree:master' into pr/ChristianSchindler/6305
matmair Mar 27, 2024
839d9f9
Merge branch 'inventree:master' into pr/ChristianSchindler/6305
matmair Apr 2, 2024
c778094
style fix
matmair Apr 2, 2024
785aff0
Merge branch 'master' of https://github.com/inventree/InvenTree into …
matmair Apr 3, 2024
2d89f06
Merge branch 'inventree:master' into pr/ChristianSchindler/6305
matmair Apr 16, 2024
1dd52c2
Merge branch 'inventree:master' into pr/ChristianSchindler/6305
matmair Apr 23, 2024
bc9704b
Merge branch 'master' into pr/ChristianSchindler/6305
matmair Jun 7, 2024
27de080
Merge branch 'master' of https://github.com/inventree/InvenTree into …
matmair Jun 26, 2024
6d22701
Merge branch 'master' into pr/ChristianSchindler/6305
matmair Jul 17, 2024
d3ec46c
Merge branch 'master' into pr/ChristianSchindler/6305
matmair Jul 22, 2024
fbca4c0
Update Dockerfile
matmair Jul 22, 2024
6f2ada1
Merge branch 'master' into pr/ChristianSchindler/6305
matmair Aug 9, 2024
7b88d0c
Merge branch 'master' into pr/ChristianSchindler/6305
matmair Aug 19, 2024
9a42167
move to using api_version
matmair Aug 20, 2024
7d10d69
fix typo
matmair Aug 20, 2024
51ce61a
remove unneeded section
matmair Aug 20, 2024
218f9c0
Make safer to execute
matmair Aug 20, 2024
ac33170
Merge branch 'master' into pr/ChristianSchindler/6305
matmair Aug 23, 2024
8d8fbd4
Update contrib/container/execute.sh
matmair Aug 23, 2024
c46fd85
Merge branch 'master' into pr/ChristianSchindler/6305
SchrodingersGat Nov 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions contrib/container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ COPY src ${INVENTREE_HOME}/src
COPY tasks.py ${INVENTREE_HOME}/tasks.py
RUN cd ${INVENTREE_HOME} && inv frontend-compile

COPY contrib/container/execute.sh ${INVENTREE_HOME}/execute.sh
RUN chmod +x ${INVENTREE_HOME}/execute.sh

# InvenTree production image:
# - Copies required files from local directory
# - Starts a gunicorn webserver
Expand Down
40 changes: 40 additions & 0 deletions contrib/container/execute.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh

# File to check existence
db_version_old="${INVENTREE_HOME}/db_version.old"
new_version="$(python3 ${INVENTREE_HOME}/.github/scripts/version_check.py only_version)"

# Check if the file exists
if [ ! -e "$db_version_old" ]; then
echo "New Installation DB is getting initialised"
# Run setup command
invoke update || exit 2

echo "Setup command completed."
echo "$new_version" > "$db_version_old"
fi
matmair marked this conversation as resolved.
Show resolved Hide resolved
old_version=$(cat "$db_version_old")
echo "old version $old_version"
echo "new version $new_version"
# Number to compare (replace with your actual value)

# Check if the stored version is smaller than new one
if [ "$(awk -v num1=$new_version -v num2=$old_version 'BEGIN { print (num1 < num2) }')" -eq 1 ]; then
echo "Error: Downgrade of version is not allowed."
echo "Old DB version was $old_version, and the new version is $new_version"
exit 1
fi

if [ "$(awk -v num1=$old_version -v num2=$new_version 'BEGIN { print (num1 < num2) }')" -eq 1 ]; then
echo "DB upgrade available: Version was $old_version, new version is $new_version"

# Run update command
invoke update || exit 2

echo "Update successful"

# Write the the new version to the old version file after update
echo "$new_version" > "$db_version_old"
fi

echo "Database migration/update checks completed."
6 changes: 6 additions & 0 deletions contrib/container/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,11 @@ fi

cd ${INVENTREE_HOME}

# Check for database updates
if($2 == 'server') then
matmair marked this conversation as resolved.
Show resolved Hide resolved
echo "Running database update checks"
source ./execute.sh
matmair marked this conversation as resolved.
Show resolved Hide resolved
fi

# Launch the CMD *after* the ENTRYPOINT completes
exec "$@"
Loading