-
Notifications
You must be signed in to change notification settings - Fork 18
docs(setup): Add setup docs and easy install script #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
deo002
wants to merge
1
commit into
fossology:main
Choose a base branch
from
siemens:docs/setup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| <!-- SPDX-FileCopyrightText: 2025 Dearsh Oberoi <[email protected]> | ||
|
|
||
| SPDX-License-Identifier: GPL-2.0-only | ||
| --> | ||
|
|
||
| # Project Setup | ||
|
|
||
| There are 3 ways to run LicenseDb. | ||
|
|
||
| ## 1. Easy Install Script | ||
|
|
||
| The easiest of them all is via the easy install script. | ||
|
|
||
| - (Optional) Edit the ```configs/.env.dev.example``` to set the environment variables. If not done, default values will be taken. | ||
|
|
||
| - (Optional) Edit the ```external_ref_fields.example.yaml``` to extend the schema of licenses and obligations with custom fields. If not done, default values will be taken. | ||
|
|
||
| - Run the easy install script to generate the app binary. | ||
|
|
||
| ```bash | ||
| ./easy_install.sh | ||
| ``` | ||
|
|
||
| - Run the executable | ||
|
|
||
| ```bash | ||
| ./laas | ||
| ``` | ||
|
|
||
| Use the command below for more startup options. | ||
|
|
||
| ```bash | ||
| ./laas --help | ||
| ``` | ||
|
|
||
| ## 2. Docker Installation | ||
|
|
||
| - Build the app image | ||
|
|
||
| ```bash | ||
| docker build -t licensedb/latest . | ||
| ``` | ||
|
|
||
| - Run the container | ||
|
|
||
| ```bash | ||
| docker compose up | ||
| ``` | ||
|
|
||
| ## 3. Bare metal Installation | ||
|
|
||
| ### 1. Setting up the project | ||
|
|
||
| - Create the `external_ref_fields.yaml` file in the root directory of the project to extend the schema of licenses and obligations with custom fields. | ||
|
|
||
| ```bash | ||
| cp external_ref_fields.example.yaml external_ref_fields.yaml | ||
| vim external_ref_fields.yaml | ||
| ``` | ||
|
|
||
| - Generate Go struct for the extra fields listed in the external_ref_fields.yaml. | ||
|
|
||
| ```bash | ||
| go generate ./... | ||
| ``` | ||
|
|
||
| - Create the `.env` file in the root directory of the project and change the | ||
| values of the environment variables as per your requirement. | ||
|
|
||
| ```bash | ||
| cp configs/.env.dev.example .env | ||
| vim .env | ||
| ``` | ||
|
|
||
| - Build the project using following command. | ||
|
|
||
| ```bash | ||
| go build ./cmd/laas | ||
| ``` | ||
|
|
||
| ### 2. Setting up the database | ||
|
|
||
| - Create database licensedb and provide user fossy all privileges to it. | ||
|
|
||
| ```sql | ||
| CREATE DATABASE licensedb; | ||
|
|
||
| CREATE USER fossy WITH PASSWORD 'fossy'; | ||
|
|
||
| GRANT ALL PRIVILEGES ON DATABASE licensedb TO fossy; | ||
| ``` | ||
|
|
||
| - Run the migration files. | ||
|
|
||
| ```bash | ||
| migrate -path pkg/db/migrations -database "postgres://fossy:fossy@localhost:5432/licensedb?sslmode=disable" up | ||
| ``` | ||
|
|
||
| - Create first user | ||
|
|
||
| Connect to the database using `psql` with the following command. | ||
|
|
||
| ```bash | ||
| psql -h localhost -p 5432 -U fossy -d licensedb | ||
| ``` | ||
|
|
||
| Run the following query to create the first user. | ||
|
|
||
| ```sql | ||
| INSERT INTO users (user_name, user_password, user_level, display_name, user_email) VALUES ('<username>', '<password>', 'SUPER_ADMIN', '<display_name>', '<user_email>'); | ||
| ``` | ||
|
|
||
| ### 3. Run the executable | ||
|
|
||
| ```bash | ||
| ./laas | ||
| ``` | ||
|
|
||
| Use the command below for more startup options. | ||
|
|
||
| ```bash | ||
| ./laas --help | ||
| ``` | ||
|
|
||
| - You can directly run it by the following command. | ||
|
|
||
| ```bash | ||
| go run ./cmd/laas | ||
| ``` | ||
|
|
||
| ## Post Install | ||
|
|
||
| - ### Generating Swagger Documentation | ||
|
|
||
| - This step can be skipped if installation is done via the ```easy_install``` script. | ||
| - Install [swag](https://github.com/swaggo/swag) using the following command. | ||
|
|
||
| ```bash | ||
| go install github.com/swaggo/swag/cmd/swag@latest | ||
| ``` | ||
|
|
||
| - Run the following command to generate swagger documentation. | ||
| <!-- https://github.com/swaggo/swag/issues/817#issuecomment-730895033 --> | ||
| ```bash | ||
| swag init --parseDependency --generalInfo api.go --dir ./pkg/api,./pkg/auth,./pkg/db,./pkg/models,./pkg/utils --output ./cmd/laas/docs | ||
| ``` | ||
|
|
||
| - Swagger documentation will be generated in `./cmd/laas/docs` folder. | ||
| - Run the project and navigate to `http://localhost:8080/swagger/index.html` to view the documentation. | ||
| - After changing any documentation comments, format them with following command. | ||
|
|
||
| ```bash | ||
| swag fmt --generalInfo ./pkg/api/api.go --dir ./pkg/api,./pkg/auth,./pkg/db,./pkg/models,./pkg/utils | ||
| ``` | ||
|
|
||
| - Only the super admin user can create new app users, import licenses and obligations. | ||
|
|
||
| To gain further capabilities, create a new admin user via the swagger docs or via the [LicenseDb UI](https://github.com/fossology/LicenseDb-UI). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the command/script or refer to the repository.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The instructions are under a wrong header; please fix.