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

Docksal aliases don't work within commands #974

Closed
charginghawk opened this issue Feb 25, 2019 · 3 comments
Closed

Docksal aliases don't work within commands #974

charginghawk opened this issue Feb 25, 2019 · 3 comments
Assignees
Labels

Comments

@charginghawk
Copy link
Contributor

charginghawk commented Feb 25, 2019

Description

If you try to use a docksal alias within a docksal command, it fails.

This makes it hard to automate cross site interactions (at the most basic level, initializing one project as a dependency of another).

Steps to reproduce the issue:

  1. Create a test command like .docksal/commands/alias-within-command:
#!/usr/bin/env bash
fin @target-project config
  1. Run command and get these results:
---------------------
COMPOSE_PROJECT_NAME_SAFE: current-project
COMPOSE_FILE:
/Users/user/.docksal/stacks/volumes-nfs.yml
/Users/user/Projects/current-project/.docksal/docksal.yml
/Users/user/Projects/current-project/.docksal/docksal-local.yml
ENV_FILE:
/Users/user/Projects/target-project/.docksal/docksal.env

PROJECT_ROOT: /Users/user/Projects/target-project
DOCROOT: docroot
VIRTUAL_HOST: target-project.docksal
VIRTUAL_HOST_ALIASES: *.target-project.docksal
IP: 192.168.64.100
MYSQL:

Docker Compose configuration
---------------------
ERROR: build path /Users/user/Projects/target-project/.docksal/web either does not exist, is not accessible, or is not a valid URL.

Describe the results you received:

The project association is pretty scrambled.

Describe the results you expected:

The command successfully runs for the targeted environment (as happens running the command outside of another docksal command).

@achekulaev
Copy link
Member

What makes you think that alias does not work? As far as I see everything works.

You have custom Dockerfile in one of your projects that has relative build path, that is not resolved properly because you use aliases.

ERROR: build path /Users/user/Projects/target-project/.docksal/web either does not exist, is not accessible, or is not a valid URL.

You need to be mindful about relative paths when using aliases.

@charginghawk
Copy link
Contributor Author

charginghawk commented Feb 26, 2019

@achekulaev I've gone through and made a more reproducible and simplified scenario, and this is still an issue. I can't start another project from within a command, and the config output is different as well.

I've created two directories, ~/Projects/test1 and ~/Projects/test2. I've cd'd into both and run fin init (so barebones, no changes, no code, default setups). With those two projects initialized, I've created two commands in test1:

$ cat .docksal/commands/test2-config 
#!/usr/bin/env bash
fin @test2 config

$ cat .docksal/commands/test2-start 
#!/usr/bin/env bash
fin @test2 start

Here's the output of fin @test2 start outside of the command vs inside (from the test1 project):

$ fin @test2 start
Key 'id_rsa' already loaded in the agent. Skipping.
Starting services...
test2_db_1_f71a08ab4d93 is up-to-date
test2_cli_1_f8de76e71d85 is up-to-date
test2_web_1_fa28c32296b0 is up-to-date
Waiting 10s for container to start...
Virtual Host: http://test2.docksal

$ fin test2-start
Key 'id_rsa' already loaded in the agent. Skipping.
 ERROR:  Another project is already using the name 'test1'
         Change the name of the current project by renaming the project folder (folder name defines the project name and has to be unique)
         or remove the other project's stack by running fin project remove in /Users/chart/Projects/test1

And the diff for fin @test2 config outside the command vs inside:

$ git diff fin\ \@test2\ config.txt fin\ test2-config.txt | cat
diff --git a/fin @test2 config.txt b/fin test2-config.txt
index 22fe8b4..8f0e6b8 100644
--- a/fin @test2 config.txt	
+++ b/fin test2-config.txt	
@@ -1,20 +1,20 @@
-$ fin @test2 config
+$ fin test2-config
 ---------------------
-COMPOSE_PROJECT_NAME_SAFE: test2
+COMPOSE_PROJECT_NAME_SAFE: test1
 COMPOSE_FILE:
 /Users/chart/.docksal/stacks/overrides-osxfs.yml
 /Users/chart/.docksal/stacks/volumes-bind.yml
 /Users/chart/.docksal/stacks/stack-default.yml
-/Users/chart/Projects/test2/.docksal/docksal.yml
+/Users/chart/Projects/test1/.docksal/docksal.yml
 ENV_FILE:
 /Users/chart/Projects/test2/.docksal/docksal.env
 
 PROJECT_ROOT: /Users/chart/Projects/test2
 DOCROOT: docroot
