Skip to content

Commit

Permalink
just: add more structure and comments
Browse files Browse the repository at this point in the history
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
  • Loading branch information
pbek committed Sep 19, 2024
1 parent bccfd94 commit 3e7288e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
5 changes: 3 additions & 2 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ log in to your Nextcloud instance.
For debugging, you can show the `nextcloud.log`:

```bash
make show-log
just show-log
```

There also is a [logging web interface](http://localhost:8081/index.php/settings/admin/logging).
Expand All @@ -24,5 +24,6 @@ There also is a [logging web interface](http://localhost:8081/index.php/settings
In case something is broken try to reset the container:

```bash
docker compose build; docker compose down; docker volume rm nextcloud-qownnotesapi_nextcloud
just build
just reset
```
30 changes: 25 additions & 5 deletions docker/justfile
Original file line number Diff line number Diff line change
@@ -1,53 +1,73 @@
# Use `just <recipe>` to run a recipe
# https://just.systems/man/en/

# By default, run the `--choose` command
# By default, run the `--list` command
default:
@just --choose
@just --list

# Variables
# Try to use "docker compose" and fall back to "docker-compose" if not available

dockerComposeCommand := `docker compose > /dev/null && echo docker compose || echo docker-compose`
containerName := "nextcloud-qownnotesapi-app-1"
volumeName := "nextcloud-qownnotesapi_nextcloud"

# Aliases

alias remove-volumes := reset

# Check the code, run tests and sign the app
all: check-code test sign-app

# Build the docker image
build:
{{ dockerComposeCommand }} build

# Fetch the database from the container
fetch-db:
{{ dockerComposeCommand }} run --rm app su -c "cp data/mydb.db apps/qownnotesapi" www-data

# Push the database to the container
push-db:
{{ dockerComposeCommand }} run --rm app su -c "cp apps/qownnotesapi/mydb.db* data" www-data

# Open a shell in the container
bash:
{{ dockerComposeCommand }} run --rm app su -c "bash" www-data

# Open a shell in the container as root
bash-root:
{{ dockerComposeCommand }} run --rm app bash

# Run a sidecar container with more debugging tools
slim-shell:
slim debug --target nextcloud-qownnotesapi-app-1
slim debug --target {{ containerName }}

# Turn off maintenance mode
maintenance-mode-off:
{{ dockerComposeCommand }} run --rm app su -c "./occ maintenance:mode --off" www-data

# Run the app:check-code command
check-code:
{{ dockerComposeCommand }} run --rm app su -c "./occ app:check-code qownnotesapi" www-data

# Run the app signing command for Nextcloud
sign-app:
{{ dockerComposeCommand }} run --rm app ../sign-app.sh www-data

# Run the app signing command for Owncloud
sign-app-owncloud:
{{ dockerComposeCommand }} run --rm app ../sign-app-owncloud.sh

# Run the tests
test:
{{ dockerComposeCommand }} run --rm app su -c "cd apps/qownnotesapi && make test" www-data

# Show Nextcloud logs
show-log:
{{ dockerComposeCommand }} run --rm app tail -f /var/www/html/data/nextcloud.log

remove-volumes:
# Remove the docker volume
reset:
docker compose down
docker volume rm nextcloud-qownnotesapi_nextcloud
docker volume rm {{ volumeName }}
9 changes: 7 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
# Use `just <recipe>` to run a recipe
# https://just.systems/man/en/

# By default, run the `--choose` command
# By default, run the `--list` command
default:
@just --choose
@just --list

# Variables

transferDir := `if [ -d "$HOME/NextcloudPrivate/Transfer" ]; then echo "$HOME/NextcloudPrivate/Transfer"; else echo "$HOME/Nextcloud/Transfer"; fi`

# Open a terminal with the qownnotesapi session
[group('dev')]
term:
zellij --layout term.kdl attach qownnotesapi -c

# Kill the qownnotesapi session
[group('dev')]
term-kill:
zellij delete-session qownnotesapi -f

# Apply the patch to the qownnotesapi repository
[group('patch')]
git-apply-patch:
git apply {{ transferDir }}/qownnotesapi.patch

# Create a patch from the staged changes in the qownnotesapi repository
[group('patch')]
@git-create-patch:
echo "transferDir: {{ transferDir }}"
git diff --no-ext-diff --staged --binary > {{ transferDir }}/qownnotesapi.patch
ls -l1t {{ transferDir }}/ | head -2

# Format all justfiles
[group('linter')]
just-format:
#!/usr/bin/env bash
# Find all files named "justfile" recursively and run just --fmt --unstable on them
Expand Down

0 comments on commit 3e7288e

Please sign in to comment.