|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Source helper functions |
| 4 | +source .fun |
| 5 | + |
| 6 | +# Proxy settings [optional] - set if your network requires a proxy to connect to the Internet |
| 7 | +export http_proxy= |
| 8 | +export https_proxy= |
| 9 | +export no_proxy=localhost |
| 10 | + |
| 11 | +# AWS settings |
| 12 | +## AWS_PROFILE - name of AWS settings profile AWS_PROFILE=default(default)|aws-do-eks|... |
| 13 | +if [ -f ${HOME}/.aws/credentials ]; then |
| 14 | + export AWS_PROFILE=${AWS_PROFILE:-default} |
| 15 | +fi |
| 16 | +## AWS_REGION - will be set to AWS_DEFAULT_REGION if not set externally. |
| 17 | +export AWS_DEFAULT_REGION=us-east-1 |
| 18 | +if [ "${AWS_REGION}" == "" ]; then |
| 19 | + export AWS_REGION=$AWS_DEFAULT_REGION |
| 20 | +fi |
| 21 | + |
| 22 | +# TO - Target Orchestrator, TO=docker|kubernetes(default) |
| 23 | +## docker - choose when running locally or on ec2 |
| 24 | +## kubernetes - choose when running on a local, remote Kubernetes cluster or EKS |
| 25 | +export TO=kubernetes |
| 26 | + |
| 27 | +# Docker image settings |
| 28 | +## REGISTRY: [optional] - Docker registry path including trailing "/". Example: registry.company.com/demo/ |
| 29 | +## If REGISTRY==default, then the default elastic container registry in the account for the current region will be used |
| 30 | +export REGISTRY=default |
| 31 | +## Set default registry if needed |
| 32 | +if [ "$REGISTRY" == "default" ]; then |
| 33 | + export REGION=${AWS_REGION} |
| 34 | + export ACCOUNT=$(aws sts get-caller-identity --query Account --output text) |
| 35 | + if [ "$ACCOUNT" == "" ]; then |
| 36 | + export REGISTRY="" |
| 37 | + else |
| 38 | + export REGISTRY=${ACCOUNT}.dkr.ecr.${REGION}.amazonaws.com/ |
| 39 | + fi |
| 40 | +fi |
| 41 | +## Add trailing forward slash if needed |
| 42 | +if [ -n "${REGISTRY}" ]; then |
| 43 | + if [ "${REGISTRY: -1}" != "/" ]; then |
| 44 | + export REGISTRY="${REGISTRY}/" |
| 45 | + fi |
| 46 | +fi |
| 47 | + |
| 48 | +## IMAGE: <required> - Docker image name for this project. Example: myapp |
| 49 | +export IMAGE=do-gromacs |
| 50 | +## VERSION: [optional] - Version tag for this Docker image. Example: v20180302 |
| 51 | +#export VERSION=v$(date +%Y%m%d) |
| 52 | +export VERSION=v20220910 |
| 53 | +export TAG=$(if [ -z "${VERSION}" ]; then echo ""; else echo ":${VERSION}"; fi) |
| 54 | + |
| 55 | +## IMAGE Build Options |
| 56 | +export SPACK_VERSION=v0.18.0 |
| 57 | +export BUILD_IMAGE=spack/amazon-linux:${SPACK_VERSION} |
| 58 | +export SPACK_CACHE_VERSION=releases/v0.18 |
| 59 | +export SPACK_TARGET=x86_64_v3 |
| 60 | +export RUN_IMAGE="public.ecr.aws/amazonlinux/amazonlinux:latest" |
| 61 | + |
| 62 | +## BUILD_OPTS: [optional] - arguments for the docker image build command |
| 63 | +export BUILD_OPTS="--build-arg http_proxy=${http_proxy} --build-arg https_proxy=${https_proxy} --build-arg no_proxy=${no_proxy} --build-arg SPACK_VERSION=${SPACK_VERSION} --build-arg BUILD_IMAGE=${BUILD_IMAGE} --build-arg SPACK_CACHE_VERSION=${SPACK_CACHE_VERSION} --build-arg SPACK_TARGET=${SPACK_TARGET} --build-arg RUN_IMAGE=${RUN_IMAGE}" |
| 64 | + |
| 65 | +# Docker TO settings |
| 66 | +## CONTAINER_NAME: [optional] - Name of the Docker container including the --name switch. Example --name myapp |
| 67 | +export CONTAINER=${IMAGE} |
| 68 | +export CONTAINER_NAME="--name ${CONTAINER}" |
| 69 | +## Port map [optional] - Mapping of external to internal ports including the -p switch. Example -p 80:8080 |
| 70 | +export PORT_MAP="-p 80:8080" |
| 71 | +## Volume map [optional] - Mapping of external to internal paths including the -v switch. Example $(pwd):/wd |
| 72 | +export VOL_MAP="-v $(pwd):/wd" |
| 73 | +## Network [optional] - Network name including the --net switch. Example --net mynet |
| 74 | +export NETWORK= |
| 75 | +## RUN_OPTS [optional] - additional options to specify with the run comman. Example -e POSTGRES_DB=dbname |
| 76 | +export RUN_OPTS="-e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION -e AWS_REGION=$AWS_REGION" |
| 77 | +if [ -f ${HOME}/.aws/credentials ]; then |
| 78 | + export RUN_OPTS="$RUN_OPTS -e AWS_PROFILE=$AWS_PROFILE" |
| 79 | +fi |
| 80 | + |
| 81 | +# Kubernetes TO settings |
| 82 | +export K8S_NAMESPACE=gromacs |
| 83 | +export K8S_PVC_NAME=fsx-pvc |
| 84 | +export K8S_PVC_SIZE=100Gi |
0 commit comments