generated from linz/template-python-hello-world
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build: devcontainer TDE-598 #285
Draft
paulfouquet
wants to merge
3
commits into
master
Choose a base branch
from
build/devcontainer-tde-598
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM osgeo/gdal:ubuntu-small-3.6.1 | ||
|
||
RUN apt update && apt install -y python3-pip python3-distutils git | ||
RUN curl -sSL https://install.python-poetry.org | python3 - | ||
|
||
# Allowing access to osgeo/gdal python library within the venv environment created with Poetry | ||
ENV PYTHONPATH="/lib/python3/dist-packages:/workspaces/topo-imagery:$PYTHONPATH" | ||
|
||
ENV PATH=/root/.local/bin:$PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# topo-imagery devcontainer | ||
|
||
The purpose of this devcontainer is to avoid any trouble to the developers managing a Python environment with GDAL and other dependencies. | ||
|
||
> **_NOTE:_** It has been setup to be used with VSCode under a linux environment. Some functionalities might not work with a different configuration. | ||
|
||
## `Dockerfile` | ||
|
||
This Docker container describes the OS configuration for the development environment. It is intended to be based on the same Docker image than our production container. | ||
|
||
## `devcontainer.json` | ||
|
||
It allows us to use common settings for the development environment. | ||
|
||
### `post_create.sh` | ||
|
||
This script is run after the container is created. | ||
|
||
### `post_start.sh` | ||
|
||
This script is run everytime the container is started. | ||
|
||
## Usage | ||
|
||
Once opened the local cloned repository in VSCode, click on the bottom left corner green button `><` `Open a Remote Window` and select the `Reopen in Container` option. Wait for the container to be build. Open a new terminal from VSCode. It should source the Python `venv`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// 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-dockerfile | ||
{ | ||
"name": "topo-imagery-dev", | ||
"context": "..", | ||
"dockerFile": "Dockerfile", | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"terminal.integrated.profiles.linux": { | ||
"bash": { | ||
"path": "/bin/bash" | ||
} | ||
}, | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true | ||
}, | ||
"python.defaultInterpreterPath": "${containerWorkspaceFolder}/.venv/bin/python3.10", | ||
"python.formatting.blackPath": "${containerWorkspaceFolder}/.venv/bin/black", | ||
"python.linting.mypyPath": "${containerWorkspaceFolder}/.venv/bin/mypy", | ||
"python.linting.pylintPath": "${containerWorkspaceFolder}/.venv/bin/pylint", | ||
"python.formatting.provider": "black", | ||
"python.testing.pytestEnabled": true, | ||
"python.linting.enabled": true, | ||
"python.linting.pylintEnabled": true, | ||
"editor.formatOnSave": true, | ||
"autoDocstring.docstringFormat": "google-notypes" | ||
}, | ||
"extensions": [ | ||
"ms-python.python", | ||
"ms-python.vscode-pylance", | ||
"esbenp.prettier-vscode", | ||
"njpwerner.autodocstring" | ||
] | ||
} | ||
}, | ||
"postCreateCommand": "bash ./.devcontainer/post_create.sh", | ||
"postStartCommand": "bash ./.devcontainer/post_start.sh ${containerWorkspaceFolder}", | ||
"mounts": [ | ||
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.aws,target=/root/.aws,type=bind", | ||
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.bashrc,target=/root/.bashrc,type=bind,consistency=cached" | ||
//"source=${localEnv:HOME}${localEnv:USERPROFILE}/tmp,target=/tmp,type=bind" | ||
], | ||
// https://containers.dev/features | ||
// NOTE: installing Git in that way took more time than within the Dockerfile | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
# Change Poetry settings to better deal with working in a container | ||
poetry config cache-dir $(pwd)/.cache | ||
poetry config virtualenvs.in-project true | ||
|
||
# Install all dependencies with poetry | ||
poetry install --no-interaction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
git config --global --add safe.directory $1 | ||
poetry run pre-commit install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/.cache | ||
/.coverage | ||
/html/ | ||
/htmlcov/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
microsoft/vscode-remote-release#7628
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix in devcontainer pre-release mentioned in microsoft/vscode-remote-release#7628 (comment) did not work for me