rebar3 compile dependencies separated from project code

classic Classic list List threaded Threaded
3 messages Options
rtp
Reply | Threaded
Open this post in threaded view
|

rebar3 compile dependencies separated from project code

rtp
Hi,

I'm build up a docker pipeline for a erlang project.  Currently I build
the whole project in a new erlang-Docker-Container by a

        rebar3 as prod tar

This task downloads and compiles the dependencies every time I build;
because the erlang-container is plain and empty.

I can now call a

        rebar3 get-deps

in a previous container (or step) to get rid of the downloads.

But I want to get a step further an compile the dependencies before
building the application, to compile only the app-code and to make the
build faster.

Does anybody know how to compile dependencies separated from app-code ?

I can't find anything.  Perhaps there's a plugin I don't know!?


Thanks a lot

Ralf
rtp
Reply | Threaded
Open this post in threaded view
|

Re: rebar3 compile dependencies separated from project code

rtp
Found a solution just now :-D

Just copy only the rebar.conf-file in a first step and compile it (I
didn't expect to work ... but it does) :

   FROM erlang:22

   WORKDIR /BUILD/

   # get deps in a first step - to use cache in next build ;-)

   COPY erlang/aw/rebar.config .
   RUN rebar3 compile

   # now get whole code

   COPY erlang/aw/ .
   RUN rebar3 as prod tar


Perhaps it helps someone :-)

Cheerio

Ralf


On 23.11.19 10:47, rtp wrote:

> Hi,
>
> I'm build up a docker pipeline for a erlang project.  Currently I build
> the whole project in a new erlang-Docker-Container by a
>
> rebar3 as prod tar
>
> This task downloads and compiles the dependencies every time I build;
> because the erlang-container is plain and empty.
>
> I can now call a
>
> rebar3 get-deps
>
> in a previous container (or step) to get rid of the downloads.
>
> But I want to get a step further an compile the dependencies before
> building the application, to compile only the app-code and to make the
> build faster.
>
> Does anybody know how to compile dependencies separated from app-code ?
>
> I can't find anything.  Perhaps there's a plugin I don't know!?
>
>
> Thanks a lot
>
> Ralf
>
Reply | Threaded
Open this post in threaded view
|

Re: rebar3 compile dependencies separated from project code

Tristan Sloughter-4
Yes, only copy the rebar.config and rebar.lock files and rebar3 compile will do the right thing.

You might find https://adoptingerlang.org/docs/production/docker/ useful. It goes beyond this form of layer caching to what is now possible with the latest versions of docker, including things like caching the hex packages outside of a layer so they don't get redownloaded after a cache bust.

Tristan

On Sat, Nov 23, 2019, at 03:04, rtp wrote:

> Found a solution just now :-D
>
> Just copy only the rebar.conf-file in a first step and compile it (I
> didn't expect to work ... but it does) :
>
>    FROM erlang:22
>
>    WORKDIR /BUILD/
>
>    # get deps in a first step - to use cache in next build ;-)
>
>    COPY erlang/aw/rebar.config .
>    RUN rebar3 compile
>
>    # now get whole code
>
>    COPY erlang/aw/ .
>    RUN rebar3 as prod tar
>
>
> Perhaps it helps someone :-)
>
> Cheerio
>
> Ralf
>
>
> On 23.11.19 10:47, rtp wrote:
> > Hi,
> >
> > I'm build up a docker pipeline for a erlang project.  Currently I build
> > the whole project in a new erlang-Docker-Container by a
> >
> > rebar3 as prod tar
> >
> > This task downloads and compiles the dependencies every time I build;
> > because the erlang-container is plain and empty.
> >
> > I can now call a
> >
> > rebar3 get-deps
> >
> > in a previous container (or step) to get rid of the downloads.
> >
> > But I want to get a step further an compile the dependencies before
> > building the application, to compile only the app-code and to make the
> > build faster.
> >
> > Does anybody know how to compile dependencies separated from app-code ?
> >
> > I can't find anything.  Perhaps there's a plugin I don't know!?
> >
> >
> > Thanks a lot
> >
> > Ralf
> >
>