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

[feature] docker build tooling #10

Closed
wants to merge 21 commits into from
Closed

[feature] docker build tooling #10

wants to merge 21 commits into from

Conversation

sescobb27
Copy link
Contributor

@sescobb27 sescobb27 commented Sep 12, 2018

** Usage

path = "/Users/kiro/workspace/elixir/elixir-docker-guide"
{ctx, _} = 
  Path.join([path, "Dockerfile"])
  |> DockerApi.DockerfileParser.parse()
  |> DockerApi.DockerBuild.build(path)

acc
end

# first line - accomulator empty

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accomulator -> accumulator

[add] more abstractions to the docker api
[add] support for exec and shell form instructions
[add] support for `COPY`ing files from host machine to container
[add] `COPY`ing files doesn't support relative PATH to WORKDIR it has to be
and absolute path
[fix] take only ImageId parte when committing a container
[add] add some logs to commands
[add] support 204 and 304 when stopping a container
[add] limit kill container after 5 sec waiting for a container
[add] remove generated TAR file and return the ContainerId
[add] wait :infinity when pulling an image
[fix] capture only the matching part of the regexes
[add] wait for some instructions to finish
[add] support for ENTRYPOINT command
[refactor] DockerApi to be much cleaner
@sescobb27
Copy link
Contributor Author

sescobb27 commented Sep 24, 2018

While trying to bind-mount a host directory to a container work I tried to make it work using the official docker client without success, here are the steps i used

# https://github.com/docker/docker-py
# python2.7
# https://docker-py.readthedocs.io/en/1.4.0/volumes/

from docker import Client
c = Client(base_url='unix://var/run/docker.sock')
host_config = c.create_host_config(binds=['/Users/kiro/test:/data'])
container_id = c.create_container('busybox:1.29', 'ls /data', volumes=['/data'], host_config=host_config)
c.commit(container_id)

Then with the ImageId returned from c.commit(container_id) i ran it with docker run -it ImageId /bin/bash and then run ls /data but the directory is empty and it shouldn't be empty

@sescobb27
Copy link
Contributor Author

sescobb27 commented Sep 24, 2018

it seems we can create a container with the mounted directory but we can't create an image with that mounted directory. moby/moby#6999

NOTE: yes, that seems to be the issue. the steps to reproduce are the same as the steps above but instead of commiting the container and running it, I just ran docker start -ai ContainerId

screen shot 2018-09-24 at 1 18 16 pm

@bryanhuntesl
Copy link
Contributor

It may be the case that having mounted that directory - and run a command, and generated an image, you will need to mount that directory when you create a container from that image in order to run subsequent commands. If it were a (pseudo) dockerfile/build it would look something like this.

  • MOUNT /foo (interpret the mount command)
  • RUN echo "bar" > /foo/bar (execute command, stop container, create image 1)
  • RUN cat /foo/bar > /foo/baz (you create a container from image 1 with /foo mount, execute command, stop container, and create image 2)
  • RUN echo bop > /foo/bop (you create a container from image 2 with /foo mount, execute command, stop container, and create image 3)

[refactor] inject context to every command instead of just the ImageId
[refactor] stop container before commiting it
@bryanhuntesl
Copy link
Contributor

+1

@bryanhuntesl
Copy link
Contributor

screen shot 2018-09-25 at 10 30 48 am

[fix] dialyzer errors
[change] how regexes capture matches
[change] handle API errors
[change] use railway oriented flow for creating a layer
[change] fail fast in the presence of errors
[change] use rail way oriented flow when uploading dir/files to a container
[add] typespecs
sescobb27 added a commit to esl/ex_docker_build that referenced this pull request Sep 26, 2018
@sescobb27
Copy link
Contributor Author

closing this PR in favor of https://github.com/sescobb27/ex_docker_build

@sescobb27 sescobb27 closed this Sep 26, 2018
@sescobb27 sescobb27 deleted the docker-build branch September 26, 2018 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants