Skip to content

Instantly share code, notes, and snippets.

@C-Loftus
Last active July 29, 2024 15:30
Show Gist options
  • Select an option

  • Save C-Loftus/036c17a27ac2e0e070838a41eb872e9c to your computer and use it in GitHub Desktop.

Select an option

Save C-Loftus/036c17a27ac2e0e070838a41eb872e9c to your computer and use it in GitHub Desktop.
Add code to spin up pygeoapi in a devcontainer.Run this from the root of the `pygeoapi` directory
mkdir .devcontainer
touch .devcontainer/devcontainer.json
cat <<EOF > .devcontainer/devcontainer.json
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
{
"name": "Existing Docker Compose (Extend)",
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": [
"../docker-compose.yml"
],
// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "pygeoapi",
// 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": "/pygeoapi",
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",
// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",
// Configure tool-specific properties.
"customizations": {
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"editor.formatOnSave": true,
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"wholroyd.jinja",
"redhat.vscode-yaml",
"charliermarsh.ruff"
]
}
},
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}
EOF
cat <<EOF > docker-compose.yml
version: '3'
services:
pygeoapi:
build: .
container_name: pygeoapi
ports:
- "5000:80"
volumes:
- ./pygeoapi:/pygeoapi/pygeoapi # Map the pygeoapi directory into /code/pygeoapi in the container
- ./tests:/pygeoapi/tests # Map the test directory into /code/test in the container
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment