Install application from github

raspberrypi3

#1

Hi,

What’s the recommended way of maintaining your application when code is stored in other git repos?

I obviously have my Dockerfile in a git repo for my own storage as well as Balenas etc but in the Dockerfile I’m installing a couple applications from external repos hosted on Github. On initial deployment this therefore requires cloning but from then onwards whenever the dockerfile reruns I just want it to pull any updates.

eg:
In Dockerfile on initial deployment:

RUN git clone

But from then on if it’s rebooted/etc it should do a RUN git pull… How do I define this elegantly?


#2

@r4space the commands in the Dockerfile I used to build the image that you run; the RUN commands are only going to be executed at build time, not runtime, so you would need to create an enterypoint script to pull in any updates and make this your CMD or ENTRYPOINT.

You can find more information about how the Dockerfile works here: https://docs.docker.com/engine/reference/builder/


#3

hmm, thanks. I stumbled on another post that led me to doing the following which seems to be working (forcing an update and use of latest code although I’m not sure if caching minimises downloads or not).

Is this an efficient way of doing it?

ENV COMMIT=438a989caf857a7f69f243db146641b433febf83
RUN git clone
RUN git checkout -q $COMMIT
CMD [“python”, “main.py”]


#4

@r4space

Again, this method will produce a docker image which is locked to the version in the COMMIT env var. If you run an instance of this container with an env var for COMMIT set to a different value, it wouldn’t make any difference; the code is pulled at build time, not instantiation time.

Is this what you want? Your original question sounds like you want the container to start, pull in the latest version, then run that.