Skip to content

Commit

Permalink
breaking: upgrated version to java 21 (#76)
Browse files Browse the repository at this point in the history
* ignore .idea

* updated webconfig

* removed application.properties

* added springboot application.yml

* added logback configurations

* added logback configurations

* upgrated pom.xml to java 21

* upgrated docker to java 21

* updated maven wrapper

* updated docker image

* updated docker image with best practice

* disabled azdo step

* disabled azdo step

* pre-commit fixs

* htlm page with new layout

* better root controller

* docker compose updated

* docker compose updated

* pre-commit fixs

* Added pull request template
  • Loading branch information
diegolagospagopa authored Jan 7, 2025
1 parent 3baa7f5 commit 863b84f
Show file tree
Hide file tree
Showing 17 changed files with 953 additions and 596 deletions.
39 changes: 39 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#### Description
<!--- Please always add a PR description as if nobody knows anything about the context these changes come from. -->
<!--- Even if we are all from our internal team, we may not be on the same page. -->
<!--- Write this PR as you were contributing to a public OSS project, where nobody knows you and you have to earn their trust. -->
<!--- This will improve our projects in the long run! Thanks. -->

#### List of Changes
<!--- Describe your changes in detail -->

#### Motivation and Context
<!--- Why is this change required? What problem does it solve? -->

#### How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, tests ran to see how -->
<!--- your change affects other areas of the code, etc. -->
- Pre-Deploy Test
- [ ] Unit
- [ ] Integration (Narrow)
- Post-Deploy Test
- [ ] Isolated Microservice
- [ ] Broader Integration
- [ ] Acceptance
- [ ] Performance & Load

#### Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] PATCH - Bug fix (backwards compatible bug fixes)
- [ ] MINOR - New feature (add functionality in a backwards compatible manner)
- [ ] MAJOR - Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] CHORE - Minor Change (fix or feature that don't impact the functionality e.g. Documentation or lint configuration)

#### Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
2 changes: 1 addition & 1 deletion .github/workflows/payments-flow-docker-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
uses: pagopa/github-actions-template/payments-flow-docker-snapshot@37569377fa759368a01c1e7f40700b4118d65d0c
with:
current_branch: ${{ github.ref_name }}
enable_azure_devops_step: 'true'
enable_azure_devops_step: 'false'
azure_devops_apps: "[one-color]"
azure_devops_project_url: 'https://dev.azure.com/pagopaspa/devopslab-projects'
azure_devops_pipeline_name: 'devopslab-diego-deploy.deploy'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/payments-flow-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: pagopa/github-actions-template/payments-flow-release@37569377fa759368a01c1e7f40700b4118d65d0c
with:
current_branch: ${{ github.ref_name }}
enable_azure_devops_step: 'true'
enable_azure_devops_step: 'false'
azure_devops_project_url: 'https://dev.azure.com/pagopaspa/devopslab-projects'
azure_devops_pipeline_name: 'devopslab-diego-deploy.deploy'
azure_devops_pat: ${{ secrets.AZUREDEVOPS_PAT }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
.terraform

charts*
Expand Down
19 changes: 19 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
54 changes: 39 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
#
# Build
#
FROM maven:3.8.4-jdk-11-slim as buildtime
# Build stage
FROM maven:3.9-amazoncorretto-21 AS builder

WORKDIR /build
COPY . .
RUN --mount=type=cache,target=/root/.m2 mvn clean package -DskipTests

RUN mvn clean package
# Runtime stage
FROM amazoncorretto:21-alpine3.20

#
# Docker RUNTIME
#
FROM adoptopenjdk/openjdk11:alpine-jre as runtime

VOLUME /tmp
WORKDIR /app

COPY --from=buildtime /build/target/*.jar /app/app.jar
# The agent is enabled at runtime via JAVA_TOOL_OPTIONS.
ADD https://github.com/microsoft/ApplicationInsights-Java/releases/download/3.2.7/applicationinsights-agent-3.2.7.jar /app/applicationinsights-agent.jar
# Add dependencies for security and monitoring
RUN apk add --no-cache \
curl \
tzdata \
&& addgroup -S javauser \
&& adduser -S javauser -G javauser

# Copy application bundle
COPY --from=builder /build/target/*.jar app.jar

# Add Application Insights agent
ADD --chmod=644 https://github.com/microsoft/ApplicationInsights-Java/releases/download/3.4.17/applicationinsights-agent-3.4.17.jar applicationinsights-agent.jar

# Configure permissions
RUN chown -R javauser:javauser /app
USER javauser

# Configure JVM options for containerized environment
ENV JAVA_TOOL_OPTIONS="-XX:MaxRAMPercentage=75.0 \
-XX:InitialRAMPercentage=50.0 \
-XX:+UseG1GC \
-Xlog:gc*:/app/gc.log \
-Djava.security.egd=file:/dev/./urandom \
-Duser.timezone=UTC"

# Application Insights configuration
ENV APPLICATIONINSIGHTS_CONNECTION_STRING=""
ENV APPLICATIONINSIGHTS_ROLE_NAME="devops-java-springboot-color"

# Configure container
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \
CMD curl -f http://localhost:8080/actuator/health || exit 1

ENTRYPOINT ["java","-jar","/app/app.jar"]
ENTRYPOINT ["java", "-javaagent:/app/applicationinsights-agent.jar", "-jar", "/app/app.jar"]
6 changes: 3 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
version: "3.8"
services:
devops-java-springboot-color:
# image: "ghcr.io/pagopa/devops-java-springboot-color:0.6.0"
# image: "ghcr.io/pagopa/devops-java-springboot-color:snapshot-upgrade-java-21"
build:
dockerfile: ./Dockerfile
context: .
container_name: devops-java-springboot-color
restart: always
environment:
- MY_APP_COLOR=red
# environment:
# - MY_APP_COLOR=red
ports:
- "8080:8080"
Loading

0 comments on commit 863b84f

Please sign in to comment.