Archived
fix(docker): initialize dev data permissions
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@jmfederico/pi-web": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Initialize shared Docker development data directory ownership before starting the dev session daemon.
|
||||||
@@ -214,6 +214,8 @@ Restart `sessiond` manually after changes that affect `src/server/sessiond.ts`,
|
|||||||
|
|
||||||
The dev setup intentionally has the same Docker socket and broad host mounts as the runtime setup. The same trust warnings apply.
|
The dev setup intentionally has the same Docker socket and broad host mounts as the runtime setup. The same trust warnings apply.
|
||||||
|
|
||||||
|
On startup, a short `data-init` service creates the shared `/data` subdirectories and gives them to `PI_WEB_UID:PI_WEB_GID`. This handles the common Flatcar/Docker case where a missing bind-mount directory is created as root by the Docker daemon.
|
||||||
|
|
||||||
### Sharing runtime and development state
|
### Sharing runtime and development state
|
||||||
|
|
||||||
Runtime and dev mode both use `/data` inside the containers. By default they now point at the same host directory:
|
Runtime and dev mode both use `/data` inside the containers. By default they now point at the same host directory:
|
||||||
|
|||||||
+28
-3
@@ -15,6 +15,11 @@ x-pi-web-dev-environment: &pi-web-dev-environment
|
|||||||
NPM_CONFIG_UPDATE_NOTIFIER: "false"
|
NPM_CONFIG_UPDATE_NOTIFIER: "false"
|
||||||
NPM_CONFIG_CACHE: /data/npm-cache
|
NPM_CONFIG_CACHE: /data/npm-cache
|
||||||
|
|
||||||
|
x-pi-web-dev-data-volume: &pi-web-dev-data-volume
|
||||||
|
type: bind
|
||||||
|
source: ${PI_WEB_DOCKER_DATA_DIR:-${HOME}/.local/share/pi-web-docker/data}
|
||||||
|
target: /data
|
||||||
|
|
||||||
x-pi-web-dev-volumes: &pi-web-dev-volumes
|
x-pi-web-dev-volumes: &pi-web-dev-volumes
|
||||||
- type: bind
|
- type: bind
|
||||||
source: ..
|
source: ..
|
||||||
@@ -22,9 +27,7 @@ x-pi-web-dev-volumes: &pi-web-dev-volumes
|
|||||||
- type: volume
|
- type: volume
|
||||||
source: node_modules
|
source: node_modules
|
||||||
target: /workspace/node_modules
|
target: /workspace/node_modules
|
||||||
- type: bind
|
- *pi-web-dev-data-volume
|
||||||
source: ${PI_WEB_DOCKER_DATA_DIR:-${HOME}/.local/share/pi-web-docker/data}
|
|
||||||
target: /data
|
|
||||||
- type: bind
|
- type: bind
|
||||||
source: /var/run/docker.sock
|
source: /var/run/docker.sock
|
||||||
target: /var/run/docker.sock
|
target: /var/run/docker.sock
|
||||||
@@ -43,11 +46,33 @@ x-pi-web-dev-volumes: &pi-web-dev-volumes
|
|||||||
read_only: true
|
read_only: true
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
data-init:
|
||||||
|
build: *pi-web-dev-build
|
||||||
|
image: ${PI_WEB_DEV_IMAGE:-pi-web:dev}
|
||||||
|
command:
|
||||||
|
- bash
|
||||||
|
- -lc
|
||||||
|
- |
|
||||||
|
set -euo pipefail
|
||||||
|
mkdir -p /data/home /data/config /data/npm-cache /data/pi-web /data/pi-agent
|
||||||
|
chown -R "${PI_WEB_UID:-1000}:${PI_WEB_GID:-1000}" /data
|
||||||
|
user: "0:0"
|
||||||
|
security_opt:
|
||||||
|
- label=disable
|
||||||
|
environment:
|
||||||
|
PI_WEB_UID: ${PI_WEB_UID:-1000}
|
||||||
|
PI_WEB_GID: ${PI_WEB_GID:-1000}
|
||||||
|
volumes:
|
||||||
|
- *pi-web-dev-data-volume
|
||||||
|
|
||||||
sessiond:
|
sessiond:
|
||||||
build: *pi-web-dev-build
|
build: *pi-web-dev-build
|
||||||
image: ${PI_WEB_DEV_IMAGE:-pi-web:dev}
|
image: ${PI_WEB_DEV_IMAGE:-pi-web:dev}
|
||||||
command: ["npm", "run", "start:sessiond"]
|
command: ["npm", "run", "start:sessiond"]
|
||||||
working_dir: /workspace
|
working_dir: /workspace
|
||||||
|
depends_on:
|
||||||
|
data-init:
|
||||||
|
condition: service_completed_successfully
|
||||||
user: "${PI_WEB_UID:-1000}:${PI_WEB_GID:-1000}"
|
user: "${PI_WEB_UID:-1000}:${PI_WEB_GID:-1000}"
|
||||||
group_add:
|
group_add:
|
||||||
- "${DOCKER_GID:-0}"
|
- "${DOCKER_GID:-0}"
|
||||||
|
|||||||
Reference in New Issue
Block a user