-
Notifications
You must be signed in to change notification settings - Fork 0
/
environment.sh
51 lines (42 loc) · 1.61 KB
/
environment.sh
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
50
51
#! /bin/bash
# Setup environment variables required to launch the services described in this
# repo. A standard install of docker compose and permission to run docker
# are the only other requirements (membership of the docker group).
#
# docker compose may be backed by podman or docker container engines, see
# https://epics-containers.github.io/main/tutorials/setup_workstation.html.
# This script must be sourced
if [ "$0" = "$BASH_SOURCE" ]; then
echo "ERROR: Please source this script (source ./environment.sh)"
exit 1
fi
# if there is a docker-compose module then load it
if [[ $(module avail docker-compose 2>/dev/null) != "" ]] ; then
module load docker-compose
fi
function check_docker {
# return 0 if docker is detected, or 1 otherwise,
# cope with the possibility that podman is aliased to docker
if [[ $(docker version) =~ "Docker" ]]&> /dev/null; then
return 0
fi
return 1
}
# set user id for the phoebus container for easy X11 forwarding.
if check_docker; then
USER_ID=$(id -u); USER_GID=$(id -g)
else
alias docker=podman
USER_ID=0; USER_GID=0
fi
# ensure local container users can access X11 server
xhost +SI:localuser:$(id -un)
# Set up the environment for compose ###########################################
# set user id for the phoebus container for easy X11 forwarding.
export UIDGID=$USER_ID:$USER_GID
# choose test profile for docker compose
export COMPOSE_PROFILES=test
# for test profile our ca-gateway publishes PVS on the loopback interface
export EPICS_CA_ADDR_LIST=127.0.0.1
# make a short alias for docker-compose for convenience
alias dc='docker compose'