Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SafetyQuincyF committed Oct 17, 2024
1 parent 3044f08 commit 2b6dada
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 38 deletions.
36 changes: 24 additions & 12 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
# Use the official Python 3.12 slim image
FROM python:3.12-slim

# Create directory for the application
RUN mkdir /app

# Install necessary dependencies
RUN apt-get update && apt-get -y install docker.io jq git && apt-get clean && rm -rf /var/lib/apt/lists/*

# Copy your project files into the container (relative to the build context)
COPY .. /app/
# 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
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
ENV PYTHONPATH="/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
4 changes: 0 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
"SAFETY_VERSION": "DEV"
}
},
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
Expand All @@ -18,5 +15,4 @@
"postCreateCommand": "pip install -r test_requirements.txt && pip install ruff requests pre-commit",
"remoteUser": "root",
"workspaceFolder": "/workspaces/safety",
"forwardPorts": [49152]
}
59 changes: 37 additions & 22 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,88 +5,105 @@
"name": "Safety Auth Login",
"type": "debugpy",
"request": "launch",
"python": "/usr/local/bin/python",
"module": "safety",
"args": ["auth"],
"args": [
"auth"
],
"console": "integratedTerminal"
},
{
"name": "Safety Auth Logout",
"type": "debugpy",
"request": "launch",
"python": "/usr/local/bin/python",
"module": "safety",
"args": ["auth", "logout"],
"args": [
"auth",
"logout"
],
"console": "integratedTerminal"
},
{
"name": "Safety Scan",
"type": "debugpy",
"request": "launch",
"python": "/usr/local/bin/python",
"module": "safety",
"args": ["scan"],
"args": [
"scan"
],
"console": "integratedTerminal"
},
{
"name": "Safety Scan --detailed-output",
"type": "debugpy",
"request": "launch",
"python": "/usr/local/bin/python",
"module": "safety",
"args": ["scan", "--detailed-output"],
"args": [
"scan",
"--detailed-output"
],
"console": "integratedTerminal"
},
{
"name": "Safety Scan --debug",
"type": "debugpy",
"request": "launch",
"python": "/usr/local/bin/python",
"module": "safety",
"args": ["--debug","scan"],
"args": [
"--debug",
"scan"
],
"console": "integratedTerminal"
},
{
"name": "Safety Scan --disable-optional-telemetry",
"type": "debugpy",
"request": "launch",
"python": "/usr/local/bin/python",
"module": "safety",
"args": ["--disable-optional-telemetry","scan"],
"args": [
"--disable-optional-telemetry",
"scan"
],
"console": "integratedTerminal"
},
{
"name": "Safety Scan --output json",
"type": "debugpy",
"request": "launch",
"python": "/usr/local/bin/python",
"module": "safety",
"args": ["scan", "--output", "json", "--output-file", "test.json"],
"args": [
"scan",
"--output",
"json",
"--output-file",
"test.json"
],
"console": "integratedTerminal"
},
{
"name": "Safety Check",
"type": "debugpy",
"request": "launch",
"python": "/usr/local/bin/python",
"module": "safety",
"args": ["check"],
"args": [
"check"
],
"console": "integratedTerminal"
},
{
"name": "Safety Check --debug",
"type": "debugpy",
"request": "launch",
"python": "/usr/local/bin/python",
"module": "safety",
"args": ["check", "--debug"],
"args": [
"check",
"--debug"
],
"console": "integratedTerminal"
},
{
"name": "Run All Tests",
"type": "debugpy",
"request": "launch",
"python": "/usr/local/bin/python",
"module": "pytest",
"args": [],
"console": "integratedTerminal"
Expand All @@ -95,7 +112,6 @@
"name": "Run test_render.py",
"type": "debugpy",
"request": "launch",
"python": "/usr/local/bin/python",
"module": "pytest",
"args": [
"./tests/scan/test_render.py"
Expand All @@ -106,7 +122,6 @@
"name": "Run test_cli.py",
"type": "debugpy",
"request": "launch",
"python": "/usr/local/bin/python",
"module": "pytest",
"args": [
"tests/test_cli.py"
Expand Down Expand Up @@ -174,4 +189,4 @@
"console": "integratedTerminal"
}
]
}
}

0 comments on commit 2b6dada

Please sign in to comment.