Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Docker support #8

Closed
wants to merge 4 commits into from
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
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM debian:buster-slim

RUN apt update && \
apt install -y lsb-release vim bash sudo perl-modules build-essential git liblwp-protocol-https-perl && \
rm -rf /var/lib/apt/lists/*

RUN cpan CPAN

COPY ./ /opt/memento

RUN cd /opt/memento && ./install.pl

RUN mkdir -p /opt/memento/Memento/Tool/custom && \
cd /opt/memento/Memento/Tool/custom && \
git clone https://github.com/bmeme/memento-plugins.git && \
git clone https://github.com/bmeme/memento-docker.git && \
git clone https://github.com/bmeme/memento-kickstarter.git

RUN groupadd --gid 1000 memento && \
useradd \
--uid 1000 \
--gid 1000 \
--groups sudo \
--create-home \
--shell /bin/bash \
memento

RUN echo "memento\nmemento" | passwd memento

USER memento

27 changes: 27 additions & 0 deletions README.docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

# Build the docker image

You can build the memento docker image by running the following command:

```
$ docker build . -t memento
```

Please note: the `Dockerfile` assumes that your user and group id is 1000.
Please edit the file accordingly to your system settings.

# Run memento using docker

With the built image presents on your system, you can use `./cmemento` wrapper to run memento.
Note: it will read (and write) the configuration from `~/.memento` directory.

If you want to use cmemento from anywhere, just copy the script in a system path:

```
$ sudo cp cmemento /usr/local/bin
```

Example:
```
$ cmemento jira projects
```
34 changes: 34 additions & 0 deletions cmemento
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

set -e
QUOTEDCMD=()
for token in "$@"; do
QUOTEDCMD+=($(printf "%q" "$token"))
done
CMD="${QUOTEDCMD[*]}"
if [[ -z "$CMD" ]]
then
CMD="bash"
fi

PWD=$(pwd -P)

if [ -f .git ]; then
SOURCE="${PWD}/.."
DEST="/usr/src/app"
CURRDIR=$(basename ${PWD})
WORKDIR="${DEST}/${CURRDIR}"
else
SOURCE="${PWD}"
DEST="/usr/src/app"
WORKDIR="/usr/src/app"
fi

docker run --rm \
-v /home/$(whoami)/.memento:/home/memento/.memento \
-v ${SOURCE}:${DEST} \
-v ~/.ssh:/home/memento/.ssh \
-v $(dirname $SSH_AUTH_SOCK):$(dirname $SSH_AUTH_SOCK) \
-e SSH_AUTH_SOCK=$SSH_AUTH_SOCK \
-w ${WORKDIR} -it memento /bin/bash -c "memento ${CMD}"