Skip to content

Commit

Permalink
chore: update the Dev Container 24.01 Edition (#2975)
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaffter authored Jan 28, 2025
1 parent dfc00d2 commit 899e091
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 132 deletions.
102 changes: 46 additions & 56 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Sage Dev Container",
"image": "ghcr.io/sage-bionetworks/sage-devcontainer:fab0893",
"name": "Sage Monorepo Dev Container",
"image": "ghcr.io/sage-bionetworks/sage-monorepo-devcontainer:sha-c7e2cdbc88fb8cc4815dafedd92b105e4b9544f2",
"containerEnv": {
"NX_BASE": "${localEnv:NX_BASE}",
"NX_BRANCH": "${localEnv:NX_BRANCH}",
Expand All @@ -14,58 +14,7 @@
"DOCKER_USERNAME": "${localEnv:DOCKER_USERNAME}",
"DOCKER_PASSWORD": "${localEnv:DOCKER_PASSWORD}"
},
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2.11.0": {
"version": "27.0.3",
"moby": false
}
},
"customizations": {
"codespaces": {
"openFiles": ["README.md"]
},
"vscode": {
"extensions": [
"alefragnani.Bookmarks",
"Angular.ng-template",
"dbaeumer.vscode-eslint",
"donjayamanne.python-environment-manager",
"dorzey.vscode-sqlfluff",
"eamodio.gitlens",
"emeraldwalk.RunOnSave",
"esbenp.prettier-vscode",
"exiasr.hadolint",
"formulahendry.auto-rename-tag",
"github.vscode-github-actions",
"GitHub.vscode-pull-request-github",
"Gruntfuggly.todo-tree",
"humao.rest-client",
"mhutchie.git-graph",
"mongodb.mongodb-vscode",
"ms-playwright.playwright",
"ms-python.black-formatter",
"ms-python.python",
"ms-toolsai.jupyter",
"mtxr.sqltools-driver-mysql",
"mtxr.sqltools-driver-pg",
"mtxr.sqltools",
"njpwerner.autodocstring",
"Orta.vscode-jest",
"pranaygp.vscode-css-peek",
"ritwickdey.LiveServer",
"shengchen.vscode-checkstyle",
"SonarSource.sonarlint-vscode",
"stkb.rewrap",
"stylelint.vscode-stylelint",
"vmware.vscode-boot-dev-pack",
"vscjava.vscode-gradle",
"vscjava.vscode-java-pack"
],
"settings": {
"workbench.startupEditor": "readme"
}
}
},
"features": {},
"forwardPorts": [
2432, 3306, 3333, 4200, 4211, 5000, 5200, 5432, 5601, 8010, 8071, 8000, 8080, 8081, 8082, 8084,
8085, 8086, 8090, 8200, 8888, 8889, 9200, 9411, 27017
Expand Down Expand Up @@ -164,7 +113,48 @@
"onAutoForward": "silent"
}
},
"remoteUser": "vscode",
"otherPortsAttributes": {
"onAutoForward": "silent"
},
"shutdownAction": "stopContainer",
"runArgs": ["--name", "sage_devcontainer"]
"runArgs": ["--name", "sage-monorepo-devcontainer"],
"customizations": {
"vscode": {
"extensions": [
"alefragnani.Bookmarks",
"Angular.ng-template",
"dbaeumer.vscode-eslint",
"donjayamanne.python-environment-manager",
"eamodio.gitlens",
"emeraldwalk.RunOnSave",
"esbenp.prettier-vscode",
"exiasr.hadolint",
"formulahendry.auto-rename-tag",
"github.vscode-github-actions",
"GitHub.vscode-pull-request-github",
"Gruntfuggly.todo-tree",
"humao.rest-client",
"mhutchie.git-graph",
"mongodb.mongodb-vscode",
"ms-playwright.playwright",
"ms-python.black-formatter",
"ms-python.python",
"ms-toolsai.jupyter",
"mtxr.sqltools-driver-mysql",
"mtxr.sqltools-driver-pg",
"mtxr.sqltools",
"njpwerner.autodocstring",
"Orta.vscode-jest",
"pranaygp.vscode-css-peek",
"ritwickdey.LiveServer",
"shengchen.vscode-checkstyle",
"SonarSource.sonarlint-vscode",
"stkb.rewrap",
"stylelint.vscode-stylelint",
"vmware.vscode-boot-dev-pack",
"vscjava.vscode-gradle",
"vscjava.vscode-java-pack"
]
}
}
}
87 changes: 48 additions & 39 deletions .github/actions/setup-dev-container/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: 'Set up the dev container'
description: 'Installs the dev container CLI, fetches caches (if exist), and starts the dev container'
description: 'Installs the dev container CLI, fetches caches (if exist), and starts the dev container.'
inputs:
devcontainer-user:
description: 'The dev container user.'
required: false
default: 'ubuntu'
runs:
using: 'composite'
steps:
Expand All @@ -11,43 +16,45 @@ runs:
# restore-keys: |
# ${{ runner.os }}-pnpm-store-

