Skip to content

Commit 3a3a179

Browse files
author
raman-1222
authored
Merge pull request #22 from Digital-Defiance/setup-devcontainers
chore: set up dev containers
2 parents 4889190 + 74f721d commit 3a3a179

File tree

8 files changed

+140
-47
lines changed

8 files changed

+140
-47
lines changed

.devcontainer/Dockerfile

Lines changed: 0 additions & 9 deletions
This file was deleted.

.devcontainer/devcontainer.json

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,18 @@
1-
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2-
// README at: https://github.com/devcontainers/templates/tree/main/src/python
31
{
4-
"name": "Development environment",
5-
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6-
7-
"build": {
8-
"dockerfile": "Dockerfile"
9-
},
10-
11-
12-
// Features to add to the dev container. More info: https://containers.dev/features.
13-
"features": {
14-
"ghcr.io/devcontainers/features/github-cli:1": {},
15-
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
16-
},
17-
18-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
19-
// "forwardPorts": [],
20-
21-
// Use 'postCreateCommand' to run commands after the container is created.
22-
// "postCreateCommand": "gh auth login && ",
23-
24-
// Configure tool-specific properties.
25-
"customizations": {
26-
"vscode": {
27-
"extensions": ["Optuna.optuna-dashboard"]
28-
}
29-
},
30-
31-
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
32-
// "remoteUser": "root"
33-
34-
35-
"containerEnv": {
36-
37-
// this is for the segmentation_models package
38-
"SM_FRAMEWORK": "tf.keras"
39-
}
2+
"image": "ghcr.io/digital-defiance/ai-health-project-devcontainer:latest",
3+
"mounts": [
4+
{
5+
"source": "/etc/localtime",
6+
"target": "/etc/localtime",
7+
"type": "bind"
8+
},
9+
{
10+
"source": "${localWorkspaceFolder}/.devcontainer/resolv.conf",
11+
"target": "/etc/resolv.conf",
12+
"type": "bind"
13+
}
14+
],
15+
"hostRequirements": {
16+
"gpu": "optional"
17+
}
4018
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"build": {
3+
"dockerfile": "Dockerfile"
4+
},
5+
"postCreateCommand": "./pre-build/postCreateCommand.sh",
6+
"features": {
7+
"ghcr.io/devcontainers/features/nvidia-cuda:1": { "installToolkit": true },
8+
"ghcr.io/duduribeiro/devcontainer-features/neovim:1": { "version": "nightly" },
9+
"ghcr.io/itsmechlark/features/1password:1": {},
10+
"ghcr.io/devcontainers/features/github-cli:1": {},
11+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
12+
"ghcr.io/devcontainers/features/node:1": { "version": "20.16"},
13+
"ghcr.io/jungaretti/features/make:1": {},
14+
"ghcr.io/devcontainers/features/python:1": { "version": "3.12"}
15+
},
16+
"postCreateCommand": "pip install tensorflow fastapi==0.70.0 uvicorn==0.15.0 optuna==3.6.1 pydantic==1.10.2",
17+
"containerEnv": {
18+
19+
// this is for the segmentation_models package
20+
"SM_FRAMEWORK": "tf.keras"
21+
}
22+
}

.devcontainer/pre-build/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM ubuntu:22.04
2+
3+
LABEL com.nvidia.volumes.needed="nvidia_driver"
4+
5+
ENV NVIDIA_VISIBLE_DEVICES all
6+
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
7+
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64
8+
ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:$PATH
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
git config --global --add safe.directory /workspaces/ai-health-project
2+
nvm install 20
3+
nvm use 20
4+
5+
git config push.autoSetupRemote true
6+
git config --global --add safe.directory /workspaces/cloud-infrastructure
7+
git clone https://github.com/RuiFilipeCampos/nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim
8+
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
9+
$HOME/.fzf/install --key-bindings --completion --update-rc
10+
echo "alias nf='nvim \$(fzf)'" >> $HOME/.bashrc
11+
nvim --headless "+Lazy! sync" +qa
12+
13+
14+
echo "export GH_TOKEN='op://digital-defiance-personal/github/GH_TOKEN'" >> $HOME/.bashrc
15+
echo "eval \$(op signin )" >> $HOME/.bashrc
16+
echo "op run -- gh auth setup-git" >> $HOME/.bashrc
17+
echo "echo 'Running git setup'" >> $HOME/.bashrc
18+
19+
echo "git config --global user.email \$(op read op://digital-defiance-personal/github/GH_EMAIL)" >> $HOME/.bashrc
20+
echo "git config --global user.name \$(op read op://digital-defiance-personal/github/GH_NAME)" >> $HOME/.bashrc

.devcontainer/resolv.conf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Generated by Docker Engine.
2+
# This file can be edited; Docker Engine will not make further changes once it
3+
# has been modified.
4+
5+
nameserver 8.8.8.8
6+
search Home
7+
8+
# Based on host file: '/run/systemd/resolve/resolv.conf' (legacy)
9+
# Overrides: []
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Dev Container Build and Push Image
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- '.github/.devcontainer/pre-build/.devcontainer.json'
8+
- '.github/.devcontainer/pre-build/Dockerfile'
9+
- '.github/workflows/pre-build-dev-container.yml'
10+
branches:
11+
- "main"
12+
tags:
13+
- "v*.*.*"
14+
15+
16+
permissions:
17+
packages: write
18+
19+
jobs:
20+
build-and-push:
21+
runs-on: ubuntu-latest
22+
steps:
23+
-
24+
name: Checkout
25+
id: checkout
26+
uses: actions/checkout@v1
27+
-
28+
name: Login to GitHub Container Registry
29+
uses: docker/login-action@v2
30+
with:
31+
registry: ghcr.io
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- id: lower-repo
36+
run: |
37+
echo "GITHUB_REPOSITORY_LOWER=${GITHUB_REPOSITORY@L}" >> $GITHUB_ENV
38+
39+
-
40+
name: Pre-build dev container image
41+
uses: devcontainers/[email protected]
42+
with:
43+
subFolder: .devcontainer/pre-build
44+
imageName: ghcr.io/${{ env.GITHUB_REPOSITORY_LOWER }}-devcontainer
45+
cacheFrom: ghcr.io/${{ env.GITHUB_REPOSITORY_LOWER }}-devcontainer
46+
push: always

makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.ONESHELL:
2+
SHELL := /bin/bash
3+
4+
stop:
5+
CONTAINER_ID=$$( @devcontainer --workspace-folder . up | tail -n 1 | jq -r '.containerId[0:-1]')
6+
@docker stop $$CONTAINER_ID
7+
8+
update:
9+
@devcontainer --workspace-folder . up --remove-existing-container
10+
11+
build:
12+
@devcontainer --workspace-folder . build
13+
14+
up:
15+
WORKSPACE_NAME=$$(basename "$$(pwd)")
16+
WORKSPACE_FOLDER=/workspaces/$$WORKSPACE_NAME
17+
CONTAINER_ID=$$(devcontainer --workspace-folder . up | tail -n 1 | jq -r '.containerId[0:-1]')
18+
@docker exec -itw $$WORKSPACE_FOLDER $$CONTAINER_ID bash
19+

0 commit comments

Comments
 (0)