Skip to content

Commit

Permalink
Implement JPA through Elide
Browse files Browse the repository at this point in the history
  • Loading branch information
QubitPi committed Sep 1, 2023
1 parent 73bb1e5 commit e1097b6
Show file tree
Hide file tree
Showing 22 changed files with 532 additions and 763 deletions.
28 changes: 28 additions & 0 deletions .github/actions/create-mvn-settings/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 'settings.xml'
description: 'Generate settings.xml for authenticating internal model package download'

inputs:
internal-maven-repo-server-id:
description: 'The server ID of Maven repo that contains the model package'
required: true
internal-maven-repo-user:
description: 'The accessing user of Maven repo that contains the model package'
required: true
internal-maven-repo-token:
description: 'The access token of Maven repo that contains the model package'
required: true

runs:
using: "composite"
steps:
- name: Authenticating internal model package download
uses: whelk-io/maven-settings-xml-action@v20
with:
servers: >
[
{
"id": "${{ inputs.internal-maven-repo-server-id }}",
"username": "${{ inputs.internal-maven-repo-user }}",
"password": "${{ inputs.internal-maven-repo-token }}"
}
]
48 changes: 11 additions & 37 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ name: Template CI/CD
push:
branches:
- master
- jpa-elide

env:
JDK_VERSION: 17
Expand Down Expand Up @@ -105,43 +106,6 @@ jobs:
user_name: ${{ env.USER }}
user_email: ${{ env.EMAIL }}

docker-image:
name: Build Test & Release Development Docker Image
needs: tests
runs-on: ubuntu-latest
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
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Test image build
uses: docker/build-push-action@v3
with:
context: .
push: false
- name: Login to DockerHub
if: github.ref == 'refs/heads/master'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push image to DockerHub
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/jersey-ws-template:latest

hashicorp:
name: Generated Webservice WAR in GitHub Action, and Publish Template AMI Image and Deploy it to EC2 through HashiCorp
if: ${{ github.event.repository.name != 'jersey-ws-template' }}
Expand All @@ -155,6 +119,16 @@ jobs:
with:
java-version: ${{ env.JDK_VERSION }}
distribution: ${{ env.JDK_DISTRIBUTION }}
- name: Generate Maven settings.xml
uses: ./.github/actions/create-mvn-settings
with:
internal-maven-repo-server-id: ${{ secrets.INTERNAL_MAVEN_REPO_SERVER_ID }}
internal-maven-repo-user: ${{ secrets.INTERNAL_MAVEN_REPO_USER }}
internal-maven-repo-token: ${{ secrets.INTERNAL_MAVEN_REPO_TOKEN }}
- name: Load webservice settings
run: |
echo "${{ secrets.APPLICATION_PROPERTIES }}" > src/main/resources/application.properties
echo "${{ secrets.JPADATASTORE_PROPERTIES }}" > src/main/resources/jpadatastore.properties
- name: Generate webservice WAR file
run: mvn -B clean package
- name: Load SSL Certificates into AMI
Expand Down
41 changes: 41 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright Jiaqi Liu
#
# 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.
version: "3.9"
services:
web:
build: .
ports:
- "8080:8080"
environment:
- MODEL_PACKAGE_NAME=${MODEL_PACKAGE_NAME}
- DB_USER=root
- DB_PASSWORD=root
- DB_DRIVER=com.mysql.jdbc.Driver
- DB_DIALECT=org.hibernate.dialect.MySQLDialect
- DB_URL=jdbc:mysql://db/elide?serverTimezone=UTC
depends_on:
db:
condition: service_healthy
db:
image: "mysql:5.7"
ports:
- "3306:3306"
volumes:
- "./mysql-init.sql:/docker-entrypoint-initdb.d/mysql-init.sql"
environment:
MYSQL_ROOT_PASSWORD: root
healthcheck:
test: mysqladmin ping -h localhost -u root -proot
timeout: 3s
retries: 3
16 changes: 16 additions & 0 deletions mysql-init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Copyright Jiaqi Liu
--
-- 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.

CREATE DATABASE IF NOT EXISTS elide;
USE elide;
Loading

0 comments on commit e1097b6

Please sign in to comment.