This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat[Docker]: Add gitconfig in containers (#14)
- Loading branch information
Showing
15 changed files
with
270 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"conventionalCommits.scopes": [ | ||
"README" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
DOCKER_SOCKET=/var/run/docker.sock | ||
DOCKER_GROUP=docker | ||
USER=avd | ||
HOME_AVD=/home/avd/ | ||
|
||
# Install specific requirement file | ||
if [ ! -z "${AVD_REQUIREMENTS}" ]; then | ||
|
@@ -33,6 +34,22 @@ if [ ! -z "${AVD_GID}" ]; then | |
groupmod -g ${AVD_GID} avd | ||
fi | ||
|
||
# Update gitconfig with username and email | ||
if [ -n "${AVD_GIT_USER}" ]; then | ||
echo "Update gitconfig with ${AVD_GIT_USER}" | ||
sed -i "s/USERNAME/${AVD_GIT_USER}/g" ${HOME_AVD}/.gitconfig | ||
else | ||
echo "Update gitconfig with default username" | ||
sed -i "s/USERNAME/AVD Base USER/g" ${HOME_AVD}/.gitconfig | ||
fi | ||
if [ -n "${AVD_GIT_EMAIL}" ]; then | ||
echo "Update gitconfig with ${AVD_GIT_EMAIL}" | ||
sed -i "s/USER_EMAIL/${AVD_GIT_EMAIL}/g" ${HOME_AVD}/.gitconfig | ||
else | ||
echo "Update gitconfig with default email" | ||
sed -i "s/USER_EMAIL/[email protected]/g" ${HOME_AVD}/.gitconfig | ||
fi | ||
|
||
if [ -S ${DOCKER_SOCKET} ]; then | ||
sudo chmod 666 /var/run/docker.sock &>/dev/null | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[user] | ||
name = USERNAME | ||
email = USER_EMAIL | ||
[alias] | ||
# Generic command | ||
rollback = reset --hard | ||
recommit = commit --amend --no-edit | ||
commit-unsafe = commit --no-verify | ||
undo = reset HEAD~1 --mixed | ||
uncommit = reset --soft HEAD~1 | ||
|
||
# Misc command | ||
refresh = !git pull --rebase --prune $@ | ||
conflicts = !git ls-files -u | cut -f 2 | sort -u | ||
push-current = push -u origin HEAD | ||
|
||
# Logging & History | ||
last = log --stat -1 HEAD | ||
graph = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit | ||
logs = log --oneline --decorate --color | ||
|
||
# In Fork model | ||
forigin = fetch origin | ||
fupstream = fetch upstream | ||
fetch-all = !sh -c 'for remote in $(git remote);do git fetch remote;done' | ||
|
||
[core] | ||
excludesfile = ~/.gitignore_global | ||
[commit] | ||
template = ~/.stCommitMsg | ||
[pull] | ||
rebase = true | ||
[filter "lfs"] | ||
clean = git-lfs clean -- %f | ||
smudge = git-lfs smudge -- %f | ||
process = git-lfs filter-process | ||
required = true | ||
[pager] | ||
branch = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
DOCKER_SOCKET=/var/run/docker.sock | ||
DOCKER_GROUP=docker | ||
USER=avd | ||
HOME_AVD=/home/avd/ | ||
|
||
# Install specific requirement file | ||
if [ ! -z "${AVD_REQUIREMENTS}" ]; then | ||
|
@@ -33,6 +34,22 @@ if [ ! -z "${AVD_GID}" ]; then | |
groupmod -g ${AVD_GID} avd | ||
fi | ||
|
||
# Update gitconfig with username and email | ||
if [ -n "${AVD_GIT_USER}" ]; then | ||
echo "Update gitconfig with ${AVD_GIT_USER}" | ||
sed -i "s/USERNAME/${AVD_GIT_USER}/g" ${HOME_AVD}/.gitconfig | ||
else | ||
echo "Update gitconfig with default username" | ||
sed -i "s/USERNAME/AVD Base USER/g" ${HOME_AVD}/.gitconfig | ||
fi | ||
if [ -n "${AVD_GIT_EMAIL}" ]; then | ||
echo "Update gitconfig with ${AVD_GIT_EMAIL}" | ||
sed -i "s/USER_EMAIL/${AVD_GIT_EMAIL}/g" ${HOME_AVD}/.gitconfig | ||
else | ||
echo "Update gitconfig with default email" | ||
sed -i "s/USER_EMAIL/[email protected]/g" ${HOME_AVD}/.gitconfig | ||
fi | ||
|
||
if [ -S ${DOCKER_SOCKET} ]; then | ||
sudo chmod 666 /var/run/docker.sock &>/dev/null | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[user] | ||
name = USERNAME | ||
email = USER_EMAIL | ||
[alias] | ||
# Generic command | ||
rollback = reset --hard | ||
recommit = commit --amend --no-edit | ||
commit-unsafe = commit --no-verify | ||
undo = reset HEAD~1 --mixed | ||
uncommit = reset --soft HEAD~1 | ||
|
||
# Misc command | ||
refresh = !git pull --rebase --prune $@ | ||
conflicts = !git ls-files -u | cut -f 2 | sort -u | ||
push-current = push -u origin HEAD | ||
|
||
# Logging & History | ||
last = log --stat -1 HEAD | ||
graph = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit | ||
logs = log --oneline --decorate --color | ||
|
||
# In Fork model | ||
forigin = fetch origin | ||
fupstream = fetch upstream | ||
fetch-all = !sh -c 'for remote in $(git remote);do git fetch remote;done' | ||
|
||
[core] | ||
excludesfile = ~/.gitignore_global | ||
[commit] | ||
template = ~/.stCommitMsg | ||
[pull] | ||
rebase = true | ||
[filter "lfs"] | ||
clean = git-lfs clean -- %f | ||
smudge = git-lfs smudge -- %f | ||
process = git-lfs filter-process | ||
required = true | ||
[pager] | ||
branch = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
DOCKER_SOCKET=/var/run/docker.sock | ||
DOCKER_GROUP=docker | ||
USER=avd | ||
HOME_AVD=/home/avd/ | ||
|
||
# Install specific requirement file | ||
if [ ! -z "${AVD_REQUIREMENTS}" ]; then | ||
|
@@ -33,6 +34,22 @@ if [ ! -z "${AVD_GID}" ]; then | |
groupmod -g ${AVD_GID} avd | ||
fi | ||
|
||
# Update gitconfig with username and email | ||
if [ -n "${AVD_GIT_USER}" ]; then | ||
echo "Update gitconfig with ${AVD_GIT_USER}" | ||
sed -i "s/USERNAME/${AVD_GIT_USER}/g" ${HOME_AVD}/.gitconfig | ||
else | ||
echo "Update gitconfig with default username" | ||
sed -i "s/USERNAME/AVD Base USER/g" ${HOME_AVD}/.gitconfig | ||
fi | ||
if [ -n "${AVD_GIT_EMAIL}" ]; then | ||
echo "Update gitconfig with ${AVD_GIT_EMAIL}" | ||
sed -i "s/USER_EMAIL/${AVD_GIT_EMAIL}/g" ${HOME_AVD}/.gitconfig | ||
else | ||
echo "Update gitconfig with default email" | ||
sed -i "s/USER_EMAIL/[email protected]/g" ${HOME_AVD}/.gitconfig | ||
fi | ||
|
||
if [ -S ${DOCKER_SOCKET} ]; then | ||
sudo chmod 666 /var/run/docker.sock &>/dev/null | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[user] | ||
name = USERNAME | ||
email = USER_EMAIL | ||
[alias] | ||
# Generic command | ||
rollback = reset --hard | ||
recommit = commit --amend --no-edit | ||
commit-unsafe = commit --no-verify | ||
undo = reset HEAD~1 --mixed | ||
uncommit = reset --soft HEAD~1 | ||
|
||
# Misc command | ||
refresh = !git pull --rebase --prune $@ | ||
conflicts = !git ls-files -u | cut -f 2 | sort -u | ||
push-current = push -u origin HEAD | ||
|
||
# Logging & History | ||
last = log --stat -1 HEAD | ||
graph = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit | ||
logs = log --oneline --decorate --color | ||
|
||
# In Fork model | ||
forigin = fetch origin | ||
fupstream = fetch upstream | ||
fetch-all = !sh -c 'for remote in $(git remote);do git fetch remote;done' | ||
|
||
[core] | ||
excludesfile = ~/.gitignore_global | ||
[commit] | ||
template = ~/.stCommitMsg | ||
[pull] | ||
rebase = true | ||
[filter "lfs"] | ||
clean = git-lfs clean -- %f | ||
smudge = git-lfs smudge -- %f | ||
process = git-lfs filter-process | ||
required = true | ||
[pager] | ||
branch = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
#!/bin/bash | ||
|
||
DOCKER_SOCKET=/var/run/docker.sock | ||
DOCKER_GROUP=docker | ||
USER=avd | ||
HOME_AVD=/home/avd/ | ||
|
||
# Install specific requirement file | ||
if [ ! -z "${AVD_REQUIREMENTS}" ]; then | ||
if [ -f ${AVD_REQUIREMENTS} ]; then | ||
echo "Install new requirements from ${AVD_REQUIREMENTS}" | ||
pip3 install --user -r ${AVD_REQUIREMENTS} | ||
sudo -H -u ${USER} pip3 install --upgrade --user -r ${AVD_REQUIREMENTS} | ||
else | ||
echo "Requirement file not found, skipping..." | ||
fi | ||
|
@@ -14,7 +18,9 @@ fi | |
# Install specific ANSIBLE version | ||
if [ ! -z "${AVD_ANSIBLE}" ]; then | ||
echo "Install ansible with version ${AVD_ANSIBLE}" | ||
pip3 install --user ansible==${AVD_ANSIBLE} | ||
# Required for migration from 2.9 to 2.10 | ||
sudo -H -u ${USER} pip3 uninstall -y ansible | ||
sudo -H -u ${USER} pip3 install --upgrade --user ansible==${AVD_ANSIBLE} | ||
fi | ||
|
||
# Reconfigure AVD User id if set by user | ||
|
@@ -28,5 +34,28 @@ if [ ! -z "${AVD_GID}" ]; then | |
groupmod -g ${AVD_GID} avd | ||
fi | ||
|
||
# Update gitconfig with username and email | ||
if [ -n "${AVD_GIT_USER}" ]; then | ||
echo "Update gitconfig with ${AVD_GIT_USER}" | ||
sed -i "s/USERNAME/${AVD_GIT_USER}/g" ${HOME_AVD}/.gitconfig | ||
else | ||
echo "Update gitconfig with default username" | ||
sed -i "s/USERNAME/AVD Base USER/g" ${HOME_AVD}/.gitconfig | ||
fi | ||
if [ -n "${AVD_GIT_EMAIL}" ]; then | ||
echo "Update gitconfig with ${AVD_GIT_EMAIL}" | ||
sed -i "s/USER_EMAIL/${AVD_GIT_EMAIL}/g" ${HOME_AVD}/.gitconfig | ||
else | ||
echo "Update gitconfig with default email" | ||
sed -i "s/USER_EMAIL/[email protected]/g" ${HOME_AVD}/.gitconfig | ||
fi | ||
|
||
if [ -S ${DOCKER_SOCKET} ]; then | ||
sudo chmod 666 /var/run/docker.sock &>/dev/null | ||
fi | ||
|
||
export PATH=$PATH:/home/avd/.local/bin | ||
export LC_ALL=C.UTF-8 | ||
|
||
cd /projects/ | ||
su - avd -c "cd /projects && /bin/zsh" |
Oops, something went wrong.