-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·49 lines (43 loc) · 1.31 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·49 lines (43 loc) · 1.31 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
45
46
47
48
49
#!/bin/bash
# setup.sh
#
# This script sets up the CECE development environment using Docker.
# It pulls the official JCSDA image and drops you into a bash shell.
#
# Usage:
# ./setup.sh # Interactive shell
# ./setup.sh -c "command" # Execute command and exit
set -e
# Define the container image
IMAGE="jcsda/docker-gnu-openmpi-dev:1.9"
# Ensure docker is installed
if ! command -v docker &> /dev/null; then
echo "Error: Docker is not installed or not in PATH."
exit 1
fi
# Check if the image already exists locally
if docker image inspect "$IMAGE" &> /dev/null; then
echo "Docker image $IMAGE already exists locally."
echo "Checking for updates..."
docker pull "$IMAGE"
else
echo "Pulling Docker image: $IMAGE"
docker pull "$IMAGE"
fi
echo "Launching CECE Development Container..."
# Check if command mode or interactive mode
if [ "$1" = "-c" ] && [ -n "$2" ]; then
# Command mode: execute command and exit
docker run --rm \
-v "$(pwd):/work" \
-w /work \
"$IMAGE" \
/bin/bash -c "source /opt/spack-environment/activate.sh && $2"
else
# Interactive mode: drop into bash shell
docker run -it --rm \
-v "$(pwd):/work" \
-w /work \
"$IMAGE" \
/bin/bash -c "source /opt/spack-environment/activate.sh && exec bash"
fi