Skip to content

Commit

Permalink
Add Dockerfile and .devcontainer to run website locally (#2814)
Browse files Browse the repository at this point in the history
* Add Dockerfile to run website locally and to run as devcontainer
  • Loading branch information
cpholguera committed Jul 14, 2024
1 parent 23b23c0 commit 7fb0069
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 1 deletion.
35 changes: 35 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "MkDocs-VSCode",
"build": {
"context": "..",
"dockerfile": "../Dockerfile"
},
"customizations": {
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"debug.javascript.usePreview": false
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"yzhang.markdown-all-in-one",
"redhat.vscode-yaml",
"shardulm94.trailing-spaces",
"oderwat.indent-rainbow",
"msjsdiag.debugger-for-chrome",
"ms-python.python",
"ms-python.debugpy",
"davidanson.vscode-markdownlint",
"timonwong.shellcheck",
"ms-python.vscode-pylance"
]
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
8000
]
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
//"remoteUser": "vscode"
}
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
dist
build
.git
Dockerfile
.dockerignore
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Use the latest Python image
FROM python:3-slim

# Install dependencies
RUN apt-get update && \
apt-get install -y git jq curl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Install Python dependencies
COPY src/scripts/requirements.txt .
RUN python -m pip install --no-cache-dir -r requirements.txt

# Clone the OWASP MASVS as required by the website build
RUN git clone --depth 1 https://github.com/OWASP/owasp-masvs.git /workspaces/owasp-masvs

# Set the working directory this way to be compatible with devcontainers and also run independently
WORKDIR /workspaces/owasp-mastg

# Expose port 8000
EXPOSE 8000

# Start the container with a shell
CMD ["bash"]

# If running manually: docker run -it --rm -p 8000:8000 -v $(pwd):/workspaces/owasp-mastg mastg
4 changes: 3 additions & 1 deletion run_web.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

# rm -rf docs/MASTG
# rm -rf docs/MASWE
rm -rf docs/MASTG/tests-beta
Expand All @@ -9,4 +11,4 @@ python3 src/scripts/transform_files.py
python3 src/scripts/populate_dynamic_pages.py
python3 src/scripts/generate_cross_references.py
# python3 src/scripts/generate_redirects.py
mkdocs serve -a localhost:8002
mkdocs serve -a 0.0.0.0:8000
2 changes: 2 additions & 0 deletions src/scripts/structure_masvs.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

if [ -d "../owasp-masvs/" ] ; then
MASVS_DIR=../owasp-masvs
elif [ -d "./owasp-masvs/" ] ; then
Expand Down

0 comments on commit 7fb0069

Please sign in to comment.