diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 5cc60397..1a66078d 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -21,7 +21,7 @@ name: Template CI/CD - master env: - JDK_VERSION: 11 + JDK_VERSION: 17 JDK_DISTRIBUTION: 'adopt' USER: QubitPi EMAIL: jack20220723@gmail.com @@ -39,18 +39,18 @@ jobs: steps: - uses: actions/checkout@v3 - uses: actionshub/markdownlint@main -# markdown-link-check: -# name: Markdown Link Check -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v3 -# - uses: gaurav-nelson/github-action-markdown-link-check@v1 -# with: -# use-verbose-mode: "yes" + markdown-link-check: + name: Markdown Link Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: gaurav-nelson/github-action-markdown-link-check@v1 + with: + use-verbose-mode: "yes" tests: name: Unit & Integration Tests - needs: [yaml-lint, markdown-lint] + needs: [yaml-lint, markdown-lint, markdown-link-check] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -77,10 +77,6 @@ jobs: restore-keys: ${{ runner.os }}-m2 - name: Run unit & integration tests run: mvn -B clean verify - - name: Set up JDK 17 for Sonar Scan - uses: actions/setup-java@v1 - with: - java-version: 17 - name: Sonar Scan env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -128,6 +124,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + - name: Set up JDK ${{ env.JDK_VERSION }} + uses: actions/setup-java@v3 + with: + java-version: ${{ env.JDK_VERSION }} + distribution: ${{ env.JDK_DISTRIBUTION }} - name: Build App WAR file so that Docker can pickup during image build run: mvn clean package - name: Set up QEMU @@ -155,7 +156,6 @@ jobs: hashicorp: name: Publish Jersey WS AMI Image and Deploy it to EC2 through HashiCorp - if: ${{ github.event.repository.name != 'astraios' }} needs: tests runs-on: ubuntu-latest defaults: diff --git a/Dockerfile b/Dockerfile index 42c9a24d..db6bca72 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ # 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. -FROM jetty:11.0.14-jdk11 +FROM jetty:jdk17 LABEL maintainer="Jiaqi (Jack) Liu" LABEL maintainer-email="jack20220723@gmail.com" diff --git a/docs/docs/development.md b/docs/docs/development.md index 9cf94b73..20792c6d 100644 --- a/docs/docs/development.md +++ b/docs/docs/development.md @@ -96,8 +96,16 @@ Running Webservice in Standalone Jetty (Production) ### Download Jetty -At [download page](https://www.eclipse.org/jetty/download.php), pick up a `.tgz` distribution. Since this template -requires Java 11+, we will use "11.0.15" release as an example: +At [download page](https://www.eclipse.org/jetty/download.php), pick up a `.tgz` distribution. **It is very important +to pick up Jetty server version that matches JDK version**. For JDK **17**, it's been tested that Jetty _11.0.15_ works + +:::note + +During testing, the embedded Jetty version is also 11.0.15 + +::: + +Hence, we will use "11.0.15" release as an example: ![Error loading download-jetty.png](./img/download-jetty.png) @@ -134,7 +142,7 @@ Lastly, drop the [WAR file](#packaging) into **/path/to/jetty-base/webapps** dir mv /path/to/war-file /path/to/jetty-base/webapps/ROOT.war ``` -### Running Jersey Template Webservice +### Running Astraios ```bash java -jar $JETTY_HOME/start.jar diff --git a/docs/docs/img/download-jetty.png b/docs/docs/img/download-jetty.png index d40ccc68..63289bfa 100644 Binary files a/docs/docs/img/download-jetty.png and b/docs/docs/img/download-jetty.png differ diff --git a/docs/docs/setup.md b/docs/docs/setup.md index 9fd34182..0d5be58c 100644 --- a/docs/docs/setup.md +++ b/docs/docs/setup.md @@ -10,21 +10,37 @@ Prepare for Local Development ```bash brew update -brew install java11 -sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk -brew install maven +brew install openjdk@17 ``` +At the end of the last command prompt, something like the below will show up: + +```bash +For the system Java wrappers to find this JDK, symlink it with + sudo ln -sfn ...openjdk@17/libexec/openjdk.jdk .../JavaVirtualMachines/openjdk-17.jdk + +openjdk@17 is keg-only, which means it was not symlinked into /usr/local, +because this is an alternate version of another formula. + +If you need to have openjdk@17 first in your PATH, run: + echo 'export PATH=".../openjdk@17/bin:$PATH"' >> .../.bash_profile + +For compilers to find openjdk@17 you may need to set: + export CPPFLAGS="-I.../openjdk@17/include" +``` + +Make sure to execute the `sudo ln -sfn`, `echo 'export PATH=...`, and the `export CPPFLAGS=` commands above + :::tip -Maven uses a separate JDK version, which can be seen via `mvn -v`. If it's not JDK 11, we should have Maven point -to our JDK 11 using [JAVA_HOME](https://stackoverflow.com/a/2503679): +Maven uses a separate JDK version, which can be seen via `mvn -v`. If it's not JDK 17, we should have Maven point +to our JDK 17 using [JAVA_HOME](https://stackoverflow.com/a/2503679): ```bash $ /usr/libexec/java_home -/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home +/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home -$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home +$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home ``` ::: @@ -33,9 +49,9 @@ If we see something similar after typing the command with the version flag below ```bash $ java --version -openjdk 11.0.10 2021-01-19 -OpenJDK Runtime Environment (build 11.0.10+9) -OpenJDK 64-Bit Server VM (build 11.0.10+9, mixed mode) +openjdk 17.0.10 2021-01-19 +OpenJDK Runtime Environment (build 17.0.10+9) +OpenJDK 64-Bit Server VM (build 17.0.10+9, mixed mode) ``` ### Installing Docker Engine @@ -64,9 +80,9 @@ Modifying Templates - Update [endpoint package] accordingly -[Docker-based integration tests]: https://github.com/paion-data/astraios/blob/master/src/test/groovy/com/paiondata/ws/jersey/template/DataServletITSpec.groovy +[Docker-based integration tests]: https://github.com/paion-data/astraios/blob/master/src/test/groovy/com/paiondata/astraios/DataServletITSpec.groovy -[endpoint package]: https://github.com/paion-data/astraios/blob/master/src/main/java/com/paiondata/ws/jersey/template/application/ResourceConfig.java +[endpoint package]: https://github.com/paion-data/astraios/blob/master/src/main/java/com/paiondata/astraios/application/ResourceConfig.java [astraios]: https://github.com/paion-data/astraios [astraios Dockerfile]: https://github.com/paion-data/astraios/blob/master/Dockerfile diff --git a/hashicorp/instances/main.tf b/hashicorp/instances/main.tf index e85f216b..f305a9fe 100644 --- a/hashicorp/instances/main.tf +++ b/hashicorp/instances/main.tf @@ -64,7 +64,7 @@ resource "aws_instance" "astraios" { tags = { Name = "ES2 Instance Name" } - security_groups = ["Security Group Name"] + security_groups = ["Paion Data Astraios"] user_data = <<-EOF #!/bin/bash diff --git a/hashicorp/scripts/setup.sh b/hashicorp/scripts/setup.sh index 4a623503..ad6ca75e 100644 --- a/hashicorp/scripts/setup.sh +++ b/hashicorp/scripts/setup.sh @@ -18,10 +18,9 @@ set -x sudo apt update && sudo apt upgrade -y sudo apt install software-properties-common -y -# Install JDK 11 - https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-20-04#installing-the-default-jre-jdk +# Install JDK 17 - https://www.rosehosting.com/blog/how-to-install-java-17-lts-on-ubuntu-20-04/ sudo apt update -sudo apt install default-jre -y -sudo apt install default-jdk -y +sudo apt install openjdk-17-jdk openjdk-17-jre # Install Maven sudo apt install maven -y @@ -32,11 +31,12 @@ cd REPO mvn clean package -Dmaven.test.skip cd ../ -# Install and configure Jetty (version 11) container -wget https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/11.0.15/jetty-home-11.0.15.tar.gz -tar -xzvf jetty-home-11.0.15.tar.gz -rm jetty-home-11.0.15.tar.gz -export JETTY_HOME=/home/ubuntu/jetty-home-11.0.15 +# Install and configure Jetty (version 17) container +JETTY_VERSION=11.0.15 +wget https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/$JETTY_VERSION/jetty-home-$JETTY_VERSION.tar.gz +tar -xzvf jetty-home-$JETTY_VERSION.tar.gz +rm jetty-home-$JETTY_VERSION.tar.gz +export JETTY_HOME=/home/ubuntu/jetty-home-$JETTY_VERSION mkdir jetty-base cd jetty-base java -jar $JETTY_HOME/start.jar --add-module=annotations,server,http,deploy diff --git a/pom.xml b/pom.xml index 7b6376f9..723a5337 100644 --- a/pom.xml +++ b/pom.xml @@ -33,8 +33,8 @@ https://sonarcloud.io UTF-8 - 11 - 11 + 17 + 17 3.0.1 1.0 @@ -45,7 +45,7 @@ 6.0.0 3.1.1 4.0.6 - 11.0.14 + 11.0.15 3.2.2 3.5.0 @@ -82,6 +82,13 @@ pom import + + org.eclipse.jetty + jetty-bom + ${version.jetty} + pom + import + @@ -193,6 +200,11 @@ logback-classic ${version.logback} + + io.sentry + sentry-logback + 6.25.2 + @@ -221,13 +233,16 @@ org.eclipse.jetty jetty-server - ${version.jetty} test org.eclipse.jetty jetty-webapp - ${version.jetty} + test + + + org.eclipse.jetty + jetty-servlet test @@ -259,7 +274,7 @@ - + org.apache.maven.plugins maven-compiler-plugin @@ -337,27 +352,6 @@ - - - org.codehaus.mojo - codenarc-maven-plugin - 0.22-1 - - ${project.basedir} - 0 - 0 - 0 - - - - prepare-package - - codenarc - - - - - org.apache.maven.plugins @@ -425,7 +419,7 @@ org.jacoco jacoco-maven-plugin - 0.8.6 + 0.8.8