Public Repository

Last pushed: 2 years ago
Short Description
A smallish image with git installed. Ideal for volume images containing application source code.
Full Description

An image which contains only git, for packaging your source code into its
own volume image.

Advantages of this approach:

  • Unlike COPY/ADD, you don't have to worry about intermediate files in
    your local working directory, such as *.pyc files or junk configs

  • Unlike volume attachments, you can package this as an image, and your
    runtime environment doesn't have to have the code checked out

  • Using techniques (see below), you can even clone from private repos this way

  • Not as small as it could possibly be, but quite a bit smaller than
    Ubuntu-based images

  • If you use git to inspect your source at start up (for example, to embed
    the application version into your runtime), this is actually a git repo,
    not just a directory of source files

Best-practices usage - public github repo

  • Just RUN git clone https://...

Best-practices usage - private github repo

  • Create a yourapp-readonly github account
  • Give that account access to your private repo
  • As that account, create a personal access token
  • RUN git clone https://<token>
    • Note that the password field of this url must be literally x-oauth-basic if you use this approach.

After creating

You probably have a "-main" type image that builds in all your application's
dependencies. That image is the one you're going to run.

We'll assume your app is "yourapp", and the image you're building with gitonly
is "you/yourapp-src".

The image you created based on gitonly should be tagged with the same release
tag as your application, e.g. you/yourapp-src:release-1.7.1.

Add a VOLUME declaration to yourapp-src to situate your source code inside of
yourapp-main somewhere.

In yourapp-main, mount the volume container exposed by yourapp-src, and run
your code.

Docker Pull Command