Skip to content
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

adding dev container config #1139

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 9 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// For format details, see https://aka.ms/devcontainer.json.
{
"name": "pypsa earth dev",
"image": "ghcr.io/drifter089/pypsa-earth:latest",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces,type=bind,consistency=cached",
"initializeCommand": "docker pull ghcr.io/drifter089/pypsa-earth:latest",
"workspaceFolder": "/workspaces",
"postAttachCommand": "bash .devcontainer/setup.sh"
}
6 changes: 6 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

# mv ../pypsa-eur/* ./
# echo 'solved tutorial files are copied to workspace'

cat .devcontainer/welcome-message.txt
13 changes: 13 additions & 0 deletions .devcontainer/welcome-message.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


👋 Welcome to pypsa-eur contribution in a dev container!
Works in VS Code, or in docker using the devcontainer cli

See https://github.com/drifter089/pypsa-eur/blob/master/README.md for guidance on debugging and contributing to pypsa-eur


For details about dev containers see https://containers.dev

The configuration for the dev container is in the .github/.devcontainer folder.

🔍 To explore VS Code to its fullest, search using the Command Palette (Cmd/Ctrl + Shift + P or F1).+
33 changes: 33 additions & 0 deletions .github/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "pypsa earth dev",
"build": {
"dockerfile": "../../Dockerfile"
},

"features": {
"ghcr.io/devcontainers-contrib/features/bash-command:1": {},
"ghcr.io/eliises/devcontainer-features/bash-profile:1": {}
},
"customizations": {
"vscode": {
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash"
}
},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-azuretools.vscode-docker",
"ms-toolsai.jupyter",
"zainchen.json",
"tomoki1207.pdf",
"grapecity.gc-excelviewer"
]
}
},

"postCreateCommand": "python -m pip install --upgrade debugpy"
}
36 changes: 36 additions & 0 deletions .github/workflows/devcontainer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Dev Container Build and Push Image

on:
workflow_dispatch:
push:
branches:
- "main"
tags:
- "v*.*.*"
pull_request:
branches: [main]


jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
-
name: Checkout
id: checkout
uses: actions/checkout@v1
-
name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}
-
name: Pre-build dev container image
uses: devcontainers/ci@v0.2
with:
subFolder: .github
imageName: ghcr.io/${{ github.repository }}
cacheFrom: ghcr.io/${{ github.repository }}
push: always
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM condaforge/mambaforge

RUN conda update -n base conda
RUN conda install -n base conda-libmamba-solver
RUN conda config --set solver libmamba

WORKDIR /pypsa-earth

COPY ./envs ./envs

RUN conda env create --file envs/environment.yaml

RUN rm -r envs

RUN echo "source activate pypsa-earth" > ~/.bashrc
ENV PATH /opt/conda/envs/pypsa-earth/bin:$PATH

ENTRYPOINT ["tail", "-f", "/dev/null"]
26 changes: 26 additions & 0 deletions Dockerfile.solved
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM condaforge/mambaforge

RUN conda update -n base conda
RUN conda install -n base conda-libmamba-solver
RUN conda config --set solver libmamba

RUN apt-get update && apt-get install -y git

WORKDIR /pypsa-earth

COPY . .

RUN conda env create --file envs/environment.yaml

RUN echo "source activate pypsa-earth" > ~/.bashrc
ENV PATH /opt/conda/envs/pypsa-earth/bin:$PATH

RUN /bin/bash -c "source activate pypsa-earth && snakemake -j 1 solve_all_networks"

RUN git ls-files -z | xargs -0 rm

RUN find . -type d -empty -delete

RUN rm -rf scripts config data .snakemake .git

ENTRYPOINT ["tail", "-f", "/dev/null"]
1 change: 1 addition & 0 deletions config.tutorial.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ tutorial: true
countries: ["NG", "BJ"]

enable:
retrieve_databundle: true
build_natura_raster: true
progress_bar: false

Expand Down
Loading