From c7549811726e12f0b7d679d5aabdb47d9dd7815f Mon Sep 17 00:00:00 2001 From: t-takahashi Date: Tue, 30 Jan 2024 08:08:31 +0900 Subject: [PATCH 1/4] Update app version to 2.0.0 --- src/main/resources/templates/list.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/templates/list.html b/src/main/resources/templates/list.html index 547cf5a..8fd6953 100644 --- a/src/main/resources/templates/list.html +++ b/src/main/resources/templates/list.html @@ -83,7 +83,7 @@ -
1.1.7
+
2.0.0
From 1a9afdd9fef54cf4bb66a0571fb8933ff409dd73 Mon Sep 17 00:00:00 2001 From: t-takahashi Date: Tue, 30 Jan 2024 22:53:41 +0900 Subject: [PATCH 2/4] Delete unused files and configurations --- app/Dockerfile | 16 ++++++++++++ build.gradle => app/build.gradle | 23 ++++++++++++++++-- .../gradle}/wrapper/gradle-wrapper.jar | Bin .../gradle}/wrapper/gradle-wrapper.properties | 2 +- gradlew => app/gradlew | 0 gradlew.bat => app/gradlew.bat | 0 settings.gradle => app/settings.gradle | 0 .../io/github/tttol/mrls/MrlsApplication.java | 0 .../tttol/mrls/config/RestTemplateConfig.java | 0 .../mrls/controller/MrListController.java | 0 .../dto/GitLabMergeRequestApiResponseDto.java | 0 .../io/github/tttol/mrls/dto/UserDto.java | 0 .../mrls/exception/GitLabApiException.java | 0 .../mrls/external/GitLabApiExecutor.java | 0 .../github/tttol/mrls/form/MrDetailForm.java | 0 .../io/github/tttol/mrls/form/MrInfoForm.java | 0 .../io/github/tttol/mrls/form/UserForm.java | 0 .../mrls/handler/ApiExceptionHandler.java | 0 .../mrls/service/MergeRequestService.java | 0 .../src}/main/resources/application-env.yml | 0 .../src}/main/resources/application.yml | 6 ++--- .../src}/main/resources/static/css/list.css | 0 .../main/resources/static/img/page-sample.png | Bin .../main/resources/templates/apiError.html | 0 .../resources/templates/fragment/footer.html | 0 .../resources/templates/fragment/header.html | 0 .../src}/main/resources/templates/list.html | 0 .../tttol/mrls/MrlsApplicationTests.java | 0 .../mrls/controller/MrListControllerTest.java | 0 .../mrls/service/MergeRequestServiceTest.java | 0 version.properties | 1 - 31 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 app/Dockerfile rename build.gradle => app/build.gradle (63%) rename {gradle => app/gradle}/wrapper/gradle-wrapper.jar (100%) rename {gradle => app/gradle}/wrapper/gradle-wrapper.properties (93%) rename gradlew => app/gradlew (100%) rename gradlew.bat => app/gradlew.bat (100%) rename settings.gradle => app/settings.gradle (100%) rename {src => app/src}/main/java/io/github/tttol/mrls/MrlsApplication.java (100%) rename {src => app/src}/main/java/io/github/tttol/mrls/config/RestTemplateConfig.java (100%) rename {src => app/src}/main/java/io/github/tttol/mrls/controller/MrListController.java (100%) rename {src => app/src}/main/java/io/github/tttol/mrls/dto/GitLabMergeRequestApiResponseDto.java (100%) rename {src => app/src}/main/java/io/github/tttol/mrls/dto/UserDto.java (100%) rename {src => app/src}/main/java/io/github/tttol/mrls/exception/GitLabApiException.java (100%) rename {src => app/src}/main/java/io/github/tttol/mrls/external/GitLabApiExecutor.java (100%) rename {src => app/src}/main/java/io/github/tttol/mrls/form/MrDetailForm.java (100%) rename {src => app/src}/main/java/io/github/tttol/mrls/form/MrInfoForm.java (100%) rename {src => app/src}/main/java/io/github/tttol/mrls/form/UserForm.java (100%) rename {src => app/src}/main/java/io/github/tttol/mrls/handler/ApiExceptionHandler.java (100%) rename {src => app/src}/main/java/io/github/tttol/mrls/service/MergeRequestService.java (100%) rename {src => app/src}/main/resources/application-env.yml (100%) rename {src => app/src}/main/resources/application.yml (71%) rename {src => app/src}/main/resources/static/css/list.css (100%) rename {src => app/src}/main/resources/static/img/page-sample.png (100%) rename {src => app/src}/main/resources/templates/apiError.html (100%) rename {src => app/src}/main/resources/templates/fragment/footer.html (100%) rename {src => app/src}/main/resources/templates/fragment/header.html (100%) rename {src => app/src}/main/resources/templates/list.html (100%) rename {src => app/src}/test/java/io/github/tttol/mrls/MrlsApplicationTests.java (100%) rename {src => app/src}/test/java/io/github/tttol/mrls/controller/MrListControllerTest.java (100%) rename {src => app/src}/test/java/io/github/tttol/mrls/service/MergeRequestServiceTest.java (100%) delete mode 100644 version.properties diff --git a/app/Dockerfile b/app/Dockerfile new file mode 100644 index 0000000..f495cdf --- /dev/null +++ b/app/Dockerfile @@ -0,0 +1,16 @@ +FROM public.ecr.aws/sam/build-java17:1.108.0-20240123221230 as build-image +WORKDIR "/task" +COPY src src/ +COPY gradle gradle/ +COPY gradlew ./ +COPY gradlew.bat ./ +COPY build.gradle ./ +COPY settings.gradle ./ +RUN ./gradlew clean assemble + +FROM public.ecr.aws/docker/library/amazoncorretto:17.0.10-alpine3.19 +COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.8.1 /lambda-adapter /opt/extensions/lambda-adapter +EXPOSE 8080 +WORKDIR /opt +COPY --from=build-image /task/build/libs/mrls-2.0.0.jar /opt +CMD ["java", "-jar", "mrls-2.0.0.jar"] \ No newline at end of file diff --git a/build.gradle b/app/build.gradle similarity index 63% rename from build.gradle rename to app/build.gradle index b0ba5b9..a14f7b2 100644 --- a/build.gradle +++ b/app/build.gradle @@ -1,11 +1,11 @@ plugins { id 'java' - id 'org.springframework.boot' version '3.0.1' + id 'org.springframework.boot' version '3.2.2' id 'io.spring.dependency-management' version '1.1.0' } group = 'io.github.tttol' -version = "1.1.6" +version = "2.0.0" sourceCompatibility = '17' configurations { @@ -32,3 +32,22 @@ dependencies { tasks.named('test') { useJUnitPlatform() } + +// sourceSets { +// main { +// java { +// srcDirs = ['app/src/main/java'] +// resources { +// srcDirs = ['app/src/main/resources'] +// } +// } +// } +// test { +// java { +// srcDirs = ['app/src/test/java'] +// resources { +// srcDirs = ['app/src/test/resources'] +// } +// } +// } +// } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/app/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from gradle/wrapper/gradle-wrapper.jar rename to app/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/wrapper/gradle-wrapper.properties b/app/gradle/wrapper/gradle-wrapper.properties similarity index 93% rename from gradle/wrapper/gradle-wrapper.properties rename to app/gradle/wrapper/gradle-wrapper.properties index 070cb70..a595206 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/app/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/app/gradlew similarity index 100% rename from gradlew rename to app/gradlew diff --git a/gradlew.bat b/app/gradlew.bat similarity index 100% rename from gradlew.bat rename to app/gradlew.bat diff --git a/settings.gradle b/app/settings.gradle similarity index 100% rename from settings.gradle rename to app/settings.gradle diff --git a/src/main/java/io/github/tttol/mrls/MrlsApplication.java b/app/src/main/java/io/github/tttol/mrls/MrlsApplication.java similarity index 100% rename from src/main/java/io/github/tttol/mrls/MrlsApplication.java rename to app/src/main/java/io/github/tttol/mrls/MrlsApplication.java diff --git a/src/main/java/io/github/tttol/mrls/config/RestTemplateConfig.java b/app/src/main/java/io/github/tttol/mrls/config/RestTemplateConfig.java similarity index 100% rename from src/main/java/io/github/tttol/mrls/config/RestTemplateConfig.java rename to app/src/main/java/io/github/tttol/mrls/config/RestTemplateConfig.java diff --git a/src/main/java/io/github/tttol/mrls/controller/MrListController.java b/app/src/main/java/io/github/tttol/mrls/controller/MrListController.java similarity index 100% rename from src/main/java/io/github/tttol/mrls/controller/MrListController.java rename to app/src/main/java/io/github/tttol/mrls/controller/MrListController.java diff --git a/src/main/java/io/github/tttol/mrls/dto/GitLabMergeRequestApiResponseDto.java b/app/src/main/java/io/github/tttol/mrls/dto/GitLabMergeRequestApiResponseDto.java similarity index 100% rename from src/main/java/io/github/tttol/mrls/dto/GitLabMergeRequestApiResponseDto.java rename to app/src/main/java/io/github/tttol/mrls/dto/GitLabMergeRequestApiResponseDto.java diff --git a/src/main/java/io/github/tttol/mrls/dto/UserDto.java b/app/src/main/java/io/github/tttol/mrls/dto/UserDto.java similarity index 100% rename from src/main/java/io/github/tttol/mrls/dto/UserDto.java rename to app/src/main/java/io/github/tttol/mrls/dto/UserDto.java diff --git a/src/main/java/io/github/tttol/mrls/exception/GitLabApiException.java b/app/src/main/java/io/github/tttol/mrls/exception/GitLabApiException.java similarity index 100% rename from src/main/java/io/github/tttol/mrls/exception/GitLabApiException.java rename to app/src/main/java/io/github/tttol/mrls/exception/GitLabApiException.java diff --git a/src/main/java/io/github/tttol/mrls/external/GitLabApiExecutor.java b/app/src/main/java/io/github/tttol/mrls/external/GitLabApiExecutor.java similarity index 100% rename from src/main/java/io/github/tttol/mrls/external/GitLabApiExecutor.java rename to app/src/main/java/io/github/tttol/mrls/external/GitLabApiExecutor.java diff --git a/src/main/java/io/github/tttol/mrls/form/MrDetailForm.java b/app/src/main/java/io/github/tttol/mrls/form/MrDetailForm.java similarity index 100% rename from src/main/java/io/github/tttol/mrls/form/MrDetailForm.java rename to app/src/main/java/io/github/tttol/mrls/form/MrDetailForm.java diff --git a/src/main/java/io/github/tttol/mrls/form/MrInfoForm.java b/app/src/main/java/io/github/tttol/mrls/form/MrInfoForm.java similarity index 100% rename from src/main/java/io/github/tttol/mrls/form/MrInfoForm.java rename to app/src/main/java/io/github/tttol/mrls/form/MrInfoForm.java diff --git a/src/main/java/io/github/tttol/mrls/form/UserForm.java b/app/src/main/java/io/github/tttol/mrls/form/UserForm.java similarity index 100% rename from src/main/java/io/github/tttol/mrls/form/UserForm.java rename to app/src/main/java/io/github/tttol/mrls/form/UserForm.java diff --git a/src/main/java/io/github/tttol/mrls/handler/ApiExceptionHandler.java b/app/src/main/java/io/github/tttol/mrls/handler/ApiExceptionHandler.java similarity index 100% rename from src/main/java/io/github/tttol/mrls/handler/ApiExceptionHandler.java rename to app/src/main/java/io/github/tttol/mrls/handler/ApiExceptionHandler.java diff --git a/src/main/java/io/github/tttol/mrls/service/MergeRequestService.java b/app/src/main/java/io/github/tttol/mrls/service/MergeRequestService.java similarity index 100% rename from src/main/java/io/github/tttol/mrls/service/MergeRequestService.java rename to app/src/main/java/io/github/tttol/mrls/service/MergeRequestService.java diff --git a/src/main/resources/application-env.yml b/app/src/main/resources/application-env.yml similarity index 100% rename from src/main/resources/application-env.yml rename to app/src/main/resources/application-env.yml diff --git a/src/main/resources/application.yml b/app/src/main/resources/application.yml similarity index 71% rename from src/main/resources/application.yml rename to app/src/main/resources/application.yml index c507b62..8ebc773 100644 --- a/src/main/resources/application.yml +++ b/app/src/main/resources/application.yml @@ -1,9 +1,9 @@ app: gitlab: - host: ${GITLAB_HOST} + host: host project: - id: ${GITLAB_PROJECT_ID} - accessToken: ${GITLAB_ACCESS_TOKEN} + id: id + accessToken: token api: endpoint: https://${app.gitlab.host}/api/v4/projects/${app.gitlab.project.id}/merge_requests?state=opened logging: diff --git a/src/main/resources/static/css/list.css b/app/src/main/resources/static/css/list.css similarity index 100% rename from src/main/resources/static/css/list.css rename to app/src/main/resources/static/css/list.css diff --git a/src/main/resources/static/img/page-sample.png b/app/src/main/resources/static/img/page-sample.png similarity index 100% rename from src/main/resources/static/img/page-sample.png rename to app/src/main/resources/static/img/page-sample.png diff --git a/src/main/resources/templates/apiError.html b/app/src/main/resources/templates/apiError.html similarity index 100% rename from src/main/resources/templates/apiError.html rename to app/src/main/resources/templates/apiError.html diff --git a/src/main/resources/templates/fragment/footer.html b/app/src/main/resources/templates/fragment/footer.html similarity index 100% rename from src/main/resources/templates/fragment/footer.html rename to app/src/main/resources/templates/fragment/footer.html diff --git a/src/main/resources/templates/fragment/header.html b/app/src/main/resources/templates/fragment/header.html similarity index 100% rename from src/main/resources/templates/fragment/header.html rename to app/src/main/resources/templates/fragment/header.html diff --git a/src/main/resources/templates/list.html b/app/src/main/resources/templates/list.html similarity index 100% rename from src/main/resources/templates/list.html rename to app/src/main/resources/templates/list.html diff --git a/src/test/java/io/github/tttol/mrls/MrlsApplicationTests.java b/app/src/test/java/io/github/tttol/mrls/MrlsApplicationTests.java similarity index 100% rename from src/test/java/io/github/tttol/mrls/MrlsApplicationTests.java rename to app/src/test/java/io/github/tttol/mrls/MrlsApplicationTests.java diff --git a/src/test/java/io/github/tttol/mrls/controller/MrListControllerTest.java b/app/src/test/java/io/github/tttol/mrls/controller/MrListControllerTest.java similarity index 100% rename from src/test/java/io/github/tttol/mrls/controller/MrListControllerTest.java rename to app/src/test/java/io/github/tttol/mrls/controller/MrListControllerTest.java diff --git a/src/test/java/io/github/tttol/mrls/service/MergeRequestServiceTest.java b/app/src/test/java/io/github/tttol/mrls/service/MergeRequestServiceTest.java similarity index 100% rename from src/test/java/io/github/tttol/mrls/service/MergeRequestServiceTest.java rename to app/src/test/java/io/github/tttol/mrls/service/MergeRequestServiceTest.java diff --git a/version.properties b/version.properties deleted file mode 100644 index a97812e..0000000 --- a/version.properties +++ /dev/null @@ -1 +0,0 @@ -appVersion=1.1.6 \ No newline at end of file From 020fb847208904a686bd1ad5f40174238f80f7e5 Mon Sep 17 00:00:00 2001 From: t-takahashi Date: Wed, 31 Jan 2024 08:03:24 +0900 Subject: [PATCH 3/4] add top.html --- .../tttol/mrls/controller/TopController.java | 17 +++++++++++++++++ app/src/main/resources/application.yml | 2 ++ app/src/main/resources/templates/top.html | 12 ++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 app/src/main/java/io/github/tttol/mrls/controller/TopController.java create mode 100644 app/src/main/resources/templates/top.html diff --git a/app/src/main/java/io/github/tttol/mrls/controller/TopController.java b/app/src/main/java/io/github/tttol/mrls/controller/TopController.java new file mode 100644 index 0000000..c48ea54 --- /dev/null +++ b/app/src/main/java/io/github/tttol/mrls/controller/TopController.java @@ -0,0 +1,17 @@ +package io.github.tttol.mrls.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +import lombok.RequiredArgsConstructor; + +@Controller +@RequestMapping("/") +@RequiredArgsConstructor +public class TopController { + @GetMapping + public String top() { + return "top"; + } +} diff --git a/app/src/main/resources/application.yml b/app/src/main/resources/application.yml index 8ebc773..dcf8181 100644 --- a/app/src/main/resources/application.yml +++ b/app/src/main/resources/application.yml @@ -1,3 +1,5 @@ +server: + port: 8081 app: gitlab: host: host diff --git a/app/src/main/resources/templates/top.html b/app/src/main/resources/templates/top.html new file mode 100644 index 0000000..cb23814 --- /dev/null +++ b/app/src/main/resources/templates/top.html @@ -0,0 +1,12 @@ + + + + + MRLS + + + +

Hello MRLS

+ + \ No newline at end of file From 1e8eb25501ca3c7edd4a7a5a0fb4e9e71481cb45 Mon Sep 17 00:00:00 2001 From: t-takahashi Date: Mon, 20 May 2024 11:12:52 +0900 Subject: [PATCH 4/4] add sam file --- .aws-sam/build.toml | 5 +++ template.yml | 75 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 .aws-sam/build.toml create mode 100644 template.yml diff --git a/.aws-sam/build.toml b/.aws-sam/build.toml new file mode 100644 index 0000000..678bce4 --- /dev/null +++ b/.aws-sam/build.toml @@ -0,0 +1,5 @@ +# This file is auto generated by SAM CLI build command + +[function_build_definitions] + +[layer_build_definitions] diff --git a/template.yml b/template.yml new file mode 100644 index 0000000..fadefa6 --- /dev/null +++ b/template.yml @@ -0,0 +1,75 @@ +AWSTemplateFormatVersion: '2010-09-09' +Transform: AWS::Serverless-2016-10-31 +Description: > + mrls in AWS Lambda +Globals: + Function: + Timeout: 10 + +Resources: + MrlsFunction: + Type: AWS::Serverless::Function + Properties: + PackageType: Image + MemorySize: 2048 + Tracing: Active + Environment: + Variables: + RUST_LOG: info + READINESS_CHECK_PATH: /healthz + REMOVE_BASE_PATH: /v1 + AutoPublishAlias: live + DeploymentPreference: + Type: AllAtOnce + ProvisionedConcurrencyConfig: + ProvisionedConcurrentExecutions: 1 + Events: + Root: + Type: HttpApi + Properties: + Path: /v1 + Method: ANY + Mrls: + Type: HttpApi + Properties: + Path: /v1/{proxy+} + Method: ANY + # Metadata: + # DockerTag: java17.gradle-v1 + # DockerContext: ./app + # Dockerfile: Dockerfile + + MyScalableTarget: + Type: AWS::ApplicationAutoScaling::ScalableTarget + Properties: + MaxCapacity: 100 + MinCapacity: 1 + ResourceId: !Sub function:${MrlsFunction}:live # You need to specify an alis or version here + RoleARN: !Sub arn:aws:iam::${AWS::AccountId}:role/aws-service-role/lambda.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_LambdaConcurrency + ScalableDimension: lambda:function:ProvisionedConcurrency + ServiceNamespace: lambda + DependsOn: MrlsFunctionAliaslive # This is your function logical ID + "Alias" + what you use for AutoPublishAlias + + MyTargetTrackingScalingPolicy: + Type: AWS::ApplicationAutoScaling::ScalingPolicy + Properties: + PolicyName: utilization + PolicyType: TargetTrackingScaling + ScalingTargetId: !Ref MyScalableTarget + TargetTrackingScalingPolicyConfiguration: + TargetValue: 0.70 # Any value between 0 and 1 can be used here + CustomizedMetricSpecification: + Dimensions: + - Name: FunctionName + Value: !Ref MrlsFunction + - Name: Resource + Value: !Sub "${MrlsFunction}:live" + MetricName: ProvisionedConcurrencyUtilization + Namespace: AWS/Lambda + Statistic: Maximum + Unit: Count + +Outputs: + MrlsApi: + Description: "API Gateway endpoint URL for Prod stage for Mrls function" + Value: !Sub "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.${AWS::URLSuffix}/v1/mrls"