-VIRTUAL_HOST: test2.docksal
-VIRTUAL_HOST_ALIASES: *.test2.docksal
+VIRTUAL_HOST: test1.docksal
+VIRTUAL_HOST_ALIASES: *.test1.docksal
 IP: 192.168.64.100
-MYSQL: 192.168.64.100:32771
+MYSQL: 192.168.64.100:32770
 
 Docker Compose configuration
 ---------------------
@@ -36,7 +36,7 @@ services:
       SECRET_PLATFORMSH_CLI_TOKEN: null
       SECRET_SSH_PRIVATE_KEY: null
       SECRET_TERMINUS_TOKEN: null
-      VIRTUAL_HOST: test2.docksal
+      VIRTUAL_HOST: test1.docksal
       XDEBUG_CONFIG: remote_connect_back=0 remote_host=192.168.64.1
       XDEBUG_ENABLED: '0'
     hostname: cli
@@ -82,7 +82,7 @@ services:
       io.docksal.cert-name: none
       io.docksal.permanent: "false"
       io.docksal.project-root: /Users/chart/Projects/test2
-      io.docksal.virtual-host: test2.docksal,*.test2.docksal,test2.docksal.*
+      io.docksal.virtual-host: test1.docksal,*.test1.docksal,test1.docksal.*
     volumes:
     - project_root:/var/www:ro,nocopy
 version: '2.1'

And full config outputs:

fin config outputs
$ fin test2-config
---------------------
COMPOSE_PROJECT_NAME_SAFE: test1
COMPOSE_FILE:
/Users/chart/.docksal/stacks/overrides-osxfs.yml
/Users/chart/.docksal/stacks/volumes-bind.yml
/Users/chart/.docksal/stacks/stack-default.yml
/Users/chart/Projects/test1/.docksal/docksal.yml
ENV_FILE:
/Users/chart/Projects/test2/.docksal/docksal.env

PROJECT_ROOT: /Users/chart/Projects/test2
DOCROOT: docroot
VIRTUAL_HOST: test1.docksal
VIRTUAL_HOST_ALIASES: *.test1.docksal
IP: 192.168.64.100
MYSQL: 192.168.64.100:32770

Docker Compose configuration
---------------------
services:
  cli:
    dns:
    - 192.168.64.100
    - 8.8.8.8
    environment:
      BLACKFIRE_CLIENT_ID: null
      BLACKFIRE_CLIENT_TOKEN: null
      DOCROOT: docroot
      GIT_USER_EMAIL: thomas.charginghawk@pega.com
      GIT_USER_NAME: charginghawk
      HOST_GID: '1053198925'
      HOST_UID: '1786867176'
      SECRET_ACAPI_EMAIL: null
      SECRET_ACAPI_KEY: null
      SECRET_PLATFORMSH_CLI_TOKEN: null
      SECRET_SSH_PRIVATE_KEY: null
      SECRET_TERMINUS_TOKEN: null
      VIRTUAL_HOST: test1.docksal
      XDEBUG_CONFIG: remote_connect_back=0 remote_host=192.168.64.1
      XDEBUG_ENABLED: '0'
    hostname: cli
    image: docksal/cli:2.5-php7.1
    volumes:
    - docksal_ssh_agent:/.ssh-agent:ro
    - cli_home:/home/docker:rw
    - /Users/chart/Projects/test2:/var/www:rw,cached
  db:
    dns:
    - 192.168.64.100
    - 8.8.8.8
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: null
      MYSQL_DATABASE: default
      MYSQL_INITDB_SKIP_TZINFO: null
      MYSQL_ONETIME_PASSWORD: null
      MYSQL_PASSWORD: user
      MYSQL_RANDOM_ROOT_PASSWORD: null
      MYSQL_ROOT_PASSWORD: root
      MYSQL_USER: user
    hostname: db
    image: docksal/db:1.2-mysql-5.6
    ports:
    - 3306/tcp
    volumes:
    - db_data:/var/lib/mysql:rw
    - project_root:/var/www:ro,nocopy
  web:
    depends_on:
      cli:
        condition: service_started
    dns:
    - 192.168.64.100
    - 8.8.8.8
    environment:
      APACHE_BASIC_AUTH_PASS: null
      APACHE_BASIC_AUTH_USER: null
      APACHE_DOCUMENTROOT: /var/www/docroot
    hostname: web
    image: docksal/web:2.1-apache2.4
    labels:
      io.docksal.cert-name: none
      io.docksal.permanent: "false"
      io.docksal.project-root: /Users/chart/Projects/test2
      io.docksal.virtual-host: test1.docksal,*.test1.docksal,test1.docksal.*
    volumes:
    - project_root:/var/www:ro,nocopy
version: '2.1'
volumes:
  cli_home: {}
  db_data: {}
  docksal_ssh_agent:
    external: true
    name: docksal_ssh_agent
  project_root:
    driver: local
    driver_opts:
      device: /Users/chart/Projects/test2
      o: bind
      type: none

---------------------

$ fin @test2 config
---------------------
COMPOSE_PROJECT_NAME_SAFE: test2
COMPOSE_FILE:
/Users/chart/.docksal/stacks/overrides-osxfs.yml
/Users/chart/.docksal/stacks/volumes-bind.yml
/Users/chart/.docksal/stacks/stack-default.yml
/Users/chart/Projects/test2/.docksal/docksal.yml
ENV_FILE:
/Users/chart/Projects/test2/.docksal/docksal.env

PROJECT_ROOT: /Users/chart/Projects/test2
DOCROOT: docroot
VIRTUAL_HOST: test2.docksal
VIRTUAL_HOST_ALIASES: *.test2.docksal
IP: 192.168.64.100
MYSQL: 192.168.64.100:32771

Docker Compose configuration
---------------------
services:
  cli:
    dns:
    - 192.168.64.100
    - 8.8.8.8
    environment:
      BLACKFIRE_CLIENT_ID: null
      BLACKFIRE_CLIENT_TOKEN: null
      DOCROOT: docroot
      GIT_USER_EMAIL: thomas.charginghawk@pega.com
      GIT_USER_NAME: charginghawk
      HOST_GID: '1053198925'
      HOST_UID: '1786867176'
      SECRET_ACAPI_EMAIL: null
      SECRET_ACAPI_KEY: null
      SECRET_PLATFORMSH_CLI_TOKEN: null
      SECRET_SSH_PRIVATE_KEY: null
      SECRET_TERMINUS_TOKEN: null
      VIRTUAL_HOST: test2.docksal
      XDEBUG_CONFIG: remote_connect_back=0 remote_host=192.168.64.1
      XDEBUG_ENABLED: '0'
    hostname: cli
    image: docksal/cli:2.5-php7.1
    volumes:
    - docksal_ssh_agent:/.ssh-agent:ro
    - cli_home:/home/docker:rw
    - /Users/chart/Projects/test2:/var/www:rw,cached
  db:
    dns:
    - 192.168.64.100
    - 8.8.8.8
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: null
      MYSQL_DATABASE: default
      MYSQL_INITDB_SKIP_TZINFO: null
      MYSQL_ONETIME_PASSWORD: null
      MYSQL_PASSWORD: user
      MYSQL_RANDOM_ROOT_PASSWORD: null
      MYSQL_ROOT_PASSWORD: root
      MYSQL_USER: user
    hostname: db
    image: docksal/db:1.2-mysql-5.6
    ports:
    - 3306/tcp
    volumes:
    - db_data:/var/lib/mysql:rw
    - project_root:/var/www:ro,nocopy
  web:
    depends_on:
      cli:
        condition: service_started
    dns:
    - 192.168.64.100
    - 8.8.8.8
    environment:
      APACHE_BASIC_AUTH_PASS: null
      APACHE_BASIC_AUTH_USER: null
      APACHE_DOCUMENTROOT: /var/www/docroot
    hostname: web
    image: docksal/web:2.1-apache2.4
    labels:
      io.docksal.cert-name: none
      io.docksal.permanent: "false"
      io.docksal.project-root: /Users/chart/Projects/test2
      io.docksal.virtual-host: test2.docksal,*.test2.docksal,test2.docksal.*
    volumes:
    - project_root:/var/www:ro,nocopy
version: '2.1'
volumes:
  cli_home: {}
  db_data: {}
  docksal_ssh_agent:
    external: true
    name: docksal_ssh_agent
  project_root:
    driver: local
    driver_opts:
      device: /Users/chart/Projects/test2
      o: bind
      type: none

---------------------

And for good measure, Output of fin sysinfo:

fin sysinfo output
$ fin sysinfo
███  OS
Darwin Mac OS X 10.13.6
Darwin L31521OUS 17.7.0 Darwin Kernel Version 17.7.0: Thu Dec 20 21:47:19 PST 2018; root:xnu-4570.71.22~1/RELEASE_X86_64 x86_64

███  ENVIRONMENT
MODE : Docker for Mac

███  FIN
fin version: 1.80.1

███  DOCKER COMPOSE
EXPECTED VERSION: 1.23.1
docker-compose version 1.23.1, build b02f1306
docker-py version: 3.5.0
CPython version: 3.6.6
OpenSSL version: OpenSSL 1.1.0h  27 Mar 2018

