Fork me on GitHub
#docker
<
2017-04-27
>
not-raspberry12:04:05

@josh.freckleton Split your dockerfile into 2, build the first one and tag it, e.g. docker build . -t base_image, and build the second one from the first one.

not-raspberry12:04:34

$ cat a/Dockerfile 
FROM clojure
ENV A=1
$ cat b/Dockerfile 
FROM image_a
ENV B=12
ENTRYPOINT ["bash"]
$ sudo docker build a -t image_a
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM clojure
 ---> 073eca6605b0
Step 2 : ENV A 1
 ---> Running in a9c4bca744fc
 ---> 84d9771186ba
Removing intermediate container a9c4bca744fc
Successfully built 84d9771186ba
$ sudo docker build b -t image_b
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM image_a
 ---> 84d9771186ba
Step 2 : ENV B 12
 ---> Running in 17d2f93e58d9
 ---> 02ad380a7db1
Removing intermediate container 17d2f93e58d9
Step 3 : ENTRYPOINT bash
 ---> Running in 3c46122fbe30
 ---> 6de067a352ed
Removing intermediate container 3c46122fbe30
Successfully built 6de067a352ed
$ sudo docker run -ti image_b
root@a12d7e23ddab:/tmp# env
A=1
B=12
...

josh.freckleton15:04:46

@not-raspberry That sounds like it would work, (I'm a bit new to docker) but what do I put in the first image that pulls down my deps, and how do I allow the deps to be accessed by lein in image B?

not-raspberry15:04:18

image 1

FROM clojure
... the code that copies the project dir ... 
RUN lein deps
image 2:
FROM image_1
RUN do_something_with_that_setup

not-raspberry15:04:32

@josh.freckleton the second dockerfile will basically inherit all the state you created with the first one

josh.freckleton15:04:13

ohhhh, duh, that lein deps step, thanks!