Update README

This commit is contained in:
Daniel Meiburg 2023-02-13 01:16:22 +01:00
parent 11e86dbdcf
commit 96aa95c404
Signed by: dm
GPG Key ID: E5827ECFFE0AA4F2
2 changed files with 38 additions and 11 deletions

View File

@ -1,14 +1,42 @@
# Container
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
$ 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
$ 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
```bash
git remote add dmeiburg ssh://root@dmeiburg.de:/root/git/container.git
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.

View File

@ -6,16 +6,15 @@
WORK_TREE=~/container
# get changed folders
changed=`GIT_WORK_TREE=$WORK_TREE git diff --dirstat=files,0 HEAD | awk '{print $NF}' `
[ -n "$changed" ] && echo -e "Changed apps:\n$changed"
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"
# update files in working direcotry
GIT_WORK_TREE=~/container git checkout -f
# restart changed docker compose stacks
for app in $changed; do
cd $WORK_TREE/$changed
for app in $changed_apps; do
cd $WORK_TREE/$app
echo -e "\nUpdate $app"
# remove old .env if no .env.gpg is supplied