███  DOCKER
EXPECTED VERSION: 18.06.1-ce

Client:
Version:           18.06.1-ce
API version:       1.38
Go version:        go1.10.3
Git commit:        e68fc7a
Built:             Tue Aug 21 17:21:31 2018
OS/Arch:           darwin/amd64
Experimental:      false

Server: Docker Engine - Community
Engine:
Version:          18.09.2
API version:      1.39 (minimum version 1.12)
Go version:       go1.10.6
Git commit:       6247962
Built:            Sun Feb 10 04:13:06 2019
OS/Arch:          linux/amd64
Experimental:     true

███  DOCKSAL: PROJECTS
project             STATUS              virtual host                                    project root
test2               Up 37 minutes       test2.docksal,*.test2.docksal,test2.docksal.*   /Users/chart/Projects/test2
test1               Up 38 minutes       test1.docksal,*.test1.docksal,test1.docksal.*   /Users/chart/Projects/test1

███  DOCKSAL: VIRTUAL HOSTS
*.test1.docksal
*.test2.docksal
test1.docksal.*
test1.docksal
test2.docksal.*
test2.docksal

███  DOCKER: RUNNING CONTAINERS
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS                         PORTS                                      NAMES
01f9ba96ab8a        docksal/web:2.1-apache2.4   "httpd-foreground"       37 minutes ago      Up 37 minutes                  80/tcp, 443/tcp                            test2_web_1_fa28c32296b0
06ff033b4b87        docksal/cli:2.5-php7.1      "/opt/startup.sh sup…"   37 minutes ago      Up 37 minutes (healthy)        22/tcp, 3000/tcp, 9000/tcp                 test2_cli_1_f8de76e71d85
2ad2015508c2        docksal/db:1.2-mysql-5.6    "/entrypoint.sh mysq…"   37 minutes ago      Up 37 minutes                  0.0.0.0:32771->3306/tcp                    test2_db_1_f71a08ab4d93
3e73805cd155        docksal/web:2.1-apache2.4   "httpd-foreground"       38 minutes ago      Up 38 minutes                  80/tcp, 443/tcp                            test1_web_1_e0b8e87b764d
8e1fb181b15f        docksal/cli:2.5-php7.1      "/opt/startup.sh sup…"   38 minutes ago      Up 38 minutes (healthy)        22/tcp, 3000/tcp, 9000/tcp                 test1_cli_1_7cbf59c98286
1c3b90802950        docksal/db:1.2-mysql-5.6    "/entrypoint.sh mysq…"   38 minutes ago      Up 38 minutes                  0.0.0.0:32770->3306/tcp                    test1_db_1_a0d49ef882b9
84ea1804fd11        docksal/ssh-agent:1.2       "docker-entrypoint.s…"   About an hour ago   Up About an hour (healthy)                                                docksal-ssh-agent
35a1853e72bd        docksal/dns:1.1             "docker-entrypoint.s…"   About an hour ago   Up About an hour (healthy)     192.168.64.100:53->53/udp                  docksal-dns
c9461ffe52ce        docksal/vhost-proxy:1.4     "docker-entrypoint.s…"   About an hour ago   Up About an hour (unhealthy)   0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   docksal-vhost-proxy

███  DOCKER: NETWORKS
NETWORK ID          NAME                               DRIVER              SCOPE
54f93143c6a5        2-pegawwwd8_default                bridge              local
4163be070dc9        _default                           bridge              local
2fe3695ede1c        bridge                             bridge              local
3f8eaef62a9d        federated-search-service_default   bridge              local
f04015c8d7d5        host                               host                local
e85ea99835e7        none                               null                local
7958283d32a2        test1_default                      bridge              local
cb3c6a276886        test2_default                      bridge              local

███  HDD Usage
Filesystem      Size   Used  Avail Capacity iused               ifree %iused  Mounted on
/dev/disk1s1   466Gi  372Gi   83Gi    82% 4431196 9223372036850344611    0%   /
devfs          191Ki  191Ki    0Bi   100%     660                   0  100%   /dev
/dev/disk1s4   466Gi   10Gi   83Gi    11%      10 9223372036854775797    0%   /private/var/vm
map -hosts       0Bi    0Bi    0Bi   100%       0                   0  100%   /net
map auto_home    0Bi    0Bi    0Bi   100%       0                   0  100%   /home
map -fstab       0Bi    0Bi    0Bi   100%       0                   0  100%   /Network/Servers

Please try the above steps to reproduce and let me know how it goes.

@charginghawk
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

No branches or pull requests

3 participants