- name: Set up Renv cache
uses: actions/cache@v3
with:
path: '/tmp/.cache/R/renv/cache'
key: ${{ runner.os }}-renv-cache-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-cache-
# - name: Set up Renv cache
# uses: actions/cache@v3
# with:
# path: '/tmp/.cache/R/renv/cache'
# key: ${{ runner.os }}-renv-cache-${{ hashFiles('**/renv.lock') }}
# restore-keys: |
# ${{ runner.os }}-renv-cache-

- name: Set up Poetry cache
uses: actions/cache@v3
with:
path: '/tmp/.cache/pypoetry'
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
# - name: Set up Poetry cache
# uses: actions/cache@v3
# with:
# path: '/tmp/.cache/pypoetry'
# key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}

- name: Set up venv cache
uses: actions/cache@v3
with:
path: |
/tmp/.local/share/virtualenv
**/.venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}
# - name: Set up venv cache
# uses: actions/cache@v3
# with:
# path: |
# /tmp/.local/share/virtualenv
# **/.venv
# key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}

- name: Set up Gradle cache
uses: actions/cache@v3
with:
path: |
/tmp/.gradle/caches
/tmp/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# - name: Set up Gradle cache
# uses: actions/cache@v3
# with:
# path: |
# /tmp/.gradle/caches
# /tmp/.gradle/wrapper
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
# restore-keys: |
# ${{ runner.os }}-gradle-

- name: Install the Dev Container CLI
shell: bash
run: npm install -g @devcontainers/cli@0.69.0
run: npm install -g @devcontainers/cli@0.72.0

- name: Start the dev container
env:
DEVCONTAINER_USER: ${{ inputs.devcontainer-user }}
shell: bash
run: |
mkdir -p \
Expand All @@ -60,21 +67,23 @@ runs:
devcontainer up \
--mount type=bind,source=/tmp/.pnpm-store,target=/workspaces/sage-monorepo/.pnpm-store \
--mount type=bind,source=/tmp/.cache/R/renv/cache,target=/home/vscode/.cache/R/renv/cache \
--mount type=bind,source=/tmp/.cache/pypoetry,target=/home/vscode/.cache/pypoetry \
--mount type=bind,source=/tmp/.local/share/virtualenv,target=/home/vscode/.local/share/virtualenv \
--mount type=bind,source=/tmp/.gradle/caches,target=/home/vscode/.gradle/caches \
--mount type=bind,source=/tmp/.gradle/wrapper,target=/home/vscode/.gradle/wrapper \
--mount type=bind,source=/tmp/.cache/R/renv/cache,target=/home/${DEVCONTAINER_USER}/.cache/R/renv/cache \
--mount type=bind,source=/tmp/.cache/pypoetry,target=/home/${DEVCONTAINER_USER}/.cache/pypoetry \
--mount type=bind,source=/tmp/.local/share/virtualenv,target=/home/${DEVCONTAINER_USER}/.local/share/virtualenv \
--mount type=bind,source=/tmp/.gradle/caches,target=/home/${DEVCONTAINER_USER}/.gradle/caches \
--mount type=bind,source=/tmp/.gradle/wrapper,target=/home/${DEVCONTAINER_USER}/.gradle/wrapper \
--workspace-folder ../sage-monorepo
- name: Prepare the workspace
env:
DEVCONTAINER_USER: ${{ inputs.devcontainer-user }}
shell: bash
run: |
devcontainer exec --workspace-folder ../sage-monorepo bash -c "
sudo chown -R vscode:vscode \
sudo chown -R ${DEVCONTAINER_USER}:${DEVCONTAINER_USER} \
/workspaces/sage-monorepo \
/home/vscode/.cache \
/home/vscode/.local \
/home/vscode/.gradle \
/home/${DEVCONTAINER_USER}/.cache \
/home/${DEVCONTAINER_USER}/.local \
/home/${DEVCONTAINER_USER}/.gradle \
&& . ./dev-env.sh \
&& workspace-install-affected"
18 changes: 9 additions & 9 deletions apps/iatlas/api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 19 additions & 16 deletions apps/iatlas/api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@ authors = [
]
readme = "README.md"

[tool.poetry.dependencies]
python = "3.8.20"
ariadne = "0.13.0"
click = "7.1.2"
flask = "1.1.2"
flask-sqlalchemy = "2.4.3"
graphql-core = "3.1.0"
itsdangerous = "1.1.0"
jinja2 = "2.11.2"
markupsafe = "1.1.1"
psycopg2-binary = "2.8.5"
sqlalchemy = "1.3.17"
starlette = "0.13.4"
typing-extensions = "3.7.4.2"
werkzeug = "1.0.1"
[[tool.poetry.packages]]
include = "api"

[tool.poetry.dependencies]
python = "3.8.20"
ariadne = "0.13.0"
click = "7.1.2"
flask = "1.1.2"
flask-sqlalchemy = "2.4.3"
graphql-core = "3.1.0"
itsdangerous = "1.1.0"
jinja2 = "2.11.2"
markupsafe = "1.1.1"
psycopg2-binary = "2.8.5"
sqlalchemy = "1.3.17"
starlette = "0.13.4"
typing-extensions = "3.7.4.2"
werkzeug = "1.0.1"

[tool.poetry.group.dev.dependencies]
autopep8 = "1.5.4"
Expand All @@ -36,7 +39,7 @@ pytest-xdist = "2.1.0"
snakeviz = "2.1.0"

[tool.poetry.group.prod.dependencies]
uWSGI = "2.0.19.1"
uWSGI = "2.0.28"

[tool.pytest.ini_options]
log_cli = true
Expand Down
25 changes: 21 additions & 4 deletions dev-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ function workspace-install-affected {
workspace-install-nodejs-dependencies
workspace-install-python-dependencies
nx affected --target=create-config
nx affected --target=prepare --exclude '!tag:language:java' --parallel=1
nx affected --target=prepare --exclude 'tag:language:java'
nx affected --target=prepare --projects=tag:language:java --parallel=1
nx affected --target=prepare --projects=tag:language:python --parallel=1
nx affected --target=prepare --projects=tag:language:r
}

# Setup Python virtualenvs
Expand Down Expand Up @@ -176,6 +177,22 @@ function workspace-initialize-env {
export COREPACK_ENABLE_DOWNLOAD_PROMPT="0"
}

function workspace-nuke-venv {
find . -name ".venv" -print0 | xargs -0 rm -fr
function workspace-nuke {
rm -fr \
.angular \
.cache \
.nx \
.pnpm-store \
coverage \
playwright-report \
reports

# find . -name "build" -print0 | xargs -0 rm -fr # but not OA build folders
find . -name ".coverage" -print0 | xargs -0 rm -fr
find . -name ".gradle" -print0 | xargs -0 rm -fr
find . -name ".pytest_cache" -print0 | xargs -0 rm -fr
find . -name ".venv" -print0 | xargs -0 rm -fr
find . -name "bin" -print0 | xargs -0 rm -fr
find . -name "dist" -print0 | xargs -0 rm -fr
find . -name "node_modules" -print0 | xargs -0 rm -fr
}
9 changes: 3 additions & 6 deletions libs/sandbox/py-lib/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@
}
},
"prepare": {
"executor": "@nxlv/python:install",
"executor": "nx:run-commands",
"options": {
"silent": false,
"args": "",
"cacheDir": ".cache/pypoetry",
"verbose": false,
"debug": false
"command": "./install.sh",
"cwd": "{projectRoot}"
}
},
"update": {
Expand Down
Loading

0 comments on commit 899e091

Please sign in to comment.