diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 00000000000..480208e7ca3 --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,58 @@ + +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" + } + ] +} +``` + + +The .devcontainer folder should look like this + + +``` +.devcontainer +├── .env +├── .vscode +│ └── launch.json +├── devcontainer.json +├── docker-compose.yml + +``` \ No newline at end of file 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 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8ae2150784a..aa8c0a5f621 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/geonode", // 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..829d67df897 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -1,82 +1,18 @@ -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' + - './.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"