diff --git a/docker-compose.yml b/docker-compose.yml index 3f818755..973e295b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,120 +1,121 @@ version: '3' services: - frontend: - #build: ./frontend - image: ghcr.io/frikky/shuffle-frontend:nightly - container_name: shuffle-frontend - hostname: shuffle-frontend - ports: - - "${FRONTEND_PORT}:80" - - "${FRONTEND_PORT_HTTPS}:443" - networks: - - shuffle - environment: - - BACKEND_HOSTNAME=${BACKEND_HOSTNAME} - restart: unless-stopped - depends_on: - - backend - backend: - #build: ./backend - image: ghcr.io/frikky/shuffle-backend:nightly - container_name: shuffle-backend - hostname: ${BACKEND_HOSTNAME} - # Here for debugging: - ports: - - "${BACKEND_PORT}:5001" - networks: - - shuffle - volumes: - - /var/run/docker.sock:/var/run/docker.sock - - ${SHUFFLE_APP_HOTLOAD_LOCATION}:/shuffle-apps:z - - ${SHUFFLE_FILE_LOCATION}:/shuffle-files:z - #- ${SHUFFLE_OPENSEARCH_CERTIFICATE_FILE}:/shuffle-files/es_certificate - env_file: .env - environment: - - SHUFFLE_APP_HOTLOAD_FOLDER=/shuffle-apps - - SHUFFLE_FILE_LOCATION=/shuffle-files - restart: unless-stopped - #depends_on: - #- opensearch #Not necessary because dependancy is handled within the backend itself instead - #- database - orborus: - image: ghcr.io/frikky/shuffle-orborus:latest - container_name: shuffle-orborus - hostname: shuffle-orborus - networks: - - shuffle - volumes: - - /var/run/docker.sock:/var/run/docker.sock - environment: - - SHUFFLE_WORKER_VERSION=latest - - ENVIRONMENT_NAME=${ENVIRONMENT_NAME} - - BASE_URL=http://${OUTER_HOSTNAME}:5001 - - DOCKER_API_VERSION=1.40 - - SHUFFLE_BASE_IMAGE_NAME=${SHUFFLE_BASE_IMAGE_NAME} - - SHUFFLE_BASE_IMAGE_REGISTRY=${SHUFFLE_BASE_IMAGE_REGISTRY} - - SHUFFLE_BASE_IMAGE_TAG_SUFFIX=${SHUFFLE_BASE_IMAGE_TAG_SUFFIX} - - HTTP_PROXY=${HTTP_PROXY} - - HTTPS_PROXY=${HTTPS_PROXY} - - SHUFFLE_PASS_WORKER_PROXY=${SHUFFLE_PASS_WORKER_PROXY} - - SHUFFLE_PASS_APP_PROXY=${SHUFFLE_PASS_APP_PROXY} - - SHUFFLE_SWARM_NETWORK_NAME=shuffle_swarm_executions - - SHUFFLE_SCALE_REPLICAS=1 - - SHUFFLE_SWARM_CONFIG=runn - restart: unless-stopped - security_opt: - - seccomp:unconfined - opensearch: - image: opensearchproject/opensearch:1.2.4 - hostname: shuffle-opensearch - container_name: shuffle-opensearch - environment: - - bootstrap.memory_lock=true - - "OPENSEARCH_JAVA_OPTS=-Xms1024m -Xmx1024m" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM - - cluster.routing.allocation.disk.threshold_enabled=false - - cluster.name=shuffle-cluster - - node.name=shuffle-opensearch - - discovery.seed_hosts=shuffle-opensearch - - cluster.initial_master_nodes=shuffle-opensearch - - node.store.allow_mmap=false - ulimits: - memlock: - soft: -1 - hard: -1 - nofile: - soft: 65536 - hard: 65536 - volumes: - - ${DB_LOCATION}:/usr/share/opensearch/data:z - ports: - - 9200:9200 - networks: - - shuffle - restart: unless-stopped - #docker-socket-proxy: - # image: tecnativa/docker-socket-proxy - # privileged: true - # environment: - # - SERVICES=1 - # - TASKS=1 - # - NETWORKS=1 - # - NODES=1 - # - BUILD=1 - # - IMAGES=1 - # - GRPC=1 - # - CONTAINERS=1 - # - PLUGINS=1 - # - SYSTEM=1 - # - VOLUMES=1 - # - INFO=1 - # - DISTRIBUTION=1 - # - POST=1 - # - AUTH=1 - # - SECRETS=1 - # volumes: - # - /var/run/docker.sock:/var/run/docker.sock + #frontend: + # #build: ./frontend + # image: ghcr.io/frikky/shuffle-frontend:nightly + # container_name: shuffle-frontend + # hostname: shuffle-frontend + # ports: + # - "${FRONTEND_PORT}:80" + # - "${FRONTEND_PORT_HTTPS}:443" # networks: # - shuffle + # environment: + # - BACKEND_HOSTNAME=${BACKEND_HOSTNAME} + # restart: unless-stopped + # depends_on: + # - backend + #backend: + # #build: ./backend + # image: ghcr.io/frikky/shuffle-backend:nightly + # container_name: shuffle-backend + # hostname: ${BACKEND_HOSTNAME} + # # Here for debugging: + # ports: + # - "${BACKEND_PORT}:5001" + # networks: + # - shuffle + # volumes: + # - /var/run/docker.sock:/var/run/docker.sock + # - ${SHUFFLE_APP_HOTLOAD_LOCATION}:/shuffle-apps:z + # - ${SHUFFLE_FILE_LOCATION}:/shuffle-files:z + # #- ${SHUFFLE_OPENSEARCH_CERTIFICATE_FILE}:/shuffle-files/es_certificate + # env_file: .env + # environment: + # - SHUFFLE_APP_HOTLOAD_FOLDER=/shuffle-apps + # - SHUFFLE_FILE_LOCATION=/shuffle-files + # restart: unless-stopped + # #depends_on: + # #- opensearch #Not necessary because dependancy is handled within the backend itself instead + # #- database + #orborus: + # image: ghcr.io/frikky/shuffle-orborus:latest + # container_name: shuffle-orborus + # hostname: shuffle-orborus + # networks: + # - shuffle + # volumes: + # - /var/run/docker.sock:/var/run/docker.sock + # environment: + # - SHUFFLE_WORKER_VERSION=latest + # - ENVIRONMENT_NAME=${ENVIRONMENT_NAME} + # - BASE_URL=http://${OUTER_HOSTNAME}:5001 + # - DOCKER_API_VERSION=1.40 + # - SHUFFLE_BASE_IMAGE_NAME=${SHUFFLE_BASE_IMAGE_NAME} + # - SHUFFLE_BASE_IMAGE_REGISTRY=${SHUFFLE_BASE_IMAGE_REGISTRY} + # - SHUFFLE_BASE_IMAGE_TAG_SUFFIX=${SHUFFLE_BASE_IMAGE_TAG_SUFFIX} + # - HTTP_PROXY=${HTTP_PROXY} + # - HTTPS_PROXY=${HTTPS_PROXY} + # - SHUFFLE_PASS_WORKER_PROXY=${SHUFFLE_PASS_WORKER_PROXY} + # - SHUFFLE_PASS_APP_PROXY=${SHUFFLE_PASS_APP_PROXY} + # - SHUFFLE_SWARM_NETWORK_NAME=shuffle_swarm_executions + # - SHUFFLE_SCALE_REPLICAS=1 + # - SHUFFLE_SWARM_CONFIG=runn + # restart: unless-stopped + # security_opt: + # - seccomp:unconfined + #opensearch: + # image: opensearchproject/opensearch:1.2.4 + # hostname: shuffle-opensearch + # container_name: shuffle-opensearch + # environment: + # - bootstrap.memory_lock=true + # - "OPENSEARCH_JAVA_OPTS=-Xms1024m -Xmx1024m" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM + # - cluster.routing.allocation.disk.threshold_enabled=false + # - cluster.name=shuffle-cluster + # - node.name=shuffle-opensearch + # - discovery.seed_hosts=shuffle-opensearch + # - cluster.initial_master_nodes=shuffle-opensearch + # - node.store.allow_mmap=false + # ulimits: + # memlock: + # soft: -1 + # hard: -1 + # nofile: + # soft: 65536 + # hard: 65536 + # volumes: + # - ${DB_LOCATION}:/usr/share/opensearch/data:z + # ports: + # - 9200:9200 + # networks: + # - shuffle + # restart: unless-stopped + docker-socket-proxy: + image: tecnativa/docker-socket-proxy + container_name: shuffle-frontend + privileged: true + environment: + - SERVICES=1 + - TASKS=1 + - NETWORKS=1 + - NODES=1 + - BUILD=1 + - IMAGES=1 + - GRPC=1 + - CONTAINERS=1 + - PLUGINS=1 + - SYSTEM=1 + - VOLUMES=1 + - INFO=1 + - DISTRIBUTION=1 + - POST=1 + - AUTH=1 + - SECRETS=1 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + networks: + - shuffle networks: shuffle: driver: bridge diff --git a/functions/onprem/orborus/build.sh b/functions/onprem/orborus/build.sh index fe360759..3256a1ed 100644 --- a/functions/onprem/orborus/build.sh +++ b/functions/onprem/orborus/build.sh @@ -1,5 +1,5 @@ NAME=shuffle-orborus -VERSION=1.0.0 +VERSION=1.0.1 echo "Running docker build with $NAME:$VERSION" #docker rmi frikky/shuffle:$NAME --force diff --git a/functions/onprem/orborus/go.mod b/functions/onprem/orborus/go.mod index 3bce0939..3d8716d3 100644 --- a/functions/onprem/orborus/go.mod +++ b/functions/onprem/orborus/go.mod @@ -8,5 +8,5 @@ require ( github.com/docker/go-connections v0.4.0 // indirect github.com/mackerelio/go-osstat v0.2.1 github.com/satori/go.uuid v1.2.0 - github.com/shuffle/shuffle-shared v0.2.27 + github.com/shuffle/shuffle-shared v0.2.41 ) diff --git a/functions/onprem/orborus/go.sum b/functions/onprem/orborus/go.sum index 628ecf89..282522ce 100644 --- a/functions/onprem/orborus/go.sum +++ b/functions/onprem/orborus/go.sum @@ -786,6 +786,8 @@ github.com/shuffle/shuffle-shared v0.2.9 h1:fh2eOD7olifW2uyC3Vlp8u3dqhgIxtYaDVja github.com/shuffle/shuffle-shared v0.2.9/go.mod h1:YuMle0RjwXb3hxR5PdaOOD9e+hUyK34OABS0UbrT/Sk= github.com/shuffle/shuffle-shared v0.2.27 h1:YT9MtXyMSxIGMpNovjp9pCKFyt2gk40EdAXqDvldhM8= github.com/shuffle/shuffle-shared v0.2.27/go.mod h1:YuMle0RjwXb3hxR5PdaOOD9e+hUyK34OABS0UbrT/Sk= +github.com/shuffle/shuffle-shared v0.2.41 h1:1TBP/47Xzh7ysi6I++wJxRxKpZYp7NBe7YF1DrFL2mA= +github.com/shuffle/shuffle-shared v0.2.41/go.mod h1:YuMle0RjwXb3hxR5PdaOOD9e+hUyK34OABS0UbrT/Sk= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= diff --git a/functions/onprem/orborus/orborus.go b/functions/onprem/orborus/orborus.go index b238a48e..f32972db 100644 --- a/functions/onprem/orborus/orborus.go +++ b/functions/onprem/orborus/orborus.go @@ -282,6 +282,35 @@ func deployServiceWorkers(image string) { } } + if len(os.Getenv("DOCKER_HOST")) > 0 { + log.Printf("[DEBUG] Deploying docker socket proxy to the network %s as the DOCKER_HOST variable is set", networkName) + if err == nil { + containers, err := dockercli.ContainerList(ctx, types.ContainerListOptions{ + All: true, + }) + + if err == nil { + for _, container := range containers { + if strings.Contains(strings.ToLower(container.Image), "docker-socket-proxy") { + networkConfig := &network.EndpointSettings{} + err := dockercli.NetworkConnect(ctx, networkName, container.ID, networkConfig) + if err != nil { + log.Printf("[ERROR] Failed connecting Docker socket proxy to docker network %s: %s", networkName, err) + } else { + log.Printf("[INFO] Attached the docker socket proxy to the execution network") + } + + break + } + } + } else { + log.Printf("[WARNING] Failed listing containers when deploying socket proxy on swarm: %s", err) + } + } else { + log.Printf("[WARNING] Failed listing and finding the right image for docker socket proxy: %s", err) + } + } + //serviceOptions := types.ServiceCreateOptions{} //service, err := dockercli.ServiceCreate( // context.Background(), @@ -385,13 +414,15 @@ func deployServiceWorkers(image string) { }, } - if defaultNetworkAttach == true { + if defaultNetworkAttach == true || strings.ToLower(os.Getenv("SHUFFLE_DEFAULT_NETWORK_ATTACH")) == "true" { + targetName := "shuffle_shuffle" + log.Printf("[DEBUG] Adding network attach for network %s to worker in swarm", targetName) serviceSpec.Networks = append(serviceSpec.Networks, swarm.NetworkAttachmentConfig{ - Target: "shuffle_shuffle", + Target: targetName, }) // FIXM: Remove this if deployment fails? - serviceSpec.TaskTemplate.ContainerSpec.Env = append(serviceSpec.TaskTemplate.ContainerSpec.Env, fmt.Sprintf("SHUFFLE_SWARM_OTHER_NETWORK=shuffle_shuffle")) + serviceSpec.TaskTemplate.ContainerSpec.Env = append(serviceSpec.TaskTemplate.ContainerSpec.Env, fmt.Sprintf("SHUFFLE_SWARM_OTHER_NETWORK=%s", targetName)) } if dockerApiVersion != "" { @@ -835,6 +866,7 @@ func main() { if len(os.Getenv("DOCKER_HOST")) > 0 { log.Printf("[DEBUG] Running docker with socket proxy %s instead of default", os.Getenv("DOCKER_HOST")) + } else { log.Printf("[DEBUG] Running docker with default socket /var/run/docker.sock") }