-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild_base_image.sh
More file actions
executable file
·44 lines (36 loc) · 1.12 KB
/
build_base_image.sh
File metadata and controls
executable file
·44 lines (36 loc) · 1.12 KB
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
# Inicializa un array vacío
args=()
# Lee el archivo .env línea por línea
IFS='='
while IFS='=' read -r key value _; do
value="${value%$'\r'}"
echo "key: $key"
echo "value: $value"
if [[ $key != \#* && $key != '' ]]; then # Excluye comentarios y líneas vacías
args+=(--build-arg "$key=$value") # Agrega --build-arg y la variable como un elemento
else
echo "Skipping $key = $value"
fi
done < docker/.env
echo "Args:" "${args[@]}"
# Ejecuta docker build con los argumentos
PROJECT_NAME='dvats'
echo "Get docker"
DOCKER=$1
VERSION=$2
#IMAGE_GOALS='conda-miniconda3'
USER_NAME=$(id -un)
echo "DOCKER: $DOCKER"
if [ "$DOCKER" = 'jupyter' ]; then
DOCKERFILE=./docker/Dockerfile.jupyter.base
else
DOCKERFILE=./docker/Dockerfile.rstudio.base
fi
echo "Dockerfile: $DOCKERFILE"
IMAGE_NAME=${PROJECT_NAME}-$DOCKER':'$VERSION
#read -p "Docker $DOCKER Dockerfile: $DOCKERFILE Image: $IMAGE_NAME"
# Si la imagen depende de usuario para rutas
# Usar :USER_NAME detrás de IMAGE_GOALS,
# Antes de :latest
echo "IMAGE_NAME: $IMAGE_NAME"
docker build "${args[@]}" . -f ${DOCKERFILE} -t ${IMAGE_NAME}