pantheon-systems / docker-build-tools-ci

Dockerfile source for docker image pantheon-public/build-tools-ci on quay.io
34 stars 39 forks source link

Build tools in docker container cannot read git email address #5

Closed jraviotta closed 5 years ago

jraviotta commented 6 years ago

I have successfully included the docker image from Quay in my docker4drupal app with the following docker-compose file that references valid variables in a .env file.

version: "2"

services:
  mariadb:
    image: wodby/mariadb:$MARIADB_TAG
    container_name: "${PROJECT_NAME}_mariadb"
    stop_grace_period: 30s
    environment:
      MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
      MYSQL_DATABASE: $DB_NAME
      MYSQL_USER: $DB_USER
      MYSQL_PASSWORD: $DB_PASSWORD

  php:
    image: wodby/drupal-php:$PHP_TAG
    container_name: "${PROJECT_NAME}_php"
    environment:
      PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
      DB_HOST: $DB_HOST
      DB_USER: $DB_USER
      DB_PASSWORD: $DB_PASSWORD
      DB_NAME: $DB_NAME
      DB_DRIVER: $DB_DRIVER
    volumes:
      - ./:/var/www/html

  nginx:
    image: wodby/drupal-nginx:$NGINX_TAG
    container_name: "${PROJECT_NAME}_nginx"
    depends_on:
      - php
    environment:
      NGINX_STATIC_CONTENT_OPEN_FILE_CACHE: "off"
      NGINX_ERROR_LOG_LEVEL: debug
      NGINX_BACKEND_HOST: php
      NGINX_SERVER_ROOT: /var/www/html/web
    volumes:
      - ./:/var/www/html
    labels:
      - 'traefik.backend=nginx'
      - 'traefik.port=80'
      - 'traefik.frontend.rule=Host:${PROJECT_BASE_URL}'

  mailhog:
    image: mailhog/mailhog
    container_name: "${PROJECT_NAME}_mailhog"
    labels:
      - 'traefik.backend=mailhog'
      - 'traefik.port=8025'
      - 'traefik.frontend.rule=Host:mailhog.${PROJECT_BASE_URL}'
  traefik:
    image: traefik
    container_name: "${PROJECT_NAME}_traefik"
    command: -c /dev/null --web --docker --logLevel=INFO
    ports:
      - '8000:80'
#      - '8080:8080' # Dashboard
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

  selenium-hub:
    image: selenium/hub
    container_name: "${PROJECT_NAME}_selenium_hub"
    ports:
      - "4444:4444"

  chrome:
    image: selenium/node-chrome-debug
    container_name: "${PROJECT_NAME}_chrome"
    ports:
    - "5900:5900"
    links:
      - selenium-hub:hub
    volumes:
      - /dev/shm:/dev/shm # Mitigates the Chromium issue described at https://code.google.com/p/chromium/issues/detail?id=519952
    environment:
        HUB_PORT_4444_TCP_ADDR: selenium-hub
        HUB_PORT_4444_TCP_PORT: 4444

  terminus:
    image: quay.io/pantheon-public/build-tools-ci # https://github.com/savaslabs/terminus-docker
    container_name: "${PROJECT_NAME}_terminus"
    env_file:
      - .env-private
    command: |
      sh -c "
        mkdir -p /terminus/cache/tokens
        terminus auth:login --machine-token=$$TERMINUS_TOKEN
        tail -f /dev/null
        "
   volumes:
      - terminus-data:/terminus/cache
      - ./:/app:cached
volumes:
  terminus-data:

I can call terminus and initiate a build with the following command:

docker exec -ti project_terminus terminus  build:project:create d8 NewSite

Terminus asks for password and agency then fails with:

 [error]  The email address ''' is not valid. Please set a valid email address via 'git config --global user.email <address>', or override this setting with the --email option. 

I can override the error by setting --email=<myemail>@provider.com and the build proceeds until the git commit which fails with the same message.

It appears that Terminus is looking for the active use by examining the global .gitconfig file. Since the container is running the process, no global git information is available. I have tried generating the file with git config --global user.email xxxx using the container's shell, but no file is created. Similarly, using git config user.email xxxx in the container's shared volume has no effect. I do have a global config locally.

Is it possible to pass the user information with an environment variable instead?

jraviotta commented 6 years ago

I was able to place my local .gitconfig file in the container by specifying a bind mounted volume in the terminus container as such:

  terminus:
    image: quay.io/pantheon-public/build-tools-ci # https://github.com/savaslabs/terminus-docker
    container_name: "${PROJECT_NAME}_terminus"
    env_file:
      - .env-private
    command: |
      sh -c "
        mkdir -p /terminus/cache/tokens
        terminus auth:login --machine-token=$$TERMINUS_TOKEN
        tail -f /dev/null
        "
    volumes:
      - terminus-data:/terminus/cache
      - ${HOME}/.gitconfig:/root/.gitconfig:ro

Terminus wanted a password for git, so I also had to set ssh as the default in my local global .gitconfig with:

git config --global url.ssh://git@github.com/.insteadOf https://github.com/

This got me to the point of committing to pantheon where i was prompted to add the RSA key fingerprint to known hosts. Entering 'yes' led to codeserver.dev requesting drush.in's password. I'm not sure how to get around those prompts.

greg-1-anderson commented 5 years ago

This looks like an interesting experiment, but this is not a supported use for this container. If you still have issues, try reaching out in the #composer-workflow channel of the Pantheon slack server.