Skip to content
This repository was archived by the owner on Feb 9, 2024. It is now read-only.

Commit 0cb8d77

Browse files
authored
feat[Docker]: Add gitconfig in containers (#14)
1 parent 02e226b commit 0cb8d77

File tree

15 files changed

+270
-2
lines changed

15 files changed

+270
-2
lines changed

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"conventionalCommits.scopes": [
3+
"README"
4+
]
5+
}

3.6/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ USER avd
6262
COPY --from=BUILDER /home/avd/.local/ /home/avd/.local
6363
ENV PATH=$PATH:/home/avd/.local/bin
6464

65+
# Copy gitconfig file
66+
COPY gitconfig /home/avd/.gitconfig
67+
6568
# Install Oh My ZSH to provide improved shell
6669
RUN wget --quiet https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true \
6770
&& echo 'plugins=(ansible common-aliases safe-paste git jsontools history git-extras)' >> $HOME/.zshrc \

3.6/entrypoint.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
DOCKER_SOCKET=/var/run/docker.sock
44
DOCKER_GROUP=docker
55
USER=avd
6+
HOME_AVD=/home/avd/
67

78
# Install specific requirement file
89
if [ ! -z "${AVD_REQUIREMENTS}" ]; then
@@ -33,6 +34,22 @@ if [ ! -z "${AVD_GID}" ]; then
3334
groupmod -g ${AVD_GID} avd
3435
fi
3536

37+
# Update gitconfig with username and email
38+
if [ -n "${AVD_GIT_USER}" ]; then
39+
echo "Update gitconfig with ${AVD_GIT_USER}"
40+
sed -i "s/USERNAME/${AVD_GIT_USER}/g" ${HOME_AVD}/.gitconfig
41+
else
42+
echo "Update gitconfig with default username"
43+
sed -i "s/USERNAME/AVD Base USER/g" ${HOME_AVD}/.gitconfig
44+
fi
45+
if [ -n "${AVD_GIT_EMAIL}" ]; then
46+
echo "Update gitconfig with ${AVD_GIT_EMAIL}"
47+
sed -i "s/USER_EMAIL/${AVD_GIT_EMAIL}/g" ${HOME_AVD}/.gitconfig
48+
else
49+
echo "Update gitconfig with default email"
50+
sed -i "s/USER_EMAIL/[email protected]/g" ${HOME_AVD}/.gitconfig
51+
fi
52+
3653
if [ -S ${DOCKER_SOCKET} ]; then
3754
sudo chmod 666 /var/run/docker.sock &>/dev/null
3855
fi

3.6/gitconfig

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[user]
2+
name = USERNAME
3+
email = USER_EMAIL
4+
[alias]
5+
# Generic command
6+
rollback = reset --hard
7+
recommit = commit --amend --no-edit
8+
commit-unsafe = commit --no-verify
9+
undo = reset HEAD~1 --mixed
10+
uncommit = reset --soft HEAD~1
11+
12+
# Misc command
13+
refresh = !git pull --rebase --prune $@
14+
conflicts = !git ls-files -u | cut -f 2 | sort -u
15+
push-current = push -u origin HEAD
16+
17+
# Logging & History
18+
last = log --stat -1 HEAD
19+
graph = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
20+
logs = log --oneline --decorate --color
21+
22+
# In Fork model
23+
forigin = fetch origin
24+
fupstream = fetch upstream
25+
fetch-all = !sh -c 'for remote in $(git remote);do git fetch remote;done'
26+
27+
[core]
28+
excludesfile = ~/.gitignore_global
29+
[commit]
30+
template = ~/.stCommitMsg
31+
[pull]
32+
rebase = true
33+
[filter "lfs"]
34+
clean = git-lfs clean -- %f
35+
smudge = git-lfs smudge -- %f
36+
process = git-lfs filter-process
37+
required = true
38+
[pager]
39+
branch = false

3.7/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ USER avd
6161
COPY --from=BUILDER /home/avd/.local/ /home/avd/.local
6262
ENV PATH=$PATH:/home/avd/.local/bin
6363

64+
# Copy gitconfig file
65+
COPY gitconfig /home/avd/.gitconfig
66+
6467
# Install Oh My ZSH to provide improved shell
6568
RUN wget --quiet https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true \
6669
&& echo 'plugins=(ansible common-aliases safe-paste git jsontools history git-extras)' >> $HOME/.zshrc \

3.7/entrypoint.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
DOCKER_SOCKET=/var/run/docker.sock
44
DOCKER_GROUP=docker
55
USER=avd
6+
HOME_AVD=/home/avd/
67

78
# Install specific requirement file
89
if [ ! -z "${AVD_REQUIREMENTS}" ]; then
@@ -33,6 +34,22 @@ if [ ! -z "${AVD_GID}" ]; then
3334
groupmod -g ${AVD_GID} avd
3435
fi
3536

37+
# Update gitconfig with username and email
38+
if [ -n "${AVD_GIT_USER}" ]; then
39+
echo "Update gitconfig with ${AVD_GIT_USER}"
40+
sed -i "s/USERNAME/${AVD_GIT_USER}/g" ${HOME_AVD}/.gitconfig
41+
else
42+
echo "Update gitconfig with default username"
43+
sed -i "s/USERNAME/AVD Base USER/g" ${HOME_AVD}/.gitconfig
44+
fi
45+
if [ -n "${AVD_GIT_EMAIL}" ]; then
46+
echo "Update gitconfig with ${AVD_GIT_EMAIL}"
47+
sed -i "s/USER_EMAIL/${AVD_GIT_EMAIL}/g" ${HOME_AVD}/.gitconfig
48+
else
49+
echo "Update gitconfig with default email"
50+
sed -i "s/USER_EMAIL/[email protected]/g" ${HOME_AVD}/.gitconfig
51+
fi
52+
3653
if [ -S ${DOCKER_SOCKET} ]; then
3754
sudo chmod 666 /var/run/docker.sock &>/dev/null
3855
fi

3.7/gitconfig

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[user]
2+
name = USERNAME
3+
email = USER_EMAIL
4+
[alias]
5+
# Generic command
6+
rollback = reset --hard
7+
recommit = commit --amend --no-edit
8+
commit-unsafe = commit --no-verify
9+
undo = reset HEAD~1 --mixed
10+
uncommit = reset --soft HEAD~1
11+
12+
# Misc command
13+
refresh = !git pull --rebase --prune $@
14+
conflicts = !git ls-files -u | cut -f 2 | sort -u
15+
push-current = push -u origin HEAD
16+
17+
# Logging & History
18+
last = log --stat -1 HEAD
19+
graph = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
20+
logs = log --oneline --decorate --color
21+
22+
# In Fork model
23+
forigin = fetch origin
24+
fupstream = fetch upstream
25+
fetch-all = !sh -c 'for remote in $(git remote);do git fetch remote;done'
26+
27+
[core]
28+
excludesfile = ~/.gitignore_global
29+
[commit]
30+
template = ~/.stCommitMsg
31+
[pull]
32+
rebase = true
33+
[filter "lfs"]
34+
clean = git-lfs clean -- %f
35+
smudge = git-lfs smudge -- %f
36+
process = git-lfs filter-process
37+
required = true
38+
[pager]
39+
branch = false

3.8/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ USER avd
6161
COPY --from=BUILDER /home/avd/.local/ /home/avd/.local
6262
ENV PATH=$PATH:/home/avd/.local/bin
6363

64+
# Copy gitconfig file
65+
COPY gitconfig /home/avd/.gitconfig
66+
6467
# Install Oh My ZSH to provide improved shell
6568
RUN wget --quiet https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true \
6669
&& echo 'plugins=(ansible common-aliases safe-paste git jsontools history git-extras)' >> $HOME/.zshrc \

3.8/entrypoint.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
DOCKER_SOCKET=/var/run/docker.sock
44
DOCKER_GROUP=docker
55
USER=avd
6+
HOME_AVD=/home/avd/
67

78
# Install specific requirement file
89
if [ ! -z "${AVD_REQUIREMENTS}" ]; then
@@ -33,6 +34,22 @@ if [ ! -z "${AVD_GID}" ]; then
3334
groupmod -g ${AVD_GID} avd
3435
fi
3536

37+
# Update gitconfig with username and email
38+
if [ -n "${AVD_GIT_USER}" ]; then
39+
echo "Update gitconfig with ${AVD_GIT_USER}"
40+
sed -i "s/USERNAME/${AVD_GIT_USER}/g" ${HOME_AVD}/.gitconfig
41+
else
42+
echo "Update gitconfig with default username"
43+
sed -i "s/USERNAME/AVD Base USER/g" ${HOME_AVD}/.gitconfig
44+
fi
45+
if [ -n "${AVD_GIT_EMAIL}" ]; then
46+
echo "Update gitconfig with ${AVD_GIT_EMAIL}"
47+
sed -i "s/USER_EMAIL/${AVD_GIT_EMAIL}/g" ${HOME_AVD}/.gitconfig
48+
else
49+
echo "Update gitconfig with default email"
50+
sed -i "s/USER_EMAIL/[email protected]/g" ${HOME_AVD}/.gitconfig
51+
fi
52+
3653
if [ -S ${DOCKER_SOCKET} ]; then
3754
sudo chmod 666 /var/run/docker.sock &>/dev/null
3855
fi

3.8/gitconfig

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[user]
2+
name = USERNAME
3+
email = USER_EMAIL
4+
[alias]
5+
# Generic command
6+
rollback = reset --hard
7+
recommit = commit --amend --no-edit
8+
commit-unsafe = commit --no-verify
9+
undo = reset HEAD~1 --mixed
10+
uncommit = reset --soft HEAD~1
11+
12+
# Misc command
13+
refresh = !git pull --rebase --prune $@
14+
conflicts = !git ls-files -u | cut -f 2 | sort -u
15+
push-current = push -u origin HEAD
16+
17+
# Logging & History
18+
last = log --stat -1 HEAD
19+
graph = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
20+
logs = log --oneline --decorate --color
21+
22+
# In Fork model
23+
forigin = fetch origin
24+
fupstream = fetch upstream
25+
fetch-all = !sh -c 'for remote in $(git remote);do git fetch remote;done'
26+
27+
[core]
28+
excludesfile = ~/.gitignore_global
29+
[commit]
30+
template = ~/.stCommitMsg
31+
[pull]
32+
rebase = true
33+
[filter "lfs"]
34+
clean = git-lfs clean -- %f
35+
smudge = git-lfs smudge -- %f
36+
process = git-lfs filter-process
37+
required = true
38+
[pager]
39+
branch = false

0 commit comments

Comments
 (0)