-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] Docker build improvements (#1425)
* Improve docker file * Make it work for both latest version and released version * Fix build for macos * Fix buildx for macos * Install docker-buildx for macos-12 * Change matrix definition for docker build * Check total physical memory and DRIVER_MEM, EXECUTOR_MEM configurations before launching * Fix gresearch spark-extension version and improved code for detecting spark versions * Use array form of CMD to allow control signals to be passed to jupyter lab
- Loading branch information
1 parent
7e41f6b
commit 2de9160
Showing
7 changed files
with
157 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
docker/sedona-spark-jupyterlab/sedona-jupyterlab.dockerfile.dockerignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Ignore everything | ||
* | ||
|
||
# Allow files and folders with a pattern starting with ! | ||
!docker/** | ||
!docs/usecases/** | ||
!python/** | ||
!spark-shaded/target/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/usr/bin/env bash | ||
|
||
DRIVER_MEM=${DRIVER_MEM:-4g} | ||
EXECUTOR_MEM=${EXECUTOR_MEM:-4g} | ||
|
||
# Function to convert memory string to megabytes | ||
convert_to_mb() { | ||
local mem_str=$1 | ||
local mem_value=${mem_str%[gGmM]} | ||
local mem_unit=${mem_str: -1} | ||
|
||
case $mem_unit in | ||
[gG]) | ||
echo $(($mem_value * 1024)) | ||
;; | ||
[mM]) | ||
echo $mem_value | ||
;; | ||
*) | ||
echo "Invalid memory unit: $mem_str" >&2 | ||
return 1 | ||
;; | ||
esac | ||
} | ||
|
||
# Convert DRIVER_MEM and EXECUTOR_MEM to megabytes | ||
DRIVER_MEM_MB=$(convert_to_mb $DRIVER_MEM) | ||
if [ $? -ne 0 ]; then | ||
echo "Error converting DRIVER_MEM to megabytes." >&2 | ||
exit 1 | ||
fi | ||
|
||
EXECUTOR_MEM_MB=$(convert_to_mb $EXECUTOR_MEM) | ||
if [ $? -ne 0 ]; then | ||
echo "Error converting EXECUTOR_MEM to megabytes." >&2 | ||
exit 1 | ||
fi | ||
|
||
# Get total physical memory in megabytes | ||
TOTAL_PHYSICAL_MEM_MB=$(free -m | awk '/^Mem:/{print $2}') | ||
|
||
# Calculate the total required memory | ||
TOTAL_REQUIRED_MEM_MB=$(($DRIVER_MEM_MB + $EXECUTOR_MEM_MB)) | ||
|
||
# Compare total required memory with total physical memory | ||
if [ $TOTAL_REQUIRED_MEM_MB -gt $TOTAL_PHYSICAL_MEM_MB ]; then | ||
echo "Error: Insufficient memory" >&2 | ||
echo " total: $TOTAL_PHYSICAL_MEM_MB MB" >&2 | ||
echo " required: $TOTAL_REQUIRED_MEM_MB MB (driver: $DRIVER_MEM_MB MB, executor: $EXECUTOR_MEM_MB MB)" >&2 | ||
echo "Please tune DRIVER_MEM and EXECUTOR_MEM to smaller values." >&2 | ||
echo "e.g: docker run -e DRIVER_MEM=2g -e EXECUTOR_MEM=2g ..." >&2 | ||
exit 1 | ||
fi | ||
|
||
# Configure spark | ||
cp ${SPARK_HOME}/conf/spark-env.sh.template ${SPARK_HOME}/conf/spark-env.sh | ||
echo "SPARK_WORKER_MEMORY=${EXECUTOR_MEM}" >> ${SPARK_HOME}/conf/spark-env.sh | ||
echo "spark.driver.memory $DRIVER_MEM" >> ${SPARK_HOME}/conf/spark-defaults.conf | ||
echo "spark.executor.memory $EXECUTOR_MEM" >> ${SPARK_HOME}/conf/spark-defaults.conf | ||
|
||
# Start spark standalone cluster | ||
service ssh start | ||
${SPARK_HOME}/sbin/start-all.sh | ||
|
||
# Start jupyter lab | ||
exec jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --allow-root --NotebookApp.token= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters