Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git*
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3-alpine
MAINTAINER Tecnativa <info@tecnativa.com>
ENTRYPOINT ["/usr/src/app/entrypoint.sh"]
ENV GIT_AUTHOR_NAME=git-aggregator \
EMAIL=https://hub.docker.com/r/tecnativa/git-aggregator
Copy link
Contributor

Choose a reason for hiding this comment

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

Tecnativa repo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is because this code builds https://hub.docker.com/r/tecnativa/git-aggregator/, and I don't want to address people to Acsone until they acknowledge maintenance of this image (in which case it would become https://hub.docker.com/r/acsone/git-aggregator/ or something similar). That's why I said what I said in #5 (comment).

# HACK Install git >= 2.11, to have --shallow-since
# TODO Remove HACK when python:alpine is alpine >= v3.5
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.5/main git
Copy link
Contributor

Choose a reason for hiding this comment

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

@yajo Hrmmmm so remember when I reported that this didn't work in the Odoo Docker container? Well it works here.

I took it a step further and created a dockerfile with just this in it, and it still worked. My curiosity is peaked, so I'll probably fool around with this a bit more in that context.

COPY . /usr/src/app
RUN pip install --no-cache-dir --editable /usr/src/app
RUN python -m compileall /usr/src/app/
VOLUME /repos
WORKDIR /repos
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ Only aggregate a specific repository using `fnmatch`_:

.. _fnmatch: https://docs.python.org/2/library/fnmatch.html

Dockerized version
------------------

You can use ``git-aggregator`` from CLI without installing anything but Docker:

.. code-block:: bash

$ docker run -it --rm -v $(pwd):/repos tecnativa/git-aggregator -c repos.yaml


Credits
=======

Expand Down
22 changes: 22 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

# Default to the gitaggregate command if we get an option as first argument
if [ "${1:0:1}" == - ]; then
cmd="gitaggregate $@"
else
cmd="$@"
fi

# Add SETUID & SETGUID to binaries to make them run with the same user as
# `/repos`'s owner. In case you mount `/repos` from your host computer. This is
# useful because otherwise all files and folders would be owned by `root`.
uid=$(stat -c %u /repos)
if [ $uid -ne $(id -u root) ]; then
gid=$(stat -c %g /repos)
addgroup -g $gid threpwood
adduser -G threpwood -u $uid guybrush -DH -s /bin/sh
Copy link
Contributor

Choose a reason for hiding this comment

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

threpwood & guybrush - Intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely 😆

All that matters is the UID & GID, so I had to put some name and that one came to my mind ☠️

Copy link
Contributor

Choose a reason for hiding this comment

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

Curious, mainly due to my newness in Docker arena- if you use a user that exists on the host system, are the GID and UID matched with the system user/group of the same name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's why this hack, it allows you to use the docker app and let it use your same user permissions. So after cloning, no root-owned files are there.

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome thanks for the elaboration! I've been running into permissions issues lately & I have no idea why this never dawned on me 😄


exec su guybrush -c "$cmd"
else
exec "$cmd"
fi