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 "

Gallery Index

" >> gallery/index.html @@ -100,4 +105,4 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./gallery # Path to the folder that you want to publish (the gallery folder) - publish_branch: docs # The branch used for GitHub Pages \ No newline at end of file + publish_branch: docs # The branch used for GitHub Pages diff --git a/.github/workflows/update_docker.yml b/.github/workflows/update_docker.yml new file mode 100644 index 0000000..607788b --- /dev/null +++ b/.github/workflows/update_docker.yml @@ -0,0 +1,33 @@ +name: update docker image + +on: + workflow_dispatch: + inputs: + tags: + description: 'image tags' + required: false + default: mewu/data_access:latest + +jobs: + docker: + runs-on: ubuntu-latest + environment: test + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + tags: ${{ github.event.inputs.tags }} \ No newline at end of file diff --git a/r/install_quarto_extensions.expect b/r/install_quarto_extensions.expect index 89e317b..5d1d8e0 100644 --- a/r/install_quarto_extensions.expect +++ b/r/install_quarto_extensions.expect @@ -1,7 +1,7 @@ #!/usr/bin/expect # Start the quarto command -spawn quarto install extension quarto-ext/shinylive +spawn quarto add quarto-ext/shinylive # Look for the prompt and send "y" expect "*Do you trust the authors of this extension*" {