Skip to content

Commit 3a221f5

Browse files
Merge pull request #2 from kevinbackhouse/devcontainer
Add devcontainer config
2 parents e614680 + ddb6492 commit 3a221f5

File tree

4 files changed

+127
-0
lines changed

4 files changed

+127
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Use Ubuntu 24.04 as base image to match the current environment
2+
FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.04
3+
4+
# Install system dependencies
5+
# Note: Python and Git are installed via devcontainer features
6+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
7+
&& apt-get -y install --no-install-recommends \
8+
build-essential \
9+
&& apt-get clean \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
# Install CodeQL CLI
13+
RUN curl -Ls -o /tmp/codeql.zip https://github.com/github/codeql-cli-binaries/releases/latest/download/codeql-linux64.zip \
14+
&& unzip /tmp/codeql.zip -d /opt \
15+
&& mv /opt/codeql /opt/codeql-cli \
16+
&& ln -s /opt/codeql-cli/codeql /usr/local/bin/codeql \
17+
&& rm /tmp/codeql.zip
18+
19+
# Set working directory
20+
WORKDIR /workspaces/seclab-taskflows
21+
22+
# The rest of the setup will be done in post-create script

.devcontainer/devcontainer.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"name": "Seclab Taskflows",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"context": ".."
6+
},
7+
// Features to add to the dev container
8+
"features": {
9+
"ghcr.io/devcontainers/features/python:1": {
10+
"version": "3.11",
11+
"installTools": true
12+
},
13+
"ghcr.io/devcontainers/features/git:1": {
14+
"version": "latest"
15+
},
16+
"ghcr.io/devcontainers/features/github-cli:1": {
17+
"version": "latest"
18+
},
19+
"ghcr.io/devcontainers/features/docker-in-docker:2": {
20+
"version": "latest"
21+
}
22+
},
23+
// Configure tool-specific properties
24+
"customizations": {
25+
"vscode": {
26+
"extensions": [
27+
"ms-python.python",
28+
"ms-python.vscode-pylance",
29+
"ms-python.vscode-python-envs",
30+
"redhat.vscode-yaml",
31+
"GitHub.copilot",
32+
"GitHub.copilot-chat",
33+
"ms-azuretools.vscode-docker"
34+
],
35+
"settings": {
36+
"python.useEnvironmentsExtension": true
37+
}
38+
}
39+
},
40+
// Use 'forwardPorts' to make a list of ports inside the container available locally
41+
"forwardPorts": [],
42+
// Use 'postCreateCommand' to run commands after the container is created
43+
"postCreateCommand": "bash .devcontainer/post-create.sh",
44+
// Use 'postStartCommand' to run commands when the container starts
45+
"postAttachCommand": "bash .devcontainer/post-attach.sh",
46+
// Environment variables
47+
"containerEnv": {
48+
"PYTHONUNBUFFERED": "1"
49+
},
50+
// Set the user to use in the container (non-root)
51+
"remoteUser": "vscode",
52+
// Grant the container access to the host's Docker daemon
53+
"runArgs": [
54+
"--init"
55+
]
56+
}

.devcontainer/post-attach.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# If running in Codespaces, check for necessary secrets and print error if missing
5+
if [ -v CODESPACES ]; then
6+
echo "🔐 Running in Codespaces - injecting secrets from Codespaces settings..."
7+
if [ ! -v COPILOT_TOKEN ]; then
8+
echo "⚠️ Running in Codespaces - please add COPILOT_TOKEN to your Codespaces secrets"
9+
fi
10+
if [ ! -v GITHUB_PERSONAL_ACCESS_TOKEN ]; then
11+
echo "⚠️ Running in Codespaces - please add GITHUB_PERSONAL_ACCESS_TOKEN to your Codespaces secrets"
12+
fi
13+
fi
14+
15+
echo "💡 Remember to activate the virtual environment: source .venv/bin/activate"

.devcontainer/post-create.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "🚀 Setting up Seclab Taskflows development environment..."
5+
6+
# Create Python virtual environment
7+
echo "📦 Creating Python virtual environment..."
8+
python3 -m venv .venv
9+
10+
# Activate virtual environment and install dependencies
11+
echo "📥 Installing Python dependencies..."
12+
source .venv/bin/activate
13+
python -m pip install --upgrade pip
14+
python -m pip install hatch
15+
hatch build
16+
17+
# Install this package from local directory.
18+
pip install -e .
19+
20+
# Create logs directory if it doesn't exist
21+
mkdir -p logs
22+
23+
# Create optional data directories
24+
mkdir -p data
25+
26+
# Create .env file if it doesn't exist
27+
if [ ! -f .env ]; then
28+
echo "📝 Creating .env template..."
29+
echo "# Optional: CodeQL database base path" >> .env
30+
echo "CODEQL_DBS_BASE_PATH=$(realpath data)" >> .env
31+
echo "⚠️ Please configure the environment or your .env file with required tokens!"
32+
fi
33+
34+
echo "✅ Development environment setup complete!"

0 commit comments

Comments
 (0)