Skip to content

Commit 85002a4

Browse files
authored
dev: use python server to serve site (#136)
Signed-off-by: Nikita Pivkin <nikita.pivkin@smartforce.io>
1 parent 97e9a6a commit 85002a4

File tree

4 files changed

+14
-45
lines changed

4 files changed

+14
-45
lines changed

GETTING_STARTED.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,15 @@ This cleans, build docGen, makes sure all the files are available in `avd-repo`,
156156
157157
### Running Locally
158158
159-
the [README.md](README.md) has a section on using `nginx` to host locally, I didn't find that much fun to use - good luck if you choose to.
160-
161-
I find the easiest and most reliable (assuming you have `python3` installed) way is
159+
The easiest and most reliable way to serve the site locally (assuming you have python3 installed) is to use the Makefile target:
162160
163161
```bash
164-
cd avd-repo/docs
165-
python3 -m http.server
162+
make serve
166163
```
167164
168-
This will make the whole site available locally at `http://localhost:8000`
165+
This will start a local HTTP server and make the entire site available at http://localhost:9011.
166+
167+
Simply open that URL in your browser to browse the site locally. Press Ctrl+C in the terminal to stop the server.
169168
170169
You are unlikely to need to be using search locally, but if you are, the next section should work out for you!!
171170

Makefile

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
PY_PORT ?= 9011
2+
13
md-update-deps:
24
cd docGen && go get github.com/aquasecurity/defsec \
35
&& go mod tidy
@@ -49,23 +51,14 @@ remove-all-repos:
4951
rm -rf avd-repo/cloudsploit-repo
5052

5153
sync-all:
52-
rsync -av ./ avd-repo/ --exclude=.idea --exclude=go.mod --exclude=go.sum --exclude=nginx.conf --exclude=main.go --exclude=main_test.go --exclude=README.md --exclude=avd-repo --exclude=.git --exclude=.gitignore --exclude=.github --exclude=content --exclude=docs --exclude=Makefile --exclude=goldens
54+
rsync -av ./ avd-repo/ --exclude=.idea --exclude=go.mod --exclude=go.sum --exclude=main.go --exclude=main_test.go --exclude=README.md --exclude=avd-repo --exclude=.git --exclude=.gitignore --exclude=.github --exclude=content --exclude=docs --exclude=Makefile --exclude=goldens
5355

5456
md-generate:
5557
cd avd-repo && ./generator
5658

57-
nginx-start:
58-
-cd avd-repo/docs && nginx -p . -c ../../nginx.conf
59-
60-
nginx-stop:
61-
@if pgrep nginx > /dev/null; then \
62-
cd avd-repo/docs && nginx -s stop -p . -c ../../nginx.conf; \
63-
else \
64-
echo "Nginx is not running."; \
65-
fi
66-
67-
nginx-restart:
68-
make nginx-stop nginx-start
59+
serve:
60+
@echo "Serving static site at http://localhost:${PY_PORT}"
61+
@cd avd-repo/docs && python3 -m http.server ${PY_PORT}
6962

7063
hugo-devel:
7164
hugo server -D --debug
@@ -77,18 +70,13 @@ hugo-generate: hugo-clean
7770
cd avd-repo && ./ci/nvd_pages_build.sh
7871
echo "avd.aquasec.com" > avd-repo/docs/CNAME
7972

80-
simple-host:
81-
cd avd-repo/docs && python3 -m http.server
82-
8373
copy-assets:
8474
cp -R avd-repo/remediations-repo/resources avd-repo/docs/resources
8575
touch avd-repo/docs/.nojekyll
8676

87-
build-all-no-clone: md-clean md-build sync-all md-generate hugo-generate copy-assets nginx-restart
88-
echo "Build Done, navigate to http://localhost:9011/ to browse"
77+
build-all-no-clone: md-clean md-build sync-all md-generate hugo-generate copy-assets serve
8978

90-
build-all: md-clean md-build md-clone-all sync-all md-generate hugo-generate copy-assets nginx-restart
91-
echo "Build Done, navigate to http://localhost:9011/ to browse"
79+
build-all: md-clean md-build md-clone-all sync-all md-generate hugo-generate copy-assets serve
9280

9381
compile-theme-sass:
9482
cd themes/aquablank/static/sass && sass avdblank.scss:../css/avdblank.css && sass avdblank.scss:../css/avdblank.min.css --style compressed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Note: Set `baseURL="/"` [here](https://github.com/aquasecurity/avd-generator/blo
1414
`make hugo-devel` and then navigate to `http://localhost:1313` to view the site.
1515

1616
#### tl;dr for the full build with real content
17-
`make md-clean md-build sync-all md-generate hugo-generate nginx-restart`
17+
`make md-clean md-build sync-all md-generate hugo-generate serve`
1818
then navigate to `http://localhost:9011` to view the pages.
1919

2020
If changes are made to the existing AVD page structure (removal of existing fields), the following must be done:

nginx.conf

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

0 commit comments

Comments
 (0)