Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd propose to have a default .vscode/launch.json available. You would have to re-create it after every rebuild. In addition one can just hit "shortcut of choice" to start up instantly. And finally, you could remove the instruction from the documentation as well :).


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

```
8 changes: 8 additions & 0 deletions .devcontainer/_vscode/geonode.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"folders": [
{
"path": "/usr/src/geonode"
},
],
"settings": {}
}
19 changes: 19 additions & 0 deletions .devcontainer/_vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
49 changes: 27 additions & 22 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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": [
Expand All @@ -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"
}
}
88 changes: 12 additions & 76 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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"
Loading