Skip to content

Commit

Permalink
Merge pull request #133 from dvn0/dockerfile
Browse files Browse the repository at this point in the history
meta: add Dockerfile
  • Loading branch information
samrocketman authored Aug 1, 2021
2 parents 75e705f + 17b7b32 commit d99ac4b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
###
# After building (eg. `docker build -t gitlab-mirrors .`) ...
# you are expected to formulate a `docker run` command like the following:
#
# docker run -ti \
# --volume /path/to/config.sh:/home/gitmirror/gitlab-mirrors/config.sh:ro \
# --volume /path/to/ssh-keys:/home/gitmirror/.ssh \
# --volume /path/to/repositories:/home/gitmirror/repositories \
# gitlab-mirrors \
# <gitlab-mirrors cmd> <cmd options> # eg. add_mirror.sh --help
###
FROM debian:10

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -yqq \
python-pip \
git

RUN pip install python-gitlab

RUN adduser --shell /bin/sh --disabled-password --gecos "" gitmirror

RUN mkdir /home/gitmirror/gitlab-mirrors

COPY . /home/gitmirror/gitlab-mirrors

RUN chown -R gitmirror:gitmirror /home/gitmirror

USER gitmirror

WORKDIR /home/gitmirror/gitlab-mirrors

RUN mkdir /home/gitmirror/repositories && \
chmod 755 /home/gitmirror/gitlab-mirrors/*.sh

ENV PATH=$PATH:/home/gitmirror/gitlab-mirrors

ENTRYPOINT [ "/bin/bash", "/home/gitmirror/gitlab-mirrors/scripts/docker/entrypoint.sh" ]
14 changes: 14 additions & 0 deletions scripts/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -eu

SSH_DIR=/home/gitmirror/.ssh

if [ ! -f "$SSH_DIR/id_ed25519" ]; then
echo -e " * No SSH key found in $SSH_DIR.\n\
* You can generate a key like this:
ssh-keygen -t ed25519 -f /path/to/ssh/key/dir/id_ed25519 -qN \"\"
* Then make sure to run this image with --volume /path/to/ssh/key/dir:$SSH_DIR"
fi

exec "$@"

0 comments on commit d99ac4b

Please sign in to comment.