These are chat archives for azukiapp/azk

14th
Jul 2015
Vicente Pons
@gponsu
Jul 14 2015 11:16
Hi, is there any way to pass env variables from the host system so they are available from the dockerfile?
I am trying to create a user, and I need that it have the same UID my user on the host machine.
ADD ./uid /tmp/

RUN cat /tmp/uid | \
    xargs -I UID useradd -u UID -G sudo -p $(openssl passwd '1234') -s /bin/bash web
It works, but I would like to take the uid of an environment variable, and not from a file
Gullit Miranda
@gullitmiranda
Jul 14 2015 11:48

Hi @gponsu.
As the docker documentation, there is the ENV statement which you can use to create a variable.
But as you want to use your UID, you will need to pass it as an option.

You are using the docker directly or Dockerfile that will be used by azk?

Vicente Pons
@gponsu
Jul 14 2015 12:04
Thanks @gullitmiranda, I'm using the Dockerfile that will be used by azk
Gullit Miranda
@gullitmiranda
Jul 14 2015 12:08
a possible solution is you create an environment variable on your machine and call it inside the Azkfile.js
Vicente Pons
@gponsu
Jul 14 2015 12:09
    envs: {
      UID_ENV: "$MY_UID"
    },
Something like that?
Gullit Miranda
@gullitmiranda
Jul 14 2015 12:10

in your .bash_profile or .zshrc add:

export USER_ID=`id -u`

and in Azkfile.js:

envs: {
  USER_ID: env.USER_ID
}
for now you can not use "$ENV_NAME”, but there is an open issue for this.
Vicente Pons
@gponsu
Jul 14 2015 12:14
ouhh thanks! And in the docker file so I can use it?
RUN useradd -u $USER_ID -G sudo -p $(openssl passwd '1234') -s /bin/bash web
Gullit Miranda
@gullitmiranda
Jul 14 2015 12:14
yep
Vicente Pons
@gponsu
Jul 14 2015 12:15

