dockerfile: java/Dockerfile #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Continuous Integration | |
on: [push, pull_request] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:15 | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_DB: postgres | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: YOU_MUST_CHANGE_THIS_PASSWORD | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'corretto' | |
java-version: '17' | |
- name: Start Tomcat | |
run: | | |
docker run -d --network=host --name tomcat tomcat:latest | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
with: | |
gradle-version: release-candidate | |
- name: Create database table | |
run: | | |
psql -h localhost -U postgres -d postgres -f ./java/app/src/main/java/org/vss/impl/postgres/sql/v0_create_vss_db.sql | |
env: | |
PGPASSWORD: YOU_MUST_CHANGE_THIS_PASSWORD | |
- name: Build and Deploy | |
run: | | |
# Print Info | |
java -version | |
gradle --version | |
cd java | |
gradle wrapper --gradle-version 8.1.1 | |
./gradlew --version | |
./gradlew build | |
docker cp app/build/libs/vss-1.0.war tomcat:/usr/local/tomcat/webapps/vss.war | |
- name: Hit endpoint to verify service is up | |
run: | | |
# Wait for tomcat-startup | |
sleep 5 | |
# Put request with store='storeId' and key=k1 | |
hex=0A0773746F726549641A150A026B3110FFFFFFFFFFFFFFFFFF011A046B317631 | |
curl --data-binary "$(echo "$hex" | xxd -r -p)" http://localhost:8080/vss/putObjects | |
# Get request with store='storeId' and key=k1 | |
hex=0A0773746F7265496412026B31 | |
curl --data-binary "$(echo "$hex" | xxd -r -p)" http://localhost:8080/vss/getObject | |
- name: Cleanup | |
run: | | |
docker stop tomcat && docker rm tomcat |