From 9d6881a0d733342cc598358a1cdc81259afac08e Mon Sep 17 00:00:00 2001 From: Mattia Date: Mon, 16 Jun 2025 18:04:59 +0200 Subject: [PATCH 1/4] Fixes #13125: Reopen in container for development is not working --- .devcontainer/README.md | 83 +++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 49 ++++++++++-------- .devcontainer/docker-compose.yml | 89 +++++--------------------------- 3 files changed, 123 insertions(+), 98 deletions(-) create mode 100644 .devcontainer/README.md diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 00000000000..2209c7adb03 --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,83 @@ + +How to develop using devcontainers in VSCode +-------------------------------------------- + + + +You can develop using the vscode remote containers extension. In this approach you need to: + +- Install the extension in your vscode: [ms-vscode-remote.remote-containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) + +- On your command pallet, select: “Remote-Containers: Reopen in Container” + +- If it’s the first time, vscode will take care of building the images. This might take some time. + +- Then a new vscode window will open, and it’ll be connected to your docker container. + +- The message “Dev Container: Debug Docker Compose” will appear in the bottom-left corner of that window. + +- In the vscode terminal, you’re going to see something similar to root@77e80acc89b8:/usr/src/geonode#. + +- To run your application, you can use the integrated terminal (./manage.py runserver 0.0.0.0:8000) or the vscode “Run and Debug” option. For launching with “Run and Debug”, generate the following files in the `.vscode` folder inside the `.devcontainer` folder + +launch.json +```json +{ + "version": "0.2.0", + "configurations": [ + + { + "name": "Python Debugger: Django", + "type": "debugpy", + "request": "launch", + "args": [ + "runserver", + "0.0.0.0:8000" + ], + "django": true, + "autoStartBrowser": false, + "justMyCode": false, + "program": "/usr/src/geonode/manage.py" + } + ] +} +``` + +src.code-workspace.json +```json +{ + "version": "0.2.0", + "configurations": [ + + { + "name": "Python Debugger: Django", + "type": "debugpy", + "request": "launch", + "args": [ + "runserver", + "0.0.0.0:8000" + ], + "django": true, + "autoStartBrowser": false, + "justMyCode": false, + "program": "/usr/src/geonode/manage.py" + } + ] +} +``` + +The .devcontainer folder should look like this + + +``` +.devcontainer +├── .env +├── .vscode +│ ├── launch.json +│ └── src.code-workspace.json +├── README.md +├── devcontainer.json +├── docker-compose.yml +├── docker.sh + +``` \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8ae2150784a..dd6975c8401 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,3 +1,4 @@ + // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: // https://github.com/microsoft/vscode-dev-containers/tree/v0.194.0/containers/docker-existing-docker-compose // If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml. @@ -17,29 +18,33 @@ // The optional 'workspaceFolder' property is the path VS Code should open by default when // connected. This is typically a file mount in .devcontainer/docker-compose.yml - "workspaceFolder": "/usr/src/geonode/", + "workspaceFolder": "/usr/src", // Set *default* container specific settings.json values on container create. - "settings": { - "terminal.integrated.profiles.linux": { - "/bin/bash": { - "path": "/bin/bash", - "args": [ - "-l" - ] - } - }, - "terminal.integrated.defaultProfile.linux": "/bin/bash" - }, - - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "ms-python.python", - "batisteo.vscode-django", - "mrorz.language-gettext", - "eamodio.gitlens", // Note: User preference - "bigonesystems.django" // Note: User preference - ], + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.profiles.linux": { + "/bin/bash": { + "path": "/bin/bash", + "args": [ + "-l" + ] + } + }, + "terminal.integrated.defaultProfile.linux": "bash" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-python.python", + "batisteo.vscode-django", + "mrorz.language-gettext", + "eamodio.gitlens", // Note: User preference + "bigonesystems.django" // Note: User preference + ] + } + }, // Use 'forwardPorts' to make a list of ports inside the container available locally. "forwardPorts": [ @@ -60,4 +65,4 @@ // Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root. // "remoteUser": "vscode" -} +} \ No newline at end of file diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 3a303d3b066..6c1425d0d80 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -1,82 +1,19 @@ -version: '3.4' -services: - # Update this to the name of the service you want to work with in your docker-compose.yml file - django: - # If you want add a non-root user to your Dockerfile, you can use the "remoteUser" - # property in devcontainer.json to cause VS Code its sub-processes (terminals, tasks, - # debugging) to execute as the user. Uncomment the next line if you want the entire - # container to run as this user instead. Note that, on Linux, you may need to - # ensure the UID and GID of the container user you create matches your local user. - # See https://aka.ms/vscode-remote/containers/non-root for details. - # - # user: vscode - - # Uncomment if you want to override the service's Dockerfile to one in the .devcontainer - # folder. Note that the path of the Dockerfile and context is relative to the *primary* - # docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile" - # array). The sample below assumes your primary file is in the root of your project. - - # build: - # context: . - # dockerfile: .devcontainer/Dockerfile - - restart: "no" - - healthcheck: - test: "echo \"I'm alive.\"" - - env_file: - - .devcontainer/.env - volumes: - # Update this to wherever you want VS Code to mount the folder of your project - - '.:/usr/src/geonode' - # Uncomment the next line to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker-compose for details. - # - /var/run/docker.sock:/var/run/docker.sock +services: + django: ports: - "8000:8000" - - "5678:5678" - + volumes: + - '.:/usr/src/geonode' + - './geonode-mapstore-client:/usr/src/geonode-mapstore-client' + - './.devcontainer/.vscode:/usr/src/.vscode' + - statics:/mnt/volumes/statics + - geoserver-data-dir:/geoserver_data/data + - backup-restore:/backup_restore + - data:/data + - tmp:/tmp + healthcheck: + test: "echo 'Alive'" entrypoint: ["/usr/src/geonode/entrypoint.sh"] - - # Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust. - # cap_add: - # - SYS_PTRACE - # security_opt: - # - seccomp:unconfined - - # Overrides default command so things don't shut down after the process ends. command: sleep infinity - - celery: - restart: "no" - env_file: - - .devcontainer/.env - - volumes: - - '.:/usr/src/geonode' - - geonode: - restart: "no" - - # Removes letsencrypt when developing - letsencrypt: - deploy: - replicas: 0 - - geoserver: - restart: "no" - ports: - - "8080:8080" - - data-dir-conf: - restart: "no" - - db: - restart: "no" - ports: - - "5432:5432" - - rabbitmq: - restart: "no" From a5c7ea57f6b13e4a9aa83217f053e1d4e9c10465 Mon Sep 17 00:00:00 2001 From: Mattia Date: Wed, 16 Jul 2025 16:23:12 +0200 Subject: [PATCH 2/4] [Fixes #13276] Fix devcontainer --- .devcontainer/README.md | 27 +-------------------------- .devcontainer/docker-compose.yml | 1 - 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/.devcontainer/README.md b/.devcontainer/README.md index 2209c7adb03..480208e7ca3 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -43,28 +43,6 @@ launch.json } ``` -src.code-workspace.json -```json -{ - "version": "0.2.0", - "configurations": [ - - { - "name": "Python Debugger: Django", - "type": "debugpy", - "request": "launch", - "args": [ - "runserver", - "0.0.0.0:8000" - ], - "django": true, - "autoStartBrowser": false, - "justMyCode": false, - "program": "/usr/src/geonode/manage.py" - } - ] -} -``` The .devcontainer folder should look like this @@ -73,11 +51,8 @@ The .devcontainer folder should look like this .devcontainer ├── .env ├── .vscode -│ ├── launch.json -│ └── src.code-workspace.json -├── README.md +│ └── launch.json ├── devcontainer.json ├── docker-compose.yml -├── docker.sh ``` \ No newline at end of file diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 6c1425d0d80..9c1a8630e8e 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -6,7 +6,6 @@ services: - "8000:8000" volumes: - '.:/usr/src/geonode' - - './geonode-mapstore-client:/usr/src/geonode-mapstore-client' - './.devcontainer/.vscode:/usr/src/.vscode' - statics:/mnt/volumes/statics - geoserver-data-dir:/geoserver_data/data From 7c00018d7e1c7e2a8b2c48da1f7c2b1dfade8bfd Mon Sep 17 00:00:00 2001 From: Mattia Date: Thu, 28 Aug 2025 12:31:56 +0200 Subject: [PATCH 3/4] Fix PR comments --- .devcontainer/devcontainer.json | 2 +- .devcontainer/docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index dd6975c8401..aa8c0a5f621 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -18,7 +18,7 @@ // The optional 'workspaceFolder' property is the path VS Code should open by default when // connected. This is typically a file mount in .devcontainer/docker-compose.yml - "workspaceFolder": "/usr/src", + "workspaceFolder": "/usr/src/geonode", // Set *default* container specific settings.json values on container create. "customizations": { diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 6c1425d0d80..621b4255570 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -7,7 +7,7 @@ services: volumes: - '.:/usr/src/geonode' - './geonode-mapstore-client:/usr/src/geonode-mapstore-client' - - './.devcontainer/.vscode:/usr/src/.vscode' + - './.devcontainer/._vscode:/usr/src/.vscode' - statics:/mnt/volumes/statics - geoserver-data-dir:/geoserver_data/data - backup-restore:/backup_restore From 207c184e13b07659b5d614fb248b29fb91ea2d53 Mon Sep 17 00:00:00 2001 From: Mattia Date: Thu, 28 Aug 2025 12:33:16 +0200 Subject: [PATCH 4/4] Fix PR comments --- .devcontainer/_vscode/geonode.code-workspace | 8 ++++++++ .devcontainer/_vscode/launch.json | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 .devcontainer/_vscode/geonode.code-workspace create mode 100644 .devcontainer/_vscode/launch.json diff --git a/.devcontainer/_vscode/geonode.code-workspace b/.devcontainer/_vscode/geonode.code-workspace new file mode 100644 index 00000000000..a85cd0b40e2 --- /dev/null +++ b/.devcontainer/_vscode/geonode.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "/usr/src/geonode" + }, + ], + "settings": {} +} \ No newline at end of file diff --git a/.devcontainer/_vscode/launch.json b/.devcontainer/_vscode/launch.json new file mode 100644 index 00000000000..ab178dccd55 --- /dev/null +++ b/.devcontainer/_vscode/launch.json @@ -0,0 +1,19 @@ +{ + "version": "0.2.0", + "configurations": [ + + { + "name": "Python Debugger: Django", + "type": "debugpy", + "request": "launch", + "args": [ + "runserver", + "0.0.0.0:8000" + ], + "django": true, + "autoStartBrowser": false, + "justMyCode": false, + "program": "/usr/src/geonode/manage.py" + } + ] +} \ No newline at end of file