-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #609 from pyupio/feat/dev-containers
feature/dev containers and vscode launch config
- Loading branch information
Showing
3 changed files
with
240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Use the official Python 3.12 slim image | ||
FROM python:3.12-slim | ||
|
||
# Create a non-root user and a directory for the application | ||
RUN useradd -m appuser && \ | ||
mkdir /app && \ | ||
chown appuser:appuser /app | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Set environment variables in a single step | ||
ENV LC_ALL=C.UTF-8 \ | ||
LANG=C.UTF-8 \ | ||
PYTHONPATH="/app" | ||
|
||
# Install necessary dependencies, clean up after installation to reduce image size | ||
RUN apt-get update && \ | ||
apt-get -y install docker.io jq git && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy project files into the container (relative to the build context) | ||
COPY . /app/ | ||
|
||
# Expose port 49152 | ||
EXPOSE 49152 | ||
|
||
# Switch to the non-root user for security reasons | ||
USER appuser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "Safety-CLI Dev Container", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"context": "..", | ||
"args": { | ||
"SAFETY_VERSION": "DEV" | ||
} | ||
}, | ||
"extensions": [ | ||
"ms-python.python", | ||
"ms-python.vscode-pylance", | ||
"ms-python.debugpy" | ||
], | ||
"postCreateCommand": "pip install -r test_requirements.txt && pip install ruff requests pre-commit", | ||
"remoteUser": "root", | ||
"workspaceFolder": "/workspaces/safety", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Safety Auth Login", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "safety", | ||
"args": [ | ||
"auth" | ||
], | ||
"console": "integratedTerminal" | ||
}, | ||
{ | ||
"name": "Safety Auth Logout", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "safety", | ||
"args": [ | ||
"auth", | ||
"logout" | ||
], | ||
"console": "integratedTerminal" | ||
}, | ||
{ | ||
"name": "Safety Scan", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "safety", | ||
"args": [ | ||
"scan" | ||
], | ||
"console": "integratedTerminal" | ||
}, | ||
{ | ||
"name": "Safety Scan --detailed-output", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "safety", | ||
"args": [ | ||
"scan", | ||
"--detailed-output" | ||
], | ||
"console": "integratedTerminal" | ||
}, | ||
{ | ||
"name": "Safety Scan --debug", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "safety", | ||
"args": [ | ||
"--debug", | ||
"scan" | ||
], | ||
"console": "integratedTerminal" | ||
}, | ||
{ | ||
"name": "Safety Scan --disable-optional-telemetry", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "safety", | ||
"args": [ | ||
"--disable-optional-telemetry", | ||
"scan" | ||
], | ||
"console": "integratedTerminal" | ||
}, | ||
{ | ||
"name": "Safety Scan --output json", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "safety", | ||
"args": [ | ||
"scan", | ||
"--output", | ||
"json", | ||
"--output-file", | ||
"test.json" | ||
], | ||
"console": "integratedTerminal" | ||
}, | ||
{ | ||
"name": "Safety Check", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "safety", | ||
"args": [ | ||
"check" | ||
], | ||
"console": "integratedTerminal" | ||
}, | ||
{ | ||
"name": "Safety Check --debug", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "safety", | ||
"args": [ | ||
"check", | ||
"--debug" | ||
], | ||
"console": "integratedTerminal" | ||
}, | ||
{ | ||
"name": "Run All Tests", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "pytest", | ||
"args": [], | ||
"console": "integratedTerminal" | ||
}, | ||
{ | ||
"name": "Run test_render.py", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "pytest", | ||
"args": [ | ||
"./tests/scan/test_render.py" | ||
], | ||
"console": "integratedTerminal" | ||
}, | ||
{ | ||
"name": "Run test_cli.py", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "pytest", | ||
"args": [ | ||
"tests/test_cli.py" | ||
], | ||
"console": "integratedTerminal" | ||
}, | ||
{ | ||
"name": "Run test_db.py", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "pytest", | ||
"args": [ | ||
"tests/test_db.py" | ||
], | ||
"console": "integratedTerminal" | ||
}, | ||
{ | ||
"name": "Run test_output_utils.py", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "pytest", | ||
"args": [ | ||
"tests/test_output_utils.py" | ||
], | ||
"console": "integratedTerminal" | ||
}, | ||
{ | ||
"name": "Run test_policy_file.py", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "pytest", | ||
"args": [ | ||
"tests/test_policy_file.py" | ||
], | ||
"console": "integratedTerminal" | ||
}, | ||
{ | ||
"name": "Run test_util.py", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "pytest", | ||
"args": [ | ||
"tests/test_util.py" | ||
], | ||
"console": "integratedTerminal" | ||
}, | ||
{ | ||
"name": "Run test_safety.py", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "pytest", | ||
"args": [ | ||
"tests/test_safety.py" | ||
], | ||
"console": "integratedTerminal" | ||
}, | ||
{ | ||
"name": "Run test_models.py", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "pytest", | ||
"args": [ | ||
"tests/test_models.py" | ||
], | ||
"console": "integratedTerminal" | ||
} | ||
] | ||
} |