diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 108685b..f747721 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,9 +1,10 @@ { "name": "Python and R Dev Container", - "build": { - "dockerfile": "../Dockerfile", - "context": "." - }, + "image": "mewu/data_access:latest", // Use pre-built image +// "build": { +// "dockerfile": "../Dockerfile", +// "context": ".." +// }, "customizations": { "vscode": { "extensions": [ @@ -25,15 +26,13 @@ // "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolder},type=bind,consistency=cached" // ], "postCreateCommand": "bash ./.devcontainer/postCreateCommand.sh", - "postStartCommand:": "rstudio-server restart && jupyter lab --ip=0.0.0.0 --no-browser --allow-root --NotebookApp.token=''", + "postStartCommand": "bash ./.devcontainer/postStartCommand.sh", "portsAttributes": { "8888": { - "label": "Jupyter Lab", - "onAutoForward": "always", + "label": "Jupyter Lab" }, "8787": { - "label": "R studio", - "onAutoForward": "always" + "label": "R studio" } }, "forwardPorts": [8787, 8888] diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh index d59b128..5249c81 100644 --- a/.devcontainer/postCreateCommand.sh +++ b/.devcontainer/postCreateCommand.sh @@ -19,10 +19,4 @@ fi # cd r && R -e 'renv::restore()' #fi -# change the default working directory for RStudio -echo "session-default-working-dir=${CODESPACE_VSCODE_FOLDER}" | sudo tee -a /etc/rstudio/rsession.conf - -rstudio-server start > rstudio_server.log 2>&1 & -jupyter lab --ip=0.0.0.0 --no-browser --allow-root --NotebookApp.token='' 2>&1 & - echo "Dev environment setup completed!" diff --git a/.devcontainer/postStartCommand.sh b/.devcontainer/postStartCommand.sh new file mode 100644 index 0000000..4a95519 --- /dev/null +++ b/.devcontainer/postStartCommand.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# change the default working directory for RStudio +echo "session-default-working-dir=${CODESPACE_VSCODE_FOLDER}" | sudo tee -a /etc/rstudio/rsession.conf + +# Start RStudio Server +echo "Start R studeio Server" +rstudio-server start > rstudio_server.log 2>&1 & +sleep 5 # Give some time for the service to start +if ! pgrep -x "rstudio-server" > /dev/null; then + echo "RStudio Server failed to start. Restarting..." + rstudio-server restart > rstudio_server.log 2>&1 & +fi + +sleep 5 +echo "Setup Jupyter-lab" +# Start Jupyter Lab +jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --allow-root --NotebookApp.token='' > jupyter_lab.log 2>&1 & +sleep 5 +if ! pgrep -x "jupyter-lab" > /dev/null; then + echo "Jupyter Lab failed to start. Restarting..." + jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --allow-root --NotebookApp.token='' > jupyter_lab.log 2>&1 & +fi + +echo "Dev environment startup completed!" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ec642c7..cd43f48 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,9 +4,8 @@ on: push: branches: - main - pull_request: - branches: - - main + paths-ignore: + - '.devcontainer/**' workflow_dispatch: # Manual trigger jobs: @@ -17,9 +16,9 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Build Docker image - run: | - docker build -t demo-quarto-image . + # - name: Build Docker image + # run: | + # docker build -t demo-quarto-image . - name: Create gallery directory on the host run: | @@ -29,7 +28,7 @@ jobs: - name: Run Quarto in Docker container run: | - docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace demo-quarto-image bash -c " + docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace mewu/data_access:latest bash -c " source /opt/venv/bin/activate echo 'activated virtualenv.' @@ -52,6 +51,12 @@ jobs: echo \"Processing file: \$file\" # Remove the /workspace prefix from the file path relative_dir=\$(dirname \"\${file#'/workspace/'}\") + + # Install extension to the folder directly + pushd \$relative_dir + /workspace/r/install_quarto_extensions.expect + popd + target_dir=\"/workspace/gallery/\$relative_dir\" echo \"Creating target directory: \$target_dir\" mkdir -p \"\$target_dir\" && echo \"Directory \$target_dir created.\" @@ -76,11 +81,11 @@ jobs: run: | ls -laR gallery echo "