Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Proxy Config Updates #2275

Merged
merged 4 commits into from
Dec 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions .ahoy/docker-compose.common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ services:
- "./.docker/etc/php5/php.ini:/etc/php5/fpm/conf.d/z_php.ini"
- "./.docker/etc/php5/xdebug-linux.ini:/etc/php5/xdebug-linux.ini"
- "./.docker/etc/php5/xdebug-macos.ini:/etc/php5/xdebug-macos.ini"
network_mode: bridge
labels:
- "traefik.frontend.rule=Host:${SLUG}.${PROXY_DOMAIN}"
- "traefik.frontend.passHostHeader=true"
environment:
# no_proxy="" required for default Docker For Mac system proxy that contains a space and prevents Selenium from loading.
# Linked containers to browser will also need this setting.
- no_proxy=""
env_file:
- mysql.env

Expand All @@ -37,6 +45,7 @@ services:
- /var/lib/mysql
labels:
- traefik.enable=false
network_mode: bridge

# CLI node
# Used for all console commands and tools.
Expand Down Expand Up @@ -65,6 +74,7 @@ services:
- ~/.ssh:/.ssh
labels:
- traefik.enable=false
network_mode: bridge

# Memcached node
# Uncomment the service definition section below and the link in the web service above to start using memcached.
Expand All @@ -76,6 +86,7 @@ services:
- MEMCACHED_MEMORY_LIMIT=128
labels:
- traefik.enable=false
network_mode: bridge

# ngrok node
# Uncomment the service definition section below to start using ngrok for sharing your local web server with the world.
Expand All @@ -95,12 +106,20 @@ services:
hostname: browser
image: selenium/standalone-chrome-debug:2.53.1
# This helps keep selenium-chrome from crashing because it uses shared memory.
ports:
- "5900"
volumes:
- /dev/shm:/dev/shm
# Project root folder mapping
- "../../:/var/www/"
links:
- web
environment:
# no_proxy="" required for default Docker For Mac system proxy that contains a space and prevents Selenium from loading.
- no_proxy=""
network_mode: bridge
labels:
- traefik.enable=false

solr:
hostname: solr
Expand All @@ -110,9 +129,5 @@ services:
volumes:
- "./.docker/etc/solr/3.x:/var/lib/solr/conf"
labels:
- traefik.enable=false

networks:
default:
external:
name: dkan_default
- "traefik.frontend.rule=Host:${SLUG}-solr.${PROXY_DOMAIN}"
network_mode: bridge
3 changes: 0 additions & 3 deletions .ahoy/docker-compose.noproxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,3 @@ services:
environment:
- PHP_IDE_CONFIG=serverName=dkan.docker
- VIRTUAL_HOST=dkan.docker
browser:
ports:
- "5900"
72 changes: 33 additions & 39 deletions .ahoy/docker.ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ commands:
# export AHOY_DOCKER_SYNC=true
# which will use Docker For Mac instead of docker-machine using native OS file syncing.
#
# To use Traefik proxy, set:
# export AHOY_USE_PROXY=true
#
# To override the default proxy domain (localtest.me), set:
# export AHOY_WEB_DOMAIN=mydomain.com
#
Expand Down Expand Up @@ -58,15 +55,7 @@ commands:
export HOST_UID=$(id -u)
docker-sync start -c dkan/.ahoy/docker-sync.yml
fi
# Create dkan network
DKAN_NETWORK=$(docker network ls -q -f name=dkan_default)
if [ -z "$DKAN_NETWORK" ]; then
docker network create dkan_default
fi

