Add more docker compatibility to run.sh

and improve README.md
This commit is contained in:
Ben 2021-10-09 17:24:04 +02:00
parent 92ac97803b
commit 9cf28154cf
Signed by: ben
GPG key ID: 0F54A7ED232D3319
2 changed files with 36 additions and 14 deletions

View file

@ -8,19 +8,33 @@ Place this app in **nextcloud/apps/**
This is the [tutorial app](https://docs.nextcloud.com/server/latest/developer_manual/app_development/tutorial.html) which shows how to develop a very simple notes app. This is the [tutorial app](https://docs.nextcloud.com/server/latest/developer_manual/app_development/tutorial.html) which shows how to develop a very simple notes app.
## Installing dependencies ## Development
Docker or Podman is required for the dev environment.
Other than that composer and npm/nodejs must be installed.
### Mac OS
```shell
brew install coreutils
```
### All
```shell
npm install
make
```
### Start dev environment
Starting the development environment with your container runtime should be as easy as
```shell
./run.sh
```
make composer
## Frontend development ## Frontend development
The app tutorial also shows the very basic implementation of an app frontend using [Vue.js](https://vuejs.org/). To build the frontend code after doing changes to its source in `src/` requires to have Node and npm installed. The app tutorial also shows the very basic implementation of an app frontend using [Vue.js](https://vuejs.org/). To build the frontend code after doing changes to its source in `src/` requires to have Node and npm installed.

28
run.sh
View file

@ -3,23 +3,23 @@
set -xeuo pipefail set -xeuo pipefail
IFS=$'\n\t' IFS=$'\n\t'
DIR="${0%/*}" DIR="$(realpath ${0%/*})"
RUNTIME_IS_PODMAN="false" RUNTIME_IS_PODMAN="false"
if [[ -x "$(which podman)" ]]; then if [[ -x "$(which podman)" ]]; then
CONTAINER_RUNTIME="$(which podman)" CONTAINER_RUNTIME="$(which podman 2> /dev/null)"
RUNTIME_IS_PODMAN="true" RUNTIME_IS_PODMAN="true"
elif [[ -x "$(which docker)" ]]; then elif [[ -x "$(which docker)" ]]; then
CONTAINER_RUNTIME="$(which docker)" CONTAINER_RUNTIME="$(which docker 2> /dev/null)"
else else
echo "Container runtime (docker/podman) not found!" echo "Container runtime (docker/podman) not found!"
exit 1 exit 1
fi fi
# replace containers # replace containers
if $CONTAINER_RUNTIME inspect --type container synapse; then if $CONTAINER_RUNTIME inspect --type container synapse 1> /dev/null; then
$CONTAINER_RUNTIME rm -f synapse $CONTAINER_RUNTIME rm -f synapse
fi fi
if $CONTAINER_RUNTIME inspect --type container nextcloud; then if $CONTAINER_RUNTIME inspect --type container nextcloud 1> /dev/null; then
$CONTAINER_RUNTIME rm -f nextcloud $CONTAINER_RUNTIME rm -f nextcloud
fi fi
@ -38,10 +38,7 @@ $CONTAINER_RUNTIME run -d \
$CONTAINER_RUNTIME exec nextcloud bash -c 'apt-get update && apt-get install -y git' $CONTAINER_RUNTIME exec nextcloud bash -c 'apt-get update && apt-get install -y git'
$CONTAINER_RUNTIME exec nextcloud chown -R 33 /var/www/html/custom_apps $CONTAINER_RUNTIME exec nextcloud chown -R 33 /var/www/html/custom_apps
if [[ $(id -u) -eq 0 || $RUNTIME_IS_PODMAN != "true" ]]; then if [[ $(id -u) -ne 0 && $RUNTIME_IS_PODMAN == "true" ]]; then
$CONTAINER_RUNTIME exec nextcloud chown -R 33 /var/www/html/custom_apps
$CONTAINER_RUNTIME exec nextcloud chmod -R ug+rw /var/www/html/custom_apps
else
$CONTAINER_RUNTIME unshare -- chown -R 33 "$DIR" $CONTAINER_RUNTIME unshare -- chown -R 33 "$DIR"
$CONTAINER_RUNTIME unshare -- chgrp -R 0 "$DIR" $CONTAINER_RUNTIME unshare -- chgrp -R 0 "$DIR"
$CONTAINER_RUNTIME unshare -- chmod -R ug+rw "$DIR" $CONTAINER_RUNTIME unshare -- chmod -R ug+rw "$DIR"
@ -52,9 +49,20 @@ $CONTAINER_RUNTIME exec --user 33 nextcloud php occ maintenance:install --databa
$CONTAINER_RUNTIME exec --user 33 nextcloud php occ config:system:set --value=true --type=boolean debug $CONTAINER_RUNTIME exec --user 33 nextcloud php occ config:system:set --value=true --type=boolean debug
$CONTAINER_RUNTIME exec --user 33 nextcloud php occ app:enable --force upschooling $CONTAINER_RUNTIME exec --user 33 nextcloud php occ app:enable --force upschooling
SYNAPSE_DATA_VOLUME_EXISTS="false"
if [[ $RUNTIME_IS_PODMAN == "true" ]]; then
if $CONTAINER_RUNTIME volume exists synapse-data; then if $CONTAINER_RUNTIME volume exists synapse-data; then
echo "Found existing synapse-data volume" echo "Found existing synapse-data volume (via volume exists)"
SYNAPSE_DATA_VOLUME_EXISTS="true"
fi
else else
if $CONTAINER_RUNTIME volume inspect synapse-data 1> /dev/null; then
echo "Found existing synapse-data volume (via volume inspect)"
SYNAPSE_DATA_VOLUME_EXISTS="true"
fi
fi
if [[ $SYNAPSE_DATA_VOLUME_EXISTS == "true" ]]; then
$CONTAINER_RUNTIME run --rm \ $CONTAINER_RUNTIME run --rm \
--name=synapse \ --name=synapse \
--hostname synapse \ --hostname synapse \