Skip to content

Commit c5220bc

Browse files
committed
Updated documentation and Python example
1 parent 19f703d commit c5220bc

24 files changed

Lines changed: 531 additions & 278 deletions

.devcontainer/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ RUN set -xe \
1313

1414
# install Python tools
1515
RUN set -xe \
16-
&& apt install -y python3 python3-pip
16+
&& su - vscode -c "curl -LsSf https://astral.sh/uv/install.sh | sh" \
17+
&& su - vscode -c "uv python install 3.12"
1718

1819
# install Go tools
1920
RUN set -xe \

.devcontainer/devcontainer.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
66
//"image": "mcr.microsoft.com/devcontainers/go:1-1.22-bookworm",
77
//"build": {
8-
//"dockerfile": "./Dockerfile"
9-
8+
//"dockerfile": "./Dockerfile"
109
//},
1110
"dockerComposeFile": "./docker-compose.yaml",
1211
"service": "devcontainer",
1312
"workspaceFolder": "/workspaces/s1-integration-examples",
14-
1513
// Features to add to the dev container. More info: https://containers.dev/features.
1614
"features": {
1715
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
@@ -21,13 +19,10 @@
2119
"dockerDashComposeVersion": "v2"
2220
}
2321
},
24-
2522
// Use 'forwardPorts' to make a list of ports inside the container available locally.
2623
// "forwardPorts": [],
27-
2824
// Use 'postCreateCommand' to run commands after the container is created.
2925
"postCreateCommand": "bash .devcontainer/post-create.sh",
30-
3126
// Configure tool-specific properties.
3227
"customizations": {
3328
"vscode": {
@@ -43,15 +38,14 @@
4338
"uctakeoff.vscode-counter",
4439
"ms-azuretools.vscode-docker",
4540
"42Crunch.vscode-openapi",
46-
"Postman.postman-for-vscode"
41+
"Postman.postman-for-vscode",
42+
"ms-python.python"
4743
]
4844
}
4945
}
50-
5146
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
5247
// "remoteUser": "root"
53-
5448
//"runArgs": [
55-
//"--network=host"
49+
//"--network=host"
5650
//]
5751
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# general files to ignore
22
.codegpt
33
.DS_Store
4+
.venv
45
dist

nexus-sdk/go/Makefile

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,14 @@ s1scanner: init
4848
doc-server:
4949
pkgsite -http :${DOCSERVER_PORT}
5050

51-
run:
52-
@LD_LIBRARY_PATH="${THIS_DIR}/dist" "${THIS_DIR}/dist/s1scanner" ${RUN_ARGS}
51+
clean:
52+
rm -rf "${THIS_DIR}/dist"
5353

54-
amd64-container: init
54+
container: init
5555
docker buildx build \
56+
--load \
5657
--tag go/s1scanner:latest \
57-
--platform linux/amd64 \
58-
-f "${THIS_DIR}/build/Dockerfile.amd64" \
59-
${THIS_DIR}/..
60-
61-
arm64-container: init
62-
docker buildx build \
63-
--tag go/s1scanner:latest \
64-
--platform linux/arm64 \
65-
-f "${THIS_DIR}/build/Dockerfile.arm64" \
58+
-f "${THIS_DIR}/build/Dockerfile" \
6659
${THIS_DIR}/..
6760

6861
nosdk-container: init

nexus-sdk/go/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ The "SDK-less" container does **not** contain the Nexus SDK library within it, s
2828

2929
You will need to mount the appropriate version of the shared library into your container depending on the architecture of your machine. If you are running on an Intel/AMD-based system, then you'll need to mount the `SDK/lib/linux/x64/libdfi.so` library from the Nexus SDK distribution package. ARM-based systems such as MacOS systems running on Apple Silicon must mount the `SDK/lib/linux/arm64/libdfi.so` library from the Nexus SDK distribution package.
3030

31-
_**NOTE:** Even though the commands below refer to Linux, it is safe to run them on MacOS and Windows as the container itself is running Linux, so we use the Linux version of the shared library._
32-
3331
Making sure your current working directory is the **_root folder of the repository_**, create an alias for the Docker command to simplify typing:
3432

3533
**Intel/AMD-based systems**
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
1-
FROM --platform=arm64 golang:1.24-bookworm AS build_stage
1+
FROM --platform=${BUILDPLATFORM} golang:1.24-bookworm AS build_stage
22

