diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1888d08 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM openjdk:8-jdk-alpine +VOLUME /tmp +EXPOSE 8090 +ADD target/*.jar terraform-ui.jar +ENV JAVA_OPTS="" +ENTRYPOINT [ "sh", "-c", "java -jar terraform-ui.jar" ] \ No newline at end of file diff --git a/README.md b/README.md index ba86e33..d5377f8 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ user interface to run terraform (tf) files. * Provide the location of directory where files will be placed in global.properties (src/main/resources) #### Clone the version of terraform-ui you want to run. ``` -git clone https://github.com/mohnishbasha/terraform-ui.git +git clone https://github.com/siddharthshankarpaul/terraform-ui.git ``` #### change directory to the root of the project #### run below command from root of project to create the artifact @@ -25,16 +25,16 @@ java -jar target/terraform-ui-X.X.jar http://localhost:8090/ ``` -## How to run as docker container ? -* TBD [working on this, will be out soon .. ] - # System requirement * Java * Maven * Mysql -# Questions -* contact: mohinish_ce [@] yahoo dot com + +## How to run as docker container ? +* docker-compose build +* docker-compose start + # Demo -![demo.gif](https://github.com/mohnishbasha/terraform-ui/blob/master/demo/demo.gif "demo") +![demo.gif](https://github.com/siddharthshankarpaul/terraform-ui/blob/master/demo/demo.gif "demo") diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..05f3961 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,19 @@ +version: "3" + +services: + web: + build: . + image: terra-ui + links: + - db + ports: + - 80:8090 + command: ["./wait-for-db.sh", "3306"] + + db: + image: mysql + environment: + - MYSQL_ROOT_PASSWORD=mysql + - MYSQL_DATABASE=terra + expose: + - 3306 \ No newline at end of file diff --git a/pom.xml b/pom.xml index b75760b..54045e9 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.4.RELEASE + 2.1.2.RELEASE @@ -19,10 +19,18 @@ + + org.springframework.boot + spring-boot-starter-web + org.springframework.boot spring-boot-starter-thymeleaf + + org.springframework.boot + spring-boot-starter-data-rest + org.springframework.boot spring-boot-starter-data-jpa @@ -37,6 +45,7 @@ mysql mysql-connector-java + runtime @@ -54,7 +63,6 @@ org.apache.commons commons-lang3 - 3.6 org.apache.commons diff --git a/src/main/java/com/glitterlabs/terraformui/dao/ProjectRepository.java b/src/main/java/com/glitterlabs/terraformui/dao/ProjectRepository.java index ffe226d..91106eb 100644 --- a/src/main/java/com/glitterlabs/terraformui/dao/ProjectRepository.java +++ b/src/main/java/com/glitterlabs/terraformui/dao/ProjectRepository.java @@ -2,7 +2,7 @@ import java.util.List; -import org.springframework.data.repository.CrudRepository; +import org.springframework.data.jpa.repository.JpaRepository; import com.glitterlabs.terraformui.model.Cloud; import com.glitterlabs.terraformui.model.Project; @@ -10,7 +10,7 @@ /** * The Interface CloudProjectRepository. */ -public interface ProjectRepository extends CrudRepository { +public interface ProjectRepository extends JpaRepository { /** * Find by name. diff --git a/src/main/java/com/glitterlabs/terraformui/service/ProjectService.java b/src/main/java/com/glitterlabs/terraformui/service/ProjectService.java index 041fe6c..7ac7cbb 100644 --- a/src/main/java/com/glitterlabs/terraformui/service/ProjectService.java +++ b/src/main/java/com/glitterlabs/terraformui/service/ProjectService.java @@ -59,7 +59,7 @@ public List findAllProjectsByCloud(@NotNull final String cloudType) { * @return the project */ public Project findById(final Long projectId) { - return this.projectdao.findOne(projectId); + return this.projectdao.getOne(projectId); } /** @@ -81,7 +81,7 @@ public void create(final Project project) throws IOException { } public void updateStatus(final Long projectId, final ProjectStatus status) { - final Project project = this.projectdao.findOne(projectId); + final Project project = findById(projectId); project.setStatus(status); this.projectdao.save(project); } diff --git a/src/main/java/com/glitterlabs/terraformui/service/ResourceService.java b/src/main/java/com/glitterlabs/terraformui/service/ResourceService.java index dd81e05..e483e83 100644 --- a/src/main/java/com/glitterlabs/terraformui/service/ResourceService.java +++ b/src/main/java/com/glitterlabs/terraformui/service/ResourceService.java @@ -43,7 +43,7 @@ public class ResourceService { * @throws IOException Signals that an I/O exception has occurred. */ public void create(final String projectId, final String name, final String content, final String resourceType) throws IOException { - final Project project = this.dao.findOne(Long.valueOf(projectId)); + final Project project = this.dao.getOne(Long.valueOf(projectId)); final Path path = Paths.get(this.prop.getDirectoryPath(), project.getPath(), name); if (StringUtils.equalsIgnoreCase(resourceType, "file")) { Files.createFile(path); @@ -59,7 +59,7 @@ public void create(final String projectId, final String name, final String conte public List findAllResources(final String projectId, final String subpath) { List result = new ArrayList<>(); - final Project project = this.dao.findOne(Long.valueOf(projectId)); + final Project project = this.dao.getOne(Long.valueOf(projectId)); if (project != null) { try { result = DirectoryUtil.getResources(Paths.get(this.prop.getDirectoryPath(), project.getPath(), subpath)); @@ -71,7 +71,7 @@ public List findAllResources(final String projectId, final String subp } public String getResourceContent(final String projectId, final String resourcePath) throws IOException { - final Project project = this.dao.findOne(Long.valueOf(projectId)); + final Project project = this.dao.getOne(Long.valueOf(projectId)); final Path path = Paths.get(this.prop.getDirectoryPath(), project.getPath(), resourcePath); final byte[] bytes = Files.readAllBytes(path); return new String(bytes); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index a43c0a3..e58dccd 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -8,7 +8,7 @@ spring.jpa.hibernate.ddl-auto=update # Oracle settings spring.datasource.url=jdbc:mysql://localhost:3306/terra spring.datasource.username=root -spring.datasource.password=mysql +spring.datasource.password=mysql@123 spring.datasource.driver-class=com.mysql.jdbc.Driver # HikariCP settings diff --git a/src/main/resources/global.properties b/src/main/resources/global.properties index 49ee045..d7d2e73 100644 --- a/src/main/resources/global.properties +++ b/src/main/resources/global.properties @@ -1,2 +1,2 @@ -directory.root=D:\\myProjects\\terraUI\\directory -terraform.exe.path=D:\\myProjects\\terraUI\\terraform.exe \ No newline at end of file +directory.root=D:\\spaul\\myProjects\\terraUI\\directory +terraform.exe.path=D:\\spaul\\myProjects\\terraUI\\terraform.exe \ No newline at end of file diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index dbaee3c..3f419c9 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -13,11 +13,11 @@ - + - + diff --git a/wait-for-db.sh b/wait-for-db.sh new file mode 100644 index 0000000..3fdd268 --- /dev/null +++ b/wait-for-db.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +echo "Waiting for mysql" +until mysql -h"$1" -P"$1" -uroot -p"$MYSQL_ROOT_PASSWORD" &> /dev/null +do + printf "." + sleep 1 +done + +echo -e "\nmysql ready" \ No newline at end of file