From 2dee620e3637385c50f2c74b68d1d4a1889b317e Mon Sep 17 00:00:00 2001 From: James Kolpack Date: Thu, 19 Mar 2026 21:56:46 -0400 Subject: [PATCH] Update Dockerfile and scripts for v1 layout compatibility, enhancing directory structure and credential handling. Adjust paths for executable and storage, and improve README documentation to reflect changes. --- Dockerfile | 45 +++++++++++------------ README-Docker.md | 22 ++++++++--- README-V1.md | 59 ++++++++++++++++++++++++++++++ build-docker.ps1 | 4 +- build-docker.sh | 4 +- piscal-manager/piscal_launcher.cfg | 13 ++++--- 6 files changed, 111 insertions(+), 36 deletions(-) create mode 100644 README-V1.md diff --git a/Dockerfile b/Dockerfile index 2caaa84..0a4722b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,12 +29,12 @@ RUN make # Stage 2: Runtime stage - Create minimal application container FROM ubuntu:latest -# Build arguments for configurable credentials and paths +# Build arguments for configurable credentials and paths (v1 VM layout) ARG SSH_USERNAME=piscaladmin ARG SSH_PASSWORD=piscaladmin ARG SSH_GROUP=piscaladmin ARG STORAGE_PATH=/home/piscaladmin/LeafWeb_storage -ARG PISCAL_EXECUTABLE=/srv/piscal +ARG PISCAL_EXECUTABLE=/home/piscaladmin/piscal_executable/piscal # Install runtime dependencies only RUN set -xe \ @@ -67,12 +67,13 @@ RUN set -xe \ RUN set -xe \ && mkdir /run/sshd -# Ensure the job/workspace base under /srv is writable. -# The client uses `/srv/${PiscalDirectoryName}/input` and `PiscalDirectoryName` -# can itself be prefixed with `LeafWeb/...`. +# v1 VM layout: LeafWeb contains scripts + project directories +# Create LeafWeb (scripts and job dirs), piscal_executable, and storage RUN set -xe \ - && mkdir -p /srv/LeafWeb \ - && chown -R ${SSH_USERNAME}:${SSH_GROUP} /srv/LeafWeb + && mkdir -p /home/${SSH_USERNAME}/LeafWeb \ + && mkdir -p /home/${SSH_USERNAME}/piscal_executable \ + && chown -R ${SSH_USERNAME}:${SSH_GROUP} /home/${SSH_USERNAME}/LeafWeb \ + && chown -R ${SSH_USERNAME}:${SSH_GROUP} /home/${SSH_USERNAME}/piscal_executable # Create storage directory structure with proper ownership RUN set -xe \ @@ -80,25 +81,23 @@ RUN set -xe \ && mkdir -p ${STORAGE_PATH}/output \ && chown -R ${SSH_USERNAME}:${SSH_GROUP} ${STORAGE_PATH} -# Copy compiled executable from builder stage -COPY --from=builder /build/leafres/testrun/piscal /srv/piscal +# Copy compiled executable and scripts to staging dir (COPY can't use ARG in dest) +COPY --from=builder /build/leafres/testrun/piscal /tmp/piscal +COPY piscal-manager/piscal_launcher.sh piscal-manager/piscal_manager.sh piscal-manager/subdir_year.sh piscal-manager/README.txt /tmp/leafweb/ -# Copy piscal-manager scripts (excluding .cfg, we'll generate it) -COPY piscal-manager/*.sh /srv/ -COPY piscal-manager/README.txt /srv/ - -# Generate piscal_launcher.cfg with build-time parameters +# Install to user's home (supports custom SSH_USERNAME) RUN set -xe \ - && echo "piscal_executable=\"${PISCAL_EXECUTABLE}\"" > /srv/piscal_launcher.cfg \ - && echo "storage_directory=\"${STORAGE_PATH}\"" >> /srv/piscal_launcher.cfg \ - && chown ${SSH_USERNAME}:${SSH_GROUP} /srv/piscal_launcher.cfg + && cp /tmp/piscal /home/${SSH_USERNAME}/piscal_executable/piscal \ + && chown ${SSH_USERNAME}:${SSH_GROUP} /home/${SSH_USERNAME}/piscal_executable/piscal \ + && cp /tmp/leafweb/* /home/${SSH_USERNAME}/LeafWeb/ \ + && echo "piscal_executable=\"${PISCAL_EXECUTABLE}\"" > /home/${SSH_USERNAME}/LeafWeb/piscal_launcher.cfg \ + && echo "storage_directory=\"${STORAGE_PATH}\"" >> /home/${SSH_USERNAME}/LeafWeb/piscal_launcher.cfg \ + && chown ${SSH_USERNAME}:${SSH_GROUP} /home/${SSH_USERNAME}/LeafWeb/* \ + && find /home/${SSH_USERNAME}/LeafWeb -name "*.sh" -type f -exec sed -i 's/\r$//' {} \; \ + && chmod +x /home/${SSH_USERNAME}/LeafWeb/*.sh || true \ + && rm -rf /tmp/piscal /tmp/leafweb -# Fix Windows line endings (CRLF -> LF) for scripts and make scripts executable -RUN set -xe \ - && find /srv -name "*.sh" -type f -exec sed -i 's/\r$//' {} \; \ - && chmod +x /srv/*.sh || true - -WORKDIR /srv +WORKDIR /home/${SSH_USERNAME}/LeafWeb EXPOSE 22 CMD ["/usr/sbin/sshd", "-D"] diff --git a/README-Docker.md b/README-Docker.md index f9b112c..ea7882e 100644 --- a/README-Docker.md +++ b/README-Docker.md @@ -64,16 +64,26 @@ The Dockerfile accepts these build arguments if you need to customize: | `SSH_PASSWORD` | `piscaladmin` | SSH password for container access | | `SSH_GROUP` | `piscaladmin` | Primary group for SSH user | | `STORAGE_PATH` | `/home/piscaladmin/LeafWeb_storage` | Storage directory for PISCAL data | -| `PISCAL_EXECUTABLE` | `/srv/piscal` | Path to PISCAL executable | +| `PISCAL_EXECUTABLE` | `/home/piscaladmin/piscal_executable/piscal` | Path to PISCAL executable | -### Storage Directory Structure +### v1 Directory Layout (VM-compatible) -The storage directory is automatically created with: +The image uses the v1 layout expected by the LeafWeb client: ``` -/home/piscaladmin/LeafWeb_storage/ -├── input/ # Input files for processing -└── output/ # Results from PISCAL processing +/home/piscaladmin/ +├── LeafWeb/ # Scripts + project directories +│ ├── piscal_launcher.cfg +│ ├── piscal_launcher.sh +│ ├── piscal_manager.sh +│ ├── subdir_year.sh +│ ├── README.txt +│ └── / # Job dirs (e.g. 280_CinnamomumbodinieriLévl) +├── LeafWeb_storage/ +│ ├── input/ +│ └── output/ +└── piscal_executable/ + └── piscal ``` ### Port Mapping diff --git a/README-V1.md b/README-V1.md new file mode 100644 index 0000000..f172acf --- /dev/null +++ b/README-V1.md @@ -0,0 +1,59 @@ +# v1 VM Deployment (LeafWeb Layout) + +This branch configures PISCAL for deployment on a VM matching the layout used by `piscal.eastus.cloudapp.azure.com`, so the LeafWeb client can access jobs and storage at the expected paths. + +## Directory Layout + +``` +/home/piscaladmin/ +├── LeafWeb/ # Scripts + project directories +│ ├── piscal_launcher.cfg # Config (piscal_executable, storage paths) +│ ├── piscal_launcher.sh +│ ├── piscal_manager.sh +│ ├── subdir_year.sh +│ ├── README.txt +│ ├── 280_CinnamomumbodinieriLévl/ # Project dirs (input/, output/, run/, etc.) +│ ├── 311_AnnaAsaday3high/ +│ └── ... +├── LeafWeb_storage/ # Shared storage for client +│ ├── input/ +│ └── output/ +├── piscal/ # Source (optional) +└── piscal_executable/ # Compiled binary + └── piscal +``` + +## Deployment + +**Docker (recommended):** The Docker image uses this layout by default. See [README-Docker.md](README-Docker.md). + +**Manual VM deployment:** Copy scripts to LeafWeb and the compiled `piscal` binary to `piscal_executable/`: + +```bash +ssh piscaladmin@host 'mkdir -p ~/LeafWeb ~/piscal_executable ~/LeafWeb_storage/input ~/LeafWeb_storage/output' +scp piscal-manager/*.cfg piscal-manager/*.sh piscal-manager/README.txt piscaladmin@host:~/LeafWeb/ +scp leafres/testrun/piscal piscaladmin@host:~/piscal_executable/ +ssh piscaladmin@host 'chmod +x ~/LeafWeb/*.sh' +``` + +## Configuration + +`piscal_launcher.cfg` uses VM paths: + +- `piscal_executable="/home/piscaladmin/piscal_executable/piscal"` +- `storage_directory="/home/piscaladmin/LeafWeb_storage"` + +Adjust if your VM uses different locations. + +## Running Jobs + +From `~/LeafWeb`: + +```bash +cd ~/LeafWeb +./piscal_manager.sh -d 280_CinnamomumbodinieriLévl -s -p C3_photosynthesis_leafweb +./piscal_manager.sh -d 280_CinnamomumbodinieriLévl # status +./piscal_manager.sh -d 280_CinnamomumbodinieriLévl -c # cleanup +``` + +The `-d` argument is the project directory name (a subdir of LeafWeb). diff --git a/build-docker.ps1 b/build-docker.ps1 index 36721f0..ced2427 100644 --- a/build-docker.ps1 +++ b/build-docker.ps1 @@ -26,10 +26,12 @@ if ($LASTEXITCODE -eq 0) { Write-Host " - piscal:latest" -ForegroundColor Green Write-Host " - piscal:dev" -ForegroundColor Green Write-Host "" - Write-Host "Default credentials:" -ForegroundColor Cyan + Write-Host "Default credentials (v1 layout):" -ForegroundColor Cyan Write-Host " Username: piscaladmin" -ForegroundColor Cyan Write-Host " Password: piscaladmin" -ForegroundColor Cyan + Write-Host " LeafWeb: /home/piscaladmin/LeafWeb (scripts + project dirs)" -ForegroundColor Cyan Write-Host " Storage: /home/piscaladmin/LeafWeb_storage" -ForegroundColor Cyan + Write-Host " Executable: /home/piscaladmin/piscal_executable/piscal" -ForegroundColor Cyan Write-Host "" Write-Host "To run: docker run -d -p 2222:22 --name piscal-server piscal:latest" -ForegroundColor Yellow Write-Host "To SSH: ssh -p 2222 piscaladmin@localhost (password: piscaladmin)" -ForegroundColor Yellow diff --git a/build-docker.sh b/build-docker.sh index 205a342..3e74df0 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -25,10 +25,12 @@ echo " - piscal:${VERSION}" echo " - piscal:latest" echo " - piscal:dev" echo "" -echo "Default credentials:" +echo "Default credentials (v1 layout):" echo " Username: piscaladmin" echo " Password: piscaladmin" +echo " LeafWeb: /home/piscaladmin/LeafWeb (scripts + project dirs)" echo " Storage: /home/piscaladmin/LeafWeb_storage" +echo " Executable: /home/piscaladmin/piscal_executable/piscal" echo "" echo "To run: docker run -d -p 2222:22 --name piscal-server piscal:latest" echo "To SSH: ssh -p 2222 piscaladmin@localhost (password: piscaladmin)" diff --git a/piscal-manager/piscal_launcher.cfg b/piscal-manager/piscal_launcher.cfg index 3493172..37fa661 100644 --- a/piscal-manager/piscal_launcher.cfg +++ b/piscal-manager/piscal_launcher.cfg @@ -1,7 +1,10 @@ -# NOTE: This file is for reference only when using non-Docker deployments. -# For Docker builds, this file is generated dynamically at build time from -# Dockerfile ARG values (see Dockerfile). The Docker-generated version will -# use the configured SSH_USERNAME and STORAGE_PATH build arguments. +# v1 VM-compatible configuration +# Deploy this file to /home/piscaladmin/LeafWeb/ alongside piscal_launcher.sh, +# piscal_manager.sh, and subdir_year.sh. Project directories (e.g. 280_*, +# 311_*) live as subdirs of LeafWeb. +# +# For Docker builds, this file is NOT used; the Dockerfile generates +# Docker builds generate this file in LeafWeb at build time. -piscal_executable="/srv/piscal" +piscal_executable="/home/piscaladmin/piscal_executable/piscal" storage_directory="/home/piscaladmin/LeafWeb_storage"