diff --git a/Makefile b/Makefile index ec4ffab69e15a4226017b6da6ccc79820e6af1ff..c160d451ae659e5aac0103998093e79e8f8c0470 100644 --- a/Makefile +++ b/Makefile @@ -1,32 +1,45 @@ SHELL = /bin/bash -dev-start: clean; - docker-compose up -d gitlab mariadb - $(MAKE) import-mariadb-tables - (CONFIG_SECRET_PATH=$$PWD/config/application/secret.properties mvn compile -e quarkus:dev -Dconfig.secret.properties=$$PWD/config/application/secret.properties -Djava.net.preferIPv4Stack=true) +setup: clean start-services; +dev-start: setup; + (CONFIG_SECRET_PATH=$$PWD/config/application/secret.properties mvn compile quarkus:dev -Dconfig.secret.properties=$$PWD/config/application/secret.properties -Djava.net.preferIPv4Stack=true) clean:; mvn clean +## Compilation steps +install-yarn:; + yarn install --frozen-lockfile --audit +compile: clean compile-java; +compile-quick: clean compile-java-quick; compile-java: generate-spec; mvn compile package compile-java-quick: generate-spec; mvn compile package -Dmaven.test.skip=true -compile: clean compile-java; -compile-quick: clean compile-java-quick; -install-yarn:; - yarn install --frozen-lockfile --audit generate-spec: install-yarn validate-spec; yarn run generate-json-schema validate-spec: install-yarn; -compile-start: compile-quick; - docker compose down +compile-start: compile-quick start; +## Docker/service binds - services soft split from application to enable dev-start easier +start:; docker compose build docker compose up -d +start-services: stop-services; + docker compose up mariadb -d +start-opt: stop-opt; + docker compose --profile optional-services up -d +stop: stop-application; +stop-application:; + docker compose down +stop-services:; + docker compose stop mariadb +stop-opt:; + docker compose --profile optional-services down +stop-all: stop-application stop-services stop-opt; +## Start njs server w/ openapi spec start-spec: validate-spec; yarn run start +## Custom Testing calls test-post-git-eca:; curl http://api.eclipse.dev.docker:8090/git/eca -v -H 'Content-Type: application/json' -d @config/json/post-git-eca.json test-dev-post-git-eca:; curl http://api.eclipse.dev.docker:8080/git/eca -v -H 'Content-Type: application/json' -d @config/json/post-git-eca.json gitlab-root-pw-reset:; - docker exec -it $$(docker-compose ps -q gitlab) gitlab-rake "gitlab:password:reset[root]" -import-mariadb-tables:; - ./config/mariadb/import.sh \ No newline at end of file + docker exec -it $$(docker-compose ps -q gitlab) gitlab-rake "gitlab:password:reset[root]" \ No newline at end of file diff --git a/config/application/secret.properties.sample b/config/application/secret.properties.sample index b53f5ba933e6e4c37569b69d9079acbf8a6a4629..8c30fd9280007ee7db60c2c23c575a188bba12cb 100644 --- a/config/application/secret.properties.sample +++ b/config/application/secret.properties.sample @@ -1,3 +1,4 @@ +eclipse.internal-host=localhost ## Required for authenticated requests to profile API (api.eclipse.org: git.eclipse.org/r/ (dev-git-eca-rest-api))) ## Ask webdev@eclipse-foundation.org if you think you should have access to this client. oauth2.client-id= @@ -8,4 +9,5 @@ quarkus.datasource.username= quarkus.datasource.password= ## database connection -quarkus.datasource.jdbc.url=jdbc:mariadb://mariadb/dev_eclipse_eca \ No newline at end of file +quarkus.datasource.jdbc.url=jdbc:mariadb://mariadb/dev_eclipse_eca +%dev.quarkus.datasource.jdbc.url=jdbc:mariadb://${eclipse.internal-host}:10101/dev_eclipse_eca \ No newline at end of file diff --git a/config/mariadb/import.sh b/config/mariadb/import.sh deleted file mode 100755 index 62e39d20a0db83fd850d2e593c83323bd514f526..0000000000000000000000000000000000000000 --- a/config/mariadb/import.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# =========================================================================== -# Copyright (c) 2022 Eclipse Foundation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Christopher Guindon (Eclipse Foundation) -# ========================================================================== - -# Clean up database - -while ! mysqladmin ping -h "$MARIADB_HOST" --silent; do - sleep 1 - echo 'Waiting for mysql server to respond...' -done - -FILE="config/mariadb/init.sql" - -if test -f "$FILE"; then - mysql -u $MARIADB_USERNAME -p$MARIADB_PASSWORD -h $MARIADB_HOST dev_eclipse_eca < $FILE -else - echo "Unable to import. Missing the sql file: (${FILE})." -fi diff --git a/config/mariadb/init.sql b/config/mariadb/initdb.d/init.sql similarity index 100% rename from config/mariadb/init.sql rename to config/mariadb/initdb.d/init.sql diff --git a/docker-compose.yaml b/docker-compose.yaml index f4d94df40a22541c4b55131f903668dbf36bbcd5..b2ccfea787c899e79a016d46aa80202eefb3ee47 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,10 +1,10 @@ -version: '3' +version: '3.9' services: application: build: dockerfile: ./src/main/docker/Dockerfile.jvm ports: - - 8090:8080 + - 10100:8080 environment: - CONFIG_SECRET_PATH=/var/run/secrets/secret.properties volumes: @@ -26,6 +26,8 @@ services: image: 'gitlab/gitlab-ee:latest' restart: always hostname: 'gitlab.eclipse.dev.docker' + profiles: + - optional-services environment: GITLAB_OMNIBUS_CONFIG: | external_url 'http://gitlab.eclipse.dev.docker:8929' @@ -41,10 +43,11 @@ services: mariadb: image: mariadb:latest ports: - - '3306:3306' + - '10101:3306' volumes: - ./config/mariadb/conf.d:/etc/mysql/conf.d - ./volumes/mariadb:/var/lib/mysql + - ./config/mariadb/initdb.d:/docker-entrypoint-initdb.d environment: MYSQL_ROOT_PASSWORD: ${MARIADB_PASSWORD} MYSQL_DATABASE: dev_eclipse_eca