33
WORKDIR /go/src
44

55
COPY ./go .
66
COPY ./_distfiles_/SDK/include/libdfi.h /go/src/pkg/scanner/nexus/include/libdfi.h
77
COPY ./_distfiles_/SDK/lib/linux/arm64/libdfi.so /go/src/pkg/scanner/nexus/lib/arm64/libdfi.so
8+
COPY ./_distfiles_/SDK/lib/linux/x64/libdfi.so /go/src/pkg/scanner/nexus/lib/amd64/libdfi.so
89

910
RUN set -e && \
1011
go mod tidy && \
1112
go build -o s1scanner ./cmd/s1scanner
1213

13-
FROM --platform=arm64 busybox:glibc
14+
FROM --platform=${BUILDPLATFORM} busybox:glibc
15+
16+
ARG TARGETARCH
17+
ARG TARGETOS
1418

1519
WORKDIR /
1620

1721
COPY --from=build_stage /go/src/s1scanner /bin/s1scanner
18-
COPY ./_distfiles_/SDK/lib/linux/arm64/libdfi.so /lib/libnexus.unstripped.so
22+
COPY ./_distfiles_/SDK/lib/linux/arm64/libdfi.so /lib/libnexus-arm64.unstripped.so
23+
COPY ./_distfiles_/SDK/lib/linux/x64/libdfi.so /lib/libnexus-amd64.unstripped.so
1924
COPY ./sample-files /opt/s1scanner/sample-files/
2025

2126
RUN set -e && \
27+
ln -sf libnexus-${TARGETARCH}.unstripped.so /lib/libnexus.unstripped.so && \
2228
chmod +x /bin/s1scanner
2329

2430
ENTRYPOINT ["/bin/s1scanner"]

nexus-sdk/go/build/Dockerfile.amd64

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

nexus-sdk/go/build/Dockerfile.nosdk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM --platform=$BUILDPLATFORM golang:1.24-bookworm AS build_stage
1+
FROM --platform=${BUILDPLATFORM} golang:1.24-bookworm AS build_stage
22

33
WORKDIR /go/src
44

@@ -13,7 +13,7 @@ RUN set -e && \
1313
ls -l && \
1414
go build -o s1scanner ./cmd/s1scanner
1515

16-
FROM busybox:glibc
16+
FROM --platform=${BUILDPLATFORM} busybox:glibc
1717

1818
WORKDIR /
1919

nexus-sdk/go/docs/developer.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ make s1scanner
5353
You can now run the scanner using the command:
5454

5555
```sh
56-
make run -- <args>
56+
LD_LIBRARY_PATH=./dist ./dist/s1scanner --base-path-folder=/ [flags] <file_or_dir ...>
5757
```
5858

59-
replacing `<args>` with any actual arguments to `s1scanner`.
59+
replacing `[flags]` with any actual arguments to `s1scanner` and `<file_or_dir>` with the absolute path to any file(s) or directory(ies) you wish to scan.
6060

61-
Be sure to include the `--` after `make run` otherwise `make` will interpret any flags as flags for the `make` command and _not_ for the `s1scanner` command.
61+
Be sure to use **absolute** paths, otherwise you will get unexpected behavior when running it outside of a container.
6262

6363
## Built-in Code Documentation
6464

nexus-sdk/go/docs/local-container.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,8 @@ Because the underlying container utilizes the Linux shared object library versio
2121

2222
To build the container, run the following command:
2323

24-
**Intel/AMD-based systems**
25-
26-
```sh
27-
make amd64-container
28-
```
29-
30-
**ARM-based systems (eg: Apple Silicon)**
31-
3224
```sh
33-
make arm64-container
25+
make container
3426
```
3527

3628
## Running the Container
@@ -43,6 +35,9 @@ Create an alias for the Docker command to simplify typing:
4335
alias s1scanner="docker run --rm -v /:/mnt:ro go/s1scanner"
4436
```
4537

38+
**NOTE:**
39+
_Do not try to run the commands below within a VS Code Terminal if you are using DevContainers and have activated the container environment. The reason being is that the mounts will not match up properly, so you'll want to alias the `s1scanner` command and run the sample commands below from a terminal outside of VS Code._
40+
4641
### Sample Scanner Commands
4742

4843
- To print a simple help screen use the `-h` or `--help` option:

0 commit comments

Comments
 (0)