if [ ! -z "$AHOY_USE_PROXY" ]; then
ahoy docker proxy-up
fi;
ahoy docker compose up -d {{args}}
ahoy docker hostfile
usage: Start the docker-compose containers.
Expand All @@ -82,15 +71,15 @@ commands:
SLUG=${PWD##*/}
SLUG=${SLUG//-/}
SLUG=${SLUG//_/}
SLUG=$(echo ${SLUG} | tr "[A-Z]" "[a-z]") # Mixed case dirs cause issue with docker image names
SLUG=$(echo ${SLUG} | tr -d '[:space:]' | tr "[A-Z]" "[a-z]") # Mixed case dirs cause issue with docker image names
echo ${SLUG}
get-proxy-domain:
cmd: |
[ "$AHOY_WEB_DOMAIN" ] && WEB_DOMAIN=$AHOY_WEB_DOMAIN || WEB_DOMAIN="localtest.me"
echo $WEB_DOMAIN
get-hostname:
cmd: |
if [ ! -z "$AHOY_USE_PROXY" ]; then
if [ "$(ahoy docker proxy-running)" = "1" ]; then
echo "$(ahoy docker get-slug).$(ahoy docker get-proxy-domain)"
else
if [ -z "$DOCKER_MACHINE_NAME" ]; then
Expand All @@ -115,27 +104,13 @@ commands:
else
echo "Starting proxy container"
docker run -d --privileged \
-p 80:80 -p 443:443 -p 8080:8080 --network dkan_default \
-p 80:80 -p 443:443 -p 8080:8080 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$DKAN_PATH/.ahoy/traefik.toml:/etc/traefik/traefik.toml" \
--name=${PROXY_NAME} traefik --web --docker --docker.domain=${PROXY_DOMAIN} --logLevel=DEBUG
fi
fi

SLUG=$(ahoy docker get-slug)

# Configure host for proxy.
PROXYCONF_FILE="dkan/.ahoy/docker-compose.proxyconf.yml"
echo -e "version: \"2\"" > ${PROXYCONF_FILE}
echo -e "services:" >> ${PROXYCONF_FILE}
echo -e " web:\n labels:" >> ${PROXYCONF_FILE}
echo -e " - traefik.backend=${SLUG}" >> ${PROXYCONF_FILE}
echo -e " - traefik.frontend.rule=Host:$(ahoy docker get-hostname)" >> ${PROXYCONF_FILE}
echo -e " - traefik.frontend.passHostHeader=true" >> ${PROXYCONF_FILE}
echo -e " browser:\n labels:" >> ${PROXYCONF_FILE}
echo -e " - traefik.backend=${SLUG}_browser" >> ${PROXYCONF_FILE}
echo -e " - traefik.frontend.rule=Host:browser.$(ahoy docker get-hostname)" >> ${PROXYCONF_FILE}

usage: Run the nginx-proxy container
stop:
cmd: |
Expand Down Expand Up @@ -242,21 +217,39 @@ commands:
mysql-dump:
cmd: docker exec -it $(ahoy docker compose ps -q cli) bash -c "mysqldump -u$(ahoy docker mysql-param username) -p$(ahoy docker mysql-param password) -h$(ahoy docker mysql-param hostname) $(ahoy docker mysql-param database)"
usage: Dump data out into a file. `ahoy docker mysql-dump > backups/local.sql`
proxy-running:
cmd: |
PROXY_RUNNING=$(docker ps | grep proxy)
if [ -z "$PROXY_RUNNING" ]; then
echo "0"
else
echo "1"
fi
usage: Reports a 0 or 1 if "proxy" docker container is running.
compose:
cmd: |
DOCKER_COMPOSE_COMMON_CONF="dkan/.ahoy/docker-compose.common.yml"
if [ ! -z "$AHOY_USE_PROXY" ]; then
PROXY_CONF="dkan/.ahoy/docker-compose.proxyconf.yml"
else
PROXY_CONF="dkan/.ahoy/docker-compose.noproxy.yml"
if [ "$(ahoy docker proxy-running)" = "0" ]; then
PROXY_CONF="-f dkan/.ahoy/docker-compose.noproxy.yml"
fi;

if [ ! -z "$AHOY_DOCKER_SYNC" ]; then
export SLUG=$(ahoy docker get-slug)
VOLUME_CONF="dkan/.ahoy/docker-compose.docker-sync.yml"
else
VOLUME_CONF="dkan/.ahoy/docker-compose.nosync.yml"
fi;
docker-compose -f $DOCKER_COMPOSE_COMMON_CONF -f $VOLUME_CONF -f $PROXY_CONF -p "${PWD##*/}" {{args}}
export SLUG=$(ahoy docker get-slug)

#Check for proxy container, get domain from that.
PROXY_DOMAIN=`docker inspect proxy 2> /dev/null | grep docker.domain | tr -d ' ",-' | cut -d \= -f 2 | head -1`

#If no proxy is running, use the overridden or default proxy domain
if [ -z "$PROXY_DOMAIN" ]; then
PROXY_DOMAIN=$(ahoy get-proxy-domain)
fi
export PROXY_DOMAIN=$PROXY_DOMAIN
docker-compose -f $DOCKER_COMPOSE_COMMON_CONF -f $VOLUME_CONF $PROXY_CONF -p "${PWD##*/}" {{args}}
usage: Abstraction for docker-compose
web-host:
cmd: |
Expand All @@ -269,28 +262,29 @@ commands:
usage: Prints the project URL
cmd: |
echo -n "http://`ahoy docker get-hostname`"
if [ -z "$AHOY_USE_PROXY" ]; then
if [ "$(ahoy docker proxy-running)" = "0" ]; then
echo -n ":`ahoy docker compose port web 80|cut -d ':' -f2`"
fi;
echo ""
surl:
usage: Prints a secure project URL
cmd: |
echo -n "https://`ahoy docker get-hostname`"
if [ -z "$AHOY_USE_PROXY" ]; then
if [ "$(ahoy docker proxy-running)" = "0" ]; then
echo -n ":`ahoy docker compose port web 443|cut -d ':' -f2`"
fi;
echo ""
vnc:
usage: Prints the project VNC URL
cmd: |
if [ "$AHOY_CMD_PROXY" = "DOCKER" ] && [ -n "$AHOY_USE_PROXY" ]; then
echo "https://browser.$(ahoy docker get-hostname):5900"
VNC_PORT=`ahoy docker compose port browser 5900|cut -d ':' -f2`
if [ "$AHOY_CMD_PROXY" = "DOCKER" ] && [ "$(ahoy docker proxy-running)" = "1" ]; then
echo "$(ahoy docker get-hostname):${VNC_PORT}"
else
if [ -z "$DOCKER_MACHINE_NAME" ]; then
echo "https://`ahoy docker web-host`:`ahoy docker compose port browser 5900|cut -d ':' -f2`"
echo "`ahoy docker web-host`:${VNC_PORT}"
else
echo "`docker-machine ip default`:`ahoy docker compose port browser 5900|cut -d ':' -f2`"
echo "`docker-machine ip default`:${VNC_PORT}"
fi
fi
cleanup:
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
7.x-1.14.1
----------
- #2283 Share MySQL Credentials With Docker Containers
- #2273 Remove dkan_workflow_permissions dependency
- #2275 Docker Proxy Config Updates
- #2263 Fix harvest validation for accessLevel values
- #2249 Change timezone handling to 'none' on temporal coverage field
- #2103 Fixed field mapping defaults for open data schema APIs
- #2237 Migration of CircleCI from V1 to V2
- #2273 Remove dkan_workflow_permissions dependency
- #2283 Share MySQL Credentials With Docker Containers

7.x-1.14
--------
Expand Down