Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
bonzofenix committed Feb 24, 2025
1 parent 8854dba commit dfd3ce5
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 9 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ test-app.go-mod-tidy:
make --directory='${go-test-app-dir}' go-mod-tidy



.PHONY: mod-download
mod-download:
@for folder in $$(find . -maxdepth 3 -name "go.mod" -exec dirname {} \;);\
Expand Down
7 changes: 7 additions & 0 deletions src/autoscaler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ fmt: importfmt
lint:
@cd ../../; make lint_autoscaler OPTS=${OPTS}

.PHONY: clean-dbtasks package-dbtasks
clean-dbtasks:
pushd dbtasks; mvn clean; popd

package-dbtasks:
pushd dbtasks; mvn package -Dmaven.test.skip=true ; popd

.PHONY: clean
clean:
@echo "# cleaning autoscaler"
Expand Down
6 changes: 6 additions & 0 deletions src/autoscaler/dbtasks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/target/
/bin/
/.classpath
/.project
/.settings
/.mvn
9 changes: 9 additions & 0 deletions src/autoscaler/dbtasks/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SHELL := /bin/bash

package:
## target build in target2 directory
mvn package -Dmaven.test.skip=true

clean:
mvn clean

11 changes: 11 additions & 0 deletions src/autoscaler/dbtasks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Build the db app
Provide the DB credentials and url in the /src/main/resources/application.properties file.
```
mvn clean package
```

## Deploy
Requires java buildpack version 3.7
```
cf push autoscaler-db -p <PATH_TO_REPO>/db/target/db-1.0-SNAPSHOT.war -b https://github.com/cloudfoundry/java-buildpack.git#v3.7
```
110 changes: 110 additions & 0 deletions src/autoscaler/dbtasks/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.cloudfoundry.autoscaler</groupId>
<artifactId>db</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>db</name>
<description>AutoScaler DB</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.18</version>
<relativePath/>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>4.31.1</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.5</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>9.2.0</version>
</dependency>
<!-- Spring Boot -->

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.7.18</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.7.18</version>
</dependency>


<!-- Ensure this matches your missing classes -->
<dependency>
<groupId>org.cloudfoundry</groupId>
<artifactId>cloudfoundry-operations</artifactId>
<version>5.4.0.RELEASE</version>
</dependency>

<dependency>
<groupId>org.cloudfoundry</groupId>
<artifactId>cloudfoundry-client-lib</artifactId>
<version>1.1.3</version>
</dependency>
</dependencies>

<build>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>

<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.cloudfoundry.autoscaler;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

18 changes: 10 additions & 8 deletions src/autoscaler/mta.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ build-parameters:
before-all:
- builder: custom
commands:
- make clean vendor
- make clean vendor clean-dbtasks package-dbtasks


modules:
# - name: db-lock-cleaner-hook # uses src/changeloglockcleaner
- name: db # uses src/db
- name: dbtasks
type: java
build-parameters:
builder: custom
commands:
- make clean package
path: ../db
path: dbtasks/target/db-1.0-SNAPSHOT.jar
properties:
JBP_LOG_LEVEL: true
DEBUG: true
parameters:
no-start: true
hooks:
- name: db-apply-changelog-hook
type: task
Expand All @@ -35,7 +37,7 @@ modules:
#--driver=org.postgresql.Driver --changeLogFile=servicebroker.db.changelog.yaml update

- name: publicapiserver
type: go # and java
type: go
path: .
properties:
DT_RELEASE_BUILD_VERSION: ${mta-version}
Expand Down

0 comments on commit dfd3ce5

Please sign in to comment.