I do not work :(

Step 2 : RUN useradd -u $USER_ID -G sudo -p $(openssl passwd '1234') -s /bin/bash web
   ---> Running in 5d545c0bc925
  useradd: invalid user ID '-G'

But thank you very much! I'll keep on trying this way :)

Gullit Miranda
@gullitmiranda
Jul 14 2015 12:18
After you add the command to your profile, you restarted the terminal?
try: echo $USER_ID
Vicente Pons
@gponsu
Jul 14 2015 12:18
⭠ wording-admin± ⮀ echo $USER_ID
1000
Gullit Miranda
@gullitmiranda
Jul 14 2015 12:20
Ow. Sorry, it has a small detail :( .
This ENV will be available only at run time, not build.
Vicente Pons
@gponsu
Jul 14 2015 12:20
and inside, if i do azk shell:
echo $USER_ID
1000
and inside, if i do azk shell:
Gullit Miranda
@gullitmiranda
Jul 14 2015 12:21
exact
Vicente Pons
@gponsu
Jul 14 2015 12:21
Then there is no way to use it in the dockerfile, right?
Gullit Miranda
@gullitmiranda
Jul 14 2015 12:22
You can send me your Dockerfile?
Vicente Pons
@gponsu
Jul 14 2015 12:23
FROM azukiapp/ruby

# Add new user
RUN useradd -u $USER_ID -G sudo -p $(openssl passwd '1234') -s /bin/bash web
USER web
This is all
Gullit Miranda
@gullitmiranda
Jul 14 2015 12:25
when the boot command? You're in your Azkfile.js?
Vicente Pons
@gponsu
Jul 14 2015 12:26
how is that? I do not understand sorry
Gullit Miranda
@gullitmiranda
Jul 14 2015 12:27
so that the system starts, it is necessary to command option in Azkfile.js or CMD in Dockerfile.
Vicente Pons
@gponsu
Jul 14 2015 12:29
The command is in the azkfile.js
Gullit Miranda
@gullitmiranda
Jul 14 2015 12:30
what’s the command?
Vicente Pons
@gponsu
Jul 14 2015 12:30
Standard to rails app
It is generated by azk init
Gullit Miranda
@gullitmiranda
Jul 14 2015 12:33
ok. I will need to prepare an entrypoint to be used in your Dockerfile.
Meanwhile, tell me what your motivation to add this user. Just so I can understand.
?
Gullit Miranda
@gullitmiranda
Jul 14 2015 12:44

please run:

$ git clone https://gist.github.com/gullitmiranda/72b8459806e708be89ef build

and change Dockerfile path in your Azkfile.js:

image: { dockerfile: “./build/Dockerfile“ }
// ...
Guilherme Araújo
@guilhermearaujo
Jul 14 2015 13:18
hey everyone! I'm trying to figure out how to debug with pry or pry-remote when using AZK. Any clues?
Vicente Pons
@gponsu
Jul 14 2015 14:06
ouh sorry, I was eating
I will try, thank you :)
Gullit Miranda
@gullitmiranda
Jul 14 2015 14:08
no problem @gponsu.
If you do not work let me know that I will look for some other solution.
Hi, @guilhermearaujo.
Have you tried to use azk shell?
Vicente Pons
@gponsu
Jul 14 2015 14:10
azk: Error: HTTP code is 500 which indicates error: server error - Cannot start container 786b36d4c2d5d1f35b3417f0bbcb4386c646fa3bfd1a7214874168ec5c3add5d: [8] System error: Unable to find user web
I think the user is not created correctly
Gullit Miranda
@gullitmiranda
Jul 14 2015 14:12
Yes. Unfortunately the USER checks if the user already exists :(
why you need web user?
Vicente Pons
@gponsu
Jul 14 2015 14:18
because if you use root, all files generated by me within the container from outside have to change them permissions
Gullit Miranda
@gullitmiranda
Jul 14 2015 14:20
you're using Linux?
And another thing, your application usually generates new files often?
Vicente Pons
@gponsu
Jul 14 2015 14:20
yep. linux
yep, usually
Gullit Miranda
@gullitmiranda
Jul 14 2015 14:21
It is unfortunately this is a recurring problem in docker :(.
I will look for an alternative to set set the default user.
Vicente Pons
@gponsu
Jul 14 2015 14:22
yep I saw it, but I thought I could fix it :(
I will look for an alternative to set set the default user.
thanks!!!!
Gullit Miranda
@gullitmiranda
Jul 14 2015 14:33
@gponsu, please
try again:
$ rm -rf build/ && git clone https://gist.github.com/gullitmiranda/72b8459806e708be89ef build
$ azk shell —rebuild
# touch teste
# ls -alh
Vicente Pons
@gponsu
Jul 14 2015 14:33
thanks :)
Gullit Miranda
@gullitmiranda
Jul 14 2015 14:33
and send me the output
Vicente Pons
@gponsu
Jul 14 2015 14:33
ok
-rw-r--r--  1 root root    0 Jul 14 14:32 teste
Gullit Miranda
@gullitmiranda
Jul 14 2015 14:35
:cry:
ow sorry
please, run
echo $USER in shell context
Vicente Pons
@gponsu
Jul 14 2015 14:36
echo $USER
web
Gullit Miranda
@gullitmiranda
Jul 14 2015 14:37
this is weird. for me it worked perfectly, although I have added the env USER: “web” in Azkfile.js
root@3714c8f4db34:/azk/elixir/hello-phoenix# touch teste
root@3714c8f4db34:/azk/elixir/hello-phoenix# ls -alh
total 20K
drwxr-xr-x 1 web   999  374 Jul 14 14:30 .
drwxr-xr-x 3 root root 4.0K Jul 14 14:30 ..
-rw-r--r-- 1 web   999 1.6K Jul 14 14:28 Azkfile.js
drwxr-xr-x 1 web   999  170 Jul 14 14:26 build
-rw-r--r-- 1 web   999    0 Jul 14 14:30 teste
root@3714c8f4db34:/azk/elixir/hello-phoenix# echo $USER
web
This message was deleted
Vicente Pons
@gponsu
Jul 14 2015 14:41
and de Azkfile.js?
and the Azkfile.js?
please
Gullit Miranda
@gullitmiranda
Jul 14 2015 14:42
    image: {"dockerfile": "./build/Dockerfile"},
    workdir: "/azk/#{manifest.dir}/#{system.name}",
    shell: "/bin/bash",
    envs: {
      // set instances variables
      MIX_ENV: "dev",
      USER: "web",
    },
Vicente Pons
@gponsu
Jul 14 2015 14:56
wiiiii!!!
-rw-rw-r--  1 web  web     0 Jul 14 14:54 teste
I did a change:
#!/bin/bash
set -e

# set 1000 if value is not defined
export USER_ID="${USER_ID:-1000}"
export USER="${USER:-web}"

# Add new user
useradd -u $USER_ID -G sudo -p $(openssl passwd $USER) -s /bin/bash $USER

exec su - web
Thank youuuu very much!!!! :)
Gullit Miranda
@gullitmiranda
Jul 14 2015 14:59
very nice :D
Vicente Pons
@gponsu
Jul 14 2015 15:01
thanks @gullitmiranda
you're the best :)
Gullit Miranda
@gullitmiranda
Jul 14 2015 15:17
:blush:
nothing man. we are here to help :D
Guilherme Araújo
@guilhermearaujo
Jul 14 2015 17:23
@gullitmiranda how can azk shell help me use pry?
Gullit Miranda
@gullitmiranda
Jul 14 2015 17:45

@guilhermearaujo
Using azk shell you have access to a container with the same context of its application, that is, you will access a container with ruby and all its dependencies.

The pry is included in your Gemfile?

Guilherme Araújo
@guilhermearaujo
Jul 14 2015 17:46
yes
I can enter the shell, but when the code is supposed to pause at a binding.pry breakpoint, it doesn't
Gullit Miranda
@gullitmiranda
Jul 14 2015 17:46

@guilhermearaujo
Using shell AZK you have access to a container with the same context of its application, that is, you will access a container with ruby and all its dependencies.

The pry is included in your Gemfile?

Guilherme Araújo
@guilhermearaujo
Jul 14 2015 17:47
I can enter the shell, but when the code is supposed to pause at a binding.pry breakpoint, it doesn't
Gullit Miranda
@gullitmiranda
Jul 14 2015 17:52
When you access the shell you are having access to a container with the same context of the application, but it is not the same container. So you will not have access to running application.
Unfortunately azk does not have support the reuse of containers. To have access the application container you must use the docker (while this is not yet available in azk)
The @scudelletti created an issue that has instructions on how to do this today:
azukiapp/azk#310
Guilherme Araújo
@guilhermearaujo
Jul 14 2015 17:56
i read that, but for some reason it's not working with me
Gullit Miranda
@gullitmiranda
Jul 14 2015 17:56
what happens?
Guilherme Araújo
@guilhermearaujo
Jul 14 2015 17:57
System error: exec: "bundle exec pry-remote": executable file not found in $PATH
this PATH, is it the VM's path or my computer's path?
Gullit Miranda
@gullitmiranda
Jul 14 2015 18:01

please, run:

azk docker exec -t -i xxxxxxx 'bundle list

and send me the output

Guilherme Araújo
@guilhermearaujo
Jul 14 2015 18:04
it writes "Usage:" and how I'm supposed to use the command
Gullit Miranda
@gullitmiranda
Jul 14 2015 18:13
sauhshau
try:
azk docker — exec -t -i CONTAINER_ID bundle list
Guilherme Araújo
@guilhermearaujo
Jul 14 2015 18:15
without replacing the id?
oh, dash-dash, nevermind
exec: "bundle list": executable file not found in $PATH
Cannot run exec command 091ab389450b2c601379cec795a1c4b4058ed4aa027bd1dd6b097babc61a8ab7 in container fb0c225ddddf7361137062119074bf9c24e3425ce9c6940f78cbb111f104d727: [8] System error: exec: "bundle list": executable file not found in $PATH
Gullit Miranda
@gullitmiranda
Jul 14 2015 18:21
replace id :D
please send my output of:
azk docker -- exec -t -i CONTAINER_ID echo $PATH
Guilherme Araújo
@guilhermearaujo
Jul 14 2015 18:28
it's the same output as "echo $PATH", which is:
/Users/guilherme/.rvm/gems/ruby-2.2.2/bin /Users/guilherme/.rvm/gems/ruby-2.2.2@global/bin /Users/guilherme/.rvm/rubies/ruby-2.2.2/bin /Users/guilherme/.rvm/bin /Users/guilherme/.rbenv/shims /Users/guilherme/.rbenv/shims /Users/guilherme/.rbenv/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /Users/guilherme/Library/Android/sdk/platform-tools /Users/guilherme/Library/Android/sdk/tools
Gullit Miranda
@gullitmiranda
Jul 14 2015 18:34
Sorry, I was forgetting a great detail :(
Guilherme Araújo
@guilhermearaujo
Jul 14 2015 18:36
which one?
Gullit Miranda
@gullitmiranda
Jul 14 2015 18:37
The environment variables are in the shell context, so the necessary environment variables are not available.
please, show me your Azkfile.js
Gullit Miranda
@gullitmiranda
Jul 14 2015 18:46
ok. I will prepare a list of commands :(
Gullit Miranda
@gullitmiranda
Jul 14 2015 18:53
more one info.
azk shell -c ‘echo $PATH'
Guilherme Araújo
@guilhermearaujo
Jul 14 2015 18:54
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/rubies/ruby-2.2.2/bin
Gullit Miranda
@gullitmiranda
Jul 14 2015 18:56
$ adocker exec -t -i CONTAINER_ID /bin/bash
$ export BUNDLE_APP_CONFIG='/azk/bundler'
$ export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/rubies/ruby-2.2.2/bin'
$ bundle list
Guilherme Araújo
@guilhermearaujo
Jul 14 2015 18:57
now it did print all the gems
Gullit Miranda
@gullitmiranda
Jul 14 2015 19:00
show
the final list of commands:
$ adocker exec -t -i CONTAINER_ID /bin/bash
$ export BUNDLE_APP_CONFIG='/azk/bundler'
$ export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/rubies/ruby-2.2.2/bin'
$ bundle exec pry-remote
Guilherme Araújo
@guilhermearaujo
Jul 14 2015 19:03
/usr/local/lib/ruby/2.2.0/drb/drb.rb:744:in `rescue in block in open': druby://127.0.0.1:9876 - #<Errno::ECONNREFUSED: Connection refused - connect(2) for "127.0.0.1" port 9876> (DRb::DRbConnError)
Gullit Miranda
@gullitmiranda
Jul 14 2015 19:07
Does this issue solves your problem?
Mon-Ouie/pry-remote#8
Guilherme Araújo
@guilhermearaujo
Jul 14 2015 19:07
btw, which container should I choose from the list?
for instance, I'm using the first of this list:
Gullit Miranda
@gullitmiranda
Jul 14 2015 19:10
please show me more infos (COMMAND, STATUS, …)
Gullit Miranda
@gullitmiranda
Jul 14 2015 19:15
yes, use first container
if you ever need to access a port other than 3000, you must add there in Azkfile.js
Guilherme Araújo
@guilhermearaujo
Jul 14 2015 19:20
so I will probably need to add one for pry-remote,
Gullit Miranda
@gullitmiranda
Jul 14 2015 19:25
:( do you need help?
Guilherme Araújo
@guilhermearaujo
Jul 14 2015 19:47
I just can't make it work...
does it work for you?
Gullit Miranda
@gullitmiranda
Jul 14 2015 19:48
to be honest I never used the pry-remote with docker :(
what's up?
Guilherme Araújo
@guilhermearaujo
Jul 14 2015 19:50
i haven't even used docker tbh... gotta read about it
Gullit Miranda
@gullitmiranda
Jul 14 2015 19:54
I will do some research and ask for help (@nuxlli)