Skip to content

Commit 887cd17

Browse files
author
Andreas Müller
committed
Merge remote-tracking branch 'b/run_as_non_root_user' into main
2 parents 7c5f257 + 6d1ece0 commit 887cd17

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ FROM node:8.2.1-alpine
33
ENV GTT_VERSION 1.7.39
44
ENV EDITOR vi
55

6-
WORKDIR /pwd
76

8-
RUN yarn global add --prefix /usr/local "gitlab-time-tracker@$GTT_VERSION"
7+
RUN apk update && \
8+
apk add git && \
9+
addgroup -S gtt && adduser -S gtt -G gtt && \
10+
yarn global add --prefix /usr/local "gitlab-time-tracker@$GTT_VERSION"
11+
USER gtt
12+
WORKDIR /home/gtt
913

10-
VOLUME ["/root", "/pwd"]
14+
VOLUME ["/home/gtt"]
1115
ENTRYPOINT ["gtt"]
1216
CMD ["--help"]

documentation.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,40 +69,36 @@ you can use the official [Docker image](https://hub.docker.com/r/kriskbx/gitlab-
6969
```shell
7070
docker run \
7171
--rm -it \
72-
-v ~:/root \
73-
-v $(pwd):/pwd \
72+
-v ~/.local/share/.gtt/:/home/gtt/.local/share/.gtt \
7473
kriskbx/gitlab-time-tracker \
7574
--help
7675
```
7776

78-
`--rm` removes the container after running, `-it` makes it interactive, `-v ~:/root` mounts your home directory to the
79-
home directory inside the container, `-v $(pwd):/pwd` mounts current directory inside the container to gtt be able to read local config. If you want to store the config in another place, mount another directory:
77+
`--rm` removes the container after running, `-it` makes it interactive, `-v ~/.local/share/.gtt/:/home/gtt/.local/share/.gtt ` mounts your gtt configuration directory in the gtt user home directory inside the container. For example, to run a report for a particular user with a date range:
78+
79+
```shell
80+
sudo docker run \
81+
--rm -it \
82+
-v ~/.local/share/.gtt/:/home/gtt/.local/share/.gtt \
83+
kriskbx/gitlab-time-tracker \
84+
report "ourorganization/aproject" --user=xxxx --from="2020-04-01" --to="2020-06-30"
85+
```
86+
87+
If you want to store the config in another place, mount another directory:
8088

8189

8290
```shell
8391
docker run \
8492
--rm -it \
85-
-v /path/to/gtt-config:/root \
93+
-v /path/to/gtt-config-dir:/home/gtt/.local/share/.gtt \
8694
kriskbx/gitlab-time-tracker \
8795
--help
8896
```
8997

90-
... or use a Docker volume:
91-
92-
```shell
93-
docker volume create gtt-config
94-
95-
docker run \
96-
--rm -it \
97-
-v gtt-config:/root \
98-
kriskbx/gitlab-time-tracker \
99-
--help
100-
```
101-
10298
I highly recommend creating an alias and adding it to your `bashrc`:
10399

104100
```shell
105-
echo "alias gtt='docker run --rm -it -v ~:/root -v $(pwd):/pwd kriskbx/gitlab-time-tracker'" >>~/.bashrc
101+
echo "alias gtt='docker run --rm -it -v -v ~/.local/share/.gtt/:/home/gtt/.local/share/.gtt kriskbx/gitlab-time-tracker'" >>~/.bashrc
106102
```
107103

108104
Now you can simply write `gtt` instead of the bulky Docker command before. Try it out: `gtt --help`

0 commit comments

Comments
 (0)