introduce .env

This commit is contained in:
Harivansh Rathi 2026-04-01 04:32:08 +00:00
parent 4f46d2f3df
commit 5d97c33d7e
6 changed files with 51 additions and 24 deletions

2
.gitignore vendored
View file

@ -6,3 +6,5 @@ npm-debug.log*
.turbo/
coverage/
apps/web/.next/
.env.agent
.state/

View file

@ -44,7 +44,7 @@ func main() {
"exportId": "dev-export",
"protocol": "webdav",
"displayName": "Example export",
"mountUrl": env("BETTERNAS_EXAMPLE_MOUNT_URL", "http://localhost:8090/dav"),
"mountUrl": env("BETTERNAS_EXAMPLE_MOUNT_URL", "http://localhost:8090/dav/"),
"readonly": false,
"credentialMode": "session-token",
})

View file

@ -30,20 +30,35 @@ services:
dockerfile: apps/control-plane/Dockerfile
environment:
PORT: 3000
BETTERNAS_VERSION: local-dev
NEXTCLOUD_BASE_URL: http://nextcloud
BETTERNAS_VERSION: ${BETTERNAS_VERSION}
NEXTCLOUD_BASE_URL: ${NEXTCLOUD_BASE_URL}
BETTERNAS_EXAMPLE_MOUNT_URL: ${BETTERNAS_EXAMPLE_MOUNT_URL}
BETTERNAS_NODE_DIRECT_ADDRESS: ${BETTERNAS_NODE_DIRECT_ADDRESS}
ports:
- "3001:3000"
- "${BETTERNAS_CONTROL_PLANE_PORT}:3000"
healthcheck:
test:
[
"CMD-SHELL",
'node -e "fetch(''http://127.0.0.1:3000/health'').then((response) => process.exit(response.ok ? 0 : 1)).catch(() => process.exit(1))"',
]
test: ["CMD-SHELL", "wget -q -O /dev/null http://127.0.0.1:3000/health"]
interval: 5s
timeout: 5s
retries: 12
node-agent:
build:
context: ../..
dockerfile: apps/node-agent/Dockerfile
environment:
PORT: 8090
BETTERNAS_EXPORT_PATH: /data/export
ports:
- "${BETTERNAS_NODE_AGENT_PORT}:8090"
healthcheck:
test: ["CMD-SHELL", "wget -q -O /dev/null http://127.0.0.1:8090/health"]
interval: 5s
timeout: 5s
retries: 12
volumes:
- ${BETTERNAS_EXPORT_PATH}:/data/export
nextcloud:
image: nextcloud:31-apache
depends_on:
@ -53,17 +68,19 @@ services:
condition: service_healthy
control-plane:
condition: service_healthy
node-agent:
condition: service_healthy
environment:
POSTGRES_HOST: db
POSTGRES_DB: nextcloud
POSTGRES_USER: nextcloud
POSTGRES_PASSWORD: nextcloud
REDIS_HOST: redis
NEXTCLOUD_ADMIN_USER: admin
NEXTCLOUD_ADMIN_PASSWORD: admin
NEXTCLOUD_ADMIN_USER: ${NEXTCLOUD_ADMIN_USER}
NEXTCLOUD_ADMIN_PASSWORD: ${NEXTCLOUD_ADMIN_PASSWORD}
BETTERNAS_CONTROL_PLANE_URL: http://control-plane:3000
ports:
- "8080:80"
- "${BETTERNAS_NEXTCLOUD_PORT}:80"
volumes:
- nextcloud-data:/var/www/html
- nextcloud-custom-apps:/var/www/html/custom_apps

View file

@ -9,6 +9,10 @@
"format": "prettier --ignore-unknown --write . && turbo run format",
"format:check": "prettier --ignore-unknown --check . && turbo run format:check",
"check-types": "turbo run check-types",
"stack:up": "./scripts/dev-up",
"stack:down": "./scripts/dev-down",
"stack:verify": "./scripts/integration/verify-stack",
"clones:setup": "./scripts/setup-clones",
"test": "turbo run test",
"verify": "pnpm run guardrails && pnpm run format:check && turbo run lint check-types test build"
},

View file

@ -2,8 +2,8 @@
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
compose_file="$repo_root/infra/docker/compose.dev.yml"
# shellcheck disable=SC1091
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib/runtime-env.sh"
args=(down --remove-orphans)
@ -11,4 +11,4 @@ if [[ "${1:-}" == "--volumes" ]]; then
args+=(--volumes)
fi
docker compose -f "$compose_file" "${args[@]}"
compose "${args[@]}"

View file

@ -2,27 +2,28 @@
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
compose_file="$repo_root/infra/docker/compose.dev.yml"
# shellcheck disable=SC1091
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib/runtime-env.sh"
app_source_dir="$repo_root/apps/nextcloud-app"
nextcloud_occ() {
docker compose -f "$compose_file" exec -T --user www-data --workdir /var/www/html nextcloud php occ "$@"
compose exec -T --user www-data --workdir /var/www/html nextcloud php occ "$@"
}
nextcloud_is_installed() {
nextcloud_occ status --output=json 2>/dev/null | grep -q '"installed":true'
}
docker compose -f "$compose_file" up -d --build
compose up -d --build
docker compose -f "$compose_file" exec -T --user root nextcloud sh -lc '
compose exec -T --user root nextcloud sh -lc '
mkdir -p /var/www/html/custom_apps/betternascontrolplane
chown -R www-data:www-data /var/www/html/custom_apps
'
docker compose -f "$compose_file" cp "$app_source_dir/." nextcloud:/var/www/html/custom_apps/betternascontrolplane
docker compose -f "$compose_file" exec -T --user root nextcloud sh -lc '
compose cp "$app_source_dir/." nextcloud:/var/www/html/custom_apps/betternascontrolplane
compose exec -T --user root nextcloud sh -lc '
chown -R www-data:www-data /var/www/html/custom_apps/betternascontrolplane
'
@ -62,5 +63,8 @@ fi
nextcloud_occ app:enable --force betternascontrolplane >/dev/null
echo "Nextcloud: http://localhost:8080"
echo "betterNAS control plane: http://localhost:3001"
echo "Clone: $BETTERNAS_CLONE_NAME"
echo "Nextcloud: $NEXTCLOUD_BASE_URL"
echo "betterNAS control plane: http://localhost:$BETTERNAS_CONTROL_PLANE_PORT"
echo "betterNAS node agent: http://localhost:$BETTERNAS_NODE_AGENT_PORT"
echo "WebDAV mount URL: $BETTERNAS_EXAMPLE_MOUNT_URL"