Skip to content

Commit

Permalink
ci: migrate config to devcontainer (#242)
Browse files Browse the repository at this point in the history
* ci: Renamed `.config` to `.devcontainer`

* ci: Added first approach of `devcontainer.json`

* ci: Replaced previous references to `.config`

* ci: Modified dockerfile and devcontainer
  • Loading branch information
Carsopre authored Dec 18, 2024
1 parent f68c381 commit cb597fd
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 13 deletions.
8 changes: 4 additions & 4 deletions .config/Dockerfile → .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# To build this docker run:
# `docker build -t koswat_dev`
# To build this docker run (from the top checkout dir):
# `docker build -t koswat_dev .devcontainer`
# To run the docker for pytest:
# `docker run -v {your_koswat_checkout_dir}:/usr/src/app/ -v {koswat_env_dir}:/usr/src/.env -t koswat_dev`
# `poetry install`
Expand All @@ -19,11 +19,11 @@ ARG CONDA_ENV="${SRC_ROOT}/.env"
# This location needs to be mounted with your koswat checout:
# -v {your_koswat_checkout_dir}:/usr/src/app
WORKDIR $SRC_ROOT/app
COPY environment.yml $SRC_ROOT/.config/environment.yml
COPY environment.yml $SRC_ROOT/.devcontainer/environment.yml

RUN conda init bash \
&& . ~/.bashrc \
&& conda env create -f $SRC_ROOT/.config/environment.yml -p $CONDA_ENV
&& conda env create -f $SRC_ROOT/.devcontainer/environment.yml -p $CONDA_ENV

# Activate conda environment
ENV PATH $CONDA_ENV/bin:$PATH
Expand Down
6 changes: 3 additions & 3 deletions .config/README.md → .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# What is .config for?
# What is .devcontainer for?
The purpose of this directory is to contain both the conda environment file (`environment.yml`) as well as a docker image that already has such environment installed and defined as entry point.

## Installing the conda environment.

To use the environment file simply run in your command line, this assumes you have [anaconda (miniforge)](https://conda-forge.org/miniforge/) installed and the binaries added to your `PATH` environment variables:

```cmd
conda env create -f .config/environment.yml -p .koswat_env
conda env create -f .devcontainer/environment.yml -p .koswat_env
```
> `-f` (--FILE) is the argument to define which file will be used to install the environment.
Expand All @@ -18,7 +18,7 @@ You can install the docker image in two ways:
1. Building and running the image yourself.

```cmd
docker build -t koswat_dev .config
docker build -t koswat_dev .devcontainer
```
2. Pulling the pre-built image from `containers.deltares.nl/gfs-dev/koswat_dev:latest`.
Expand Down
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"build": {
"dockerfile": "Dockerfile"
},
"mounts": [
"source=${localWorkspaceFolder},target=/usr/src/app,type=bind,consistency=cached"
],
"workspaceFolder": "/usr/src/app",
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.debugpy",
"ms-python.black-formatter",
"ms-python.isort",
"ms-python.pylint",
"ms-vscode.test-adapter-converter",
"njpwerner.autodocstring"
]
}
},

"forwardPorts": [3000]
}
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/code_cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
miniforge-variant: Mambaforge
# channels: conda-forge, nodefaults
# channel-priority: strict
environment-file: .config/environment.yml
environment-file: .devcontainer/environment.yml
activate-environment: koswat_env

- name: Install Dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
miniforge-variant: Mambaforge
# channels: conda-forge, nodefaults
# channel-priority: strict
environment-file: .config/environment.yml
environment-file: .devcontainer/environment.yml
activate-environment: koswat_env

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pip install git+https://github.com/Deltares/[email protected]
1. With [Anaconda (miniforge)](https://conda-forge.org/miniforge/) (our recommendation):
```bash
cd C:\repos\koswat
conda env create -f .config\environment.yml
conda env create -f .devcontainer\environment.yml
conda activate koswat_env
poetry install
```
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ docker run -it koswat bash
1. With [Miniforge](https://conda-forge.org/miniforge/) (our recommendation):
```bash
cd C:\repos\koswat
conda env create -f .config\environment.yml
conda env create -f .devcontainer\environment.yml
conda activate koswat_env
poetry install
```
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ exclude = '''
| \.github # root of the project
| \.env
| \.venv
| \.config
| \.devcontainer
| .pytest_cache
| .scannerwork
| .vscode
Expand All @@ -75,7 +75,7 @@ exclude = '''
profile = "black"
multi_line_output = 3
line_length = 88
skip = [".git", ".github", ".env", ".venv", ".config", ".pytest_cache", ".scannerwork", ".vscode", "site"]
skip = [".git", ".github", ".env", ".venv", ".devcontainer", ".pytest_cache", ".scannerwork", ".vscode", "site"]

[tool.commitizen]
name = "cz_conventional_commits"
Expand Down

0 comments on commit cb597fd

Please sign in to comment.