Update README
This commit is contained in:
parent
11e86dbdcf
commit
96aa95c404
40
README.md
40
README.md
|
|
@ -1,14 +1,42 @@
|
||||||
# Container
|
# Container
|
||||||
|
|
||||||
This project contains my personal docker compose configurations.
|
This project contains my personal docker compose configurations.
|
||||||
To use this configuartions the .env files have to be decrypted with
|
|
||||||
the key@dmeiburg.de key
|
#### Operating principle:
|
||||||
|
Changes in this repo get pushed to a bare repo on dmeiburg.de.
|
||||||
|
Whenever a push is received a post-receive hook runs.
|
||||||
|
|
||||||
|
The post-receive hook then:
|
||||||
|
- deploys the code into a working directory
|
||||||
|
- decrypts .env.gpg files
|
||||||
|
- restarts stacks with changed compose files
|
||||||
|
|
||||||
|
The env files are encrypted for key@dmeiburg.de and server@dmeiburg.de.
|
||||||
|
|
||||||
|
#### Server setup
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ gpg -d .env.gpg > .env
|
# create bare repo on dmeiburg.de
|
||||||
|
mkdir -p git/container.git
|
||||||
|
cd git/container.git
|
||||||
|
git init --bare
|
||||||
```
|
```
|
||||||
|
|
||||||
To encrypt an .env file the following command is used:
|
```sh
|
||||||
|
# install the post receive hook
|
||||||
|
# whenever the hook is edited, this command has to be used again
|
||||||
|
scp post-receive dmeiburg:~/git/container/hooks/
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Local setup
|
||||||
|
```sh
|
||||||
|
# add bare repos as remote on local machine
|
||||||
|
git remote add dmeiburg ssh://root@dmeiburg.de:/root/git/container.git
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Encrypting .env files
|
||||||
|
|
||||||
|
To encrypt an .env files, the following command is used:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ gpg -er key@dmeiburg.de -r server@dmeiburg.de .env
|
$ gpg -er key@dmeiburg.de -r server@dmeiburg.de .env
|
||||||
|
|
@ -18,8 +46,8 @@ $ gpg -er key@dmeiburg.de -r server@dmeiburg.de .env
|
||||||
#### Deployment
|
#### Deployment
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git remote add dmeiburg ssh://root@dmeiburg.de:/root/git/container.git
|
|
||||||
git push dmeiburg
|
git push dmeiburg
|
||||||
```
|
```
|
||||||
|
|
||||||
Make sure `post-receive` hook is installed in the bare repository.
|
If necessary the post-receive hook has to be updated via scp.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,15 @@
|
||||||
WORK_TREE=~/container
|
WORK_TREE=~/container
|
||||||
|
|
||||||
# get changed folders
|
# get changed folders
|
||||||
changed=`GIT_WORK_TREE=$WORK_TREE git diff --dirstat=files,0 HEAD | awk '{print $NF}' `
|
changed_apps=`GIT_WORK_TREE=$WORK_TREE git diff --dirstat=files,0 HEAD | awk '{print $NF}' `
|
||||||
|
[ -n "$changed_apps" ] && echo -e "Changed apps:\n$changed_apps"
|
||||||
[ -n "$changed" ] && echo -e "Changed apps:\n$changed"
|
|
||||||
|
|
||||||
# update files in working direcotry
|
# update files in working direcotry
|
||||||
GIT_WORK_TREE=~/container git checkout -f
|
GIT_WORK_TREE=~/container git checkout -f
|
||||||
|
|
||||||
# restart changed docker compose stacks
|
# restart changed docker compose stacks
|
||||||
for app in $changed; do
|
for app in $changed_apps; do
|
||||||
cd $WORK_TREE/$changed
|
cd $WORK_TREE/$app
|
||||||
echo -e "\nUpdate $app"
|
echo -e "\nUpdate $app"
|
||||||
|
|
||||||
# remove old .env if no .env.gpg is supplied
|
# remove old .env if no .env.gpg is supplied
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue