From a739b12d770d3aac58dc83cd1091e9a6654f96c7 Mon Sep 17 00:00:00 2001 From: Zachary Sabourin <zachary.sabourin@eclipse-foundation.org> Date: Fri, 13 Jan 2023 17:42:12 +0000 Subject: [PATCH] feat: Standardize build process + update readme --- Jenkinsfile | 4 +-- Makefile | 25 ++++++++++------ README.md | 32 +++++++++++++++++---- config/application/secret.properties.sample | 6 ++-- docker-compose.yaml | 4 +++ 5 files changed, 53 insertions(+), 18 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2f6efff..ca2017b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,4 @@ - @Library('common-shared') _ +@Library('common-shared') _ pipeline { agent { @@ -108,6 +108,7 @@ pipeline { container('buildcontainer') { readTrusted 'Makefile' readTrusted 'pom.xml' + readTrusted 'package.json' sh 'make compile' stash name: "target", includes: "target/**/*" } @@ -120,7 +121,6 @@ pipeline { } steps { readTrusted 'src/main/docker/Dockerfile.jvm' - unstash 'target' sh ''' docker build -f src/main/docker/Dockerfile.jvm --no-cache -t ${IMAGE_NAME}:${TAG_NAME} -t ${IMAGE_NAME}:latest . diff --git a/Makefile b/Makefile index 73e441f..9b0735e 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,4 @@ SHELL = /bin/bash -pre-setup:; - @echo "Creating environment file from template" - @rm -f .env && envsubst < config/.env.sample > .env setup:; @echo "Generating secret files from templates using environment file + variables" @@ -12,19 +9,18 @@ dev-start:; clean:; mvn clean + yarn run clean install-yarn:; yarn install --frozen-lockfile --audit -generate-spec: validate-spec; +compile-test-resources: install-yarn; yarn run generate-json-schema -validate-spec: install-yarn; - -compile-java: generate-spec; +compile-java: compile-test-resources; mvn compile package -compile-java-quick: generate-spec; +compile-java-quick: compile-test-resources; mvn compile package -Dmaven.test.skip=true compile: clean compile-java; @@ -35,3 +31,16 @@ compile-start: compile-quick; docker compose down docker compose build docker compose up -d + +compile-java-quick-stubbed: compile-test-resources; + mvn compile package -Dmaven.test.skip=true -Declipse.cve.stubbed=true + +compile-quick-stubbed: clean compile-java-quick-stubbed; + +compile-start-stubbed: compile-quick-stubbed; + docker compose down + docker compose build + docker compose up -d + +start-spec: compile-test-resources; + yarn run start diff --git a/README.md b/README.md index f453997..4b79607 100644 --- a/README.md +++ b/README.md @@ -14,24 +14,46 @@ This API fetches internal CVE data ### Setup -Additional setup instructions will be added as the project grows and evolves. +Before running the application, some setup is required. The initial setup of this server can be started by running the command `make setup` which will instantiate the secrets file. To finish the setup, open the secrets file and add values to the missing fields before starting the server. The missing fields are primarily parameters used in the fetching of CVE data from GitLab and GitHub. Once the setup is finished you should be able to start the server through docker or using the live coding dev-mode. -#### Build and start server +#### Build and Start Server ```bash make compile-start ``` -#### Live coding dev mode +#### Build and Start Server Using Stubbed Data + +A version of the above server using stubbed data + +```bash +make compile-start-stubbed +``` + +#### Live Coding Dev Mode + +The live-coding dev mode uses stubbed data ```bash make dev-start ``` -#### Generate spec +#### Generate Spec + +```bash +make generate-test-resources +``` + +#### Running Tests + +```bash +mvn test +``` + +#### Render a Live UI Preview of the API Spec ```bash -make generate-spec +make start-spec ``` ## Contributing diff --git a/config/application/secret.properties.sample b/config/application/secret.properties.sample index ac8becc..02e806b 100644 --- a/config/application/secret.properties.sample +++ b/config/application/secret.properties.sample @@ -1,6 +1,6 @@ -eclipse.google.jwt-location=$PWD/config/application/client_secrets.json -eclipse.google.cve-file-id= eclipse.gitlab.cve-project.token=sample eclipse.gitlab.cve-project.project-id=sample eclipse.gitlab.cve-project.file-path=sample -eclipse.gitlab.cve-project.ref=sample \ No newline at end of file +eclipse.gitlab.cve-project.ref=sample + +eclipse.github.cve-project.token=sample \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index d0ed0b9..03f5201 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -5,6 +5,10 @@ services: dockerfile: ./src/main/docker/Dockerfile.jvm ports: - 8090:8090 + environment: + - CONFIG_SECRET_PATH=/var/run/secrets/secret.properties + volumes: + - ./config/application/secret.properties:/var/run/secrets/secret.properties deploy: restart_policy: condition: on-failure -- GitLab