OPG Scanning is a Go-based microservice designed to perform scanning and document extraction and processing operations. It is containerized with Docker Compose for both standard and Sirius-integrated environments.
The OPG Scanning service enables you to run tests, build the application, and perform security and lint analysis through a set of defined Makefile commands. The project is structured for rapid local development and integration testing with external dependencies such as Localstack and a Sirius mock service.
For local development and testing you will need:
- Docker
- Docker Compose
- Golang (>= 1.24.0 - if you plan on running tests outside of Docker)
The Makefile includes several targets to simplify common development tasks:
- Build and Test
make
: Runs tests, starts the application, and then cleans up.make test
: Builds theservice-app-test
container and runs unit tests.make integration-test
: Starts the application, runs integration tests viatester/test.sh
, and then cleans up.
- Build and Run
make build
: Builds the application Docker image.make start
: Builds the application and starts it using Docker Compose.make start-sirius
: Runs the application integrated with local Sirius. This command uses bothdocker-compose.yml
anddocker-compose.sirius.yml
.
- Clean Up
make clean
: Stops and removes Docker Compose resources.
- Static Analysis
make go-lint
: Runs the Go linting tool inside its container.make gosec
: Runs the Go security scanner to check for vulnerabilities.
The project uses two Docker Compose files to manage service configurations:
- docker-compose.yml
Defines the following services:- service-app: The main application container.
- service-app-test: A container running tests with a dedicated Dockerfile.
- localstack: A local AWS stack emulator for S3, Secrets Manager, SQS, SSM, etc.
- sirius-mock: A mock service to emulate Sirius endpoints.
- go-lint: A container to run golangci-lint with preset cache and output settings.
- gosec: A container to run security scans on your code.
- docker-compose.sirius.yml
Overrides for running with Sirius integration:- Resets some service dependencies and network settings.
- Adjusts the
SIRIUS_BASE_URL
environment variable to point to the Sirius API.
-
Running Unit Tests
make test
This command builds the test container and runs all unit tests.
-
Running Integration Tests
make integration-test
This will start the app, run the integration tests via the provided test script, and perform cleanup.
-
Starting the Application
make start
To run with Sirius integration:
make start-sirius
-
Cleaning Up
To stop and remove all Docker Compose resources, run:
make clean
-
For linting
make go-lint
-
For security scanning
make gosec
Before running tests or starting the application, ensure you have the required Docker images by building the project:
make build
The Makefile’s setup-directories target ensures that necessary directories (e.g., for test results) are created.