Skip to content

Commit

Permalink
Feat/63 update java apis to build native image (#146)
Browse files Browse the repository at this point in the history
* feat: enable oracle-api to build cloud native image

About issue #63

* feat: add cloud native support for backend

* feat: flyway log4j configuration for cloud native

About issue #63

* ci: adjust workflows for cloud native - partial

Also related to issue #63

* feat: fix healthchecks and oracle cert password

* fix: native images name when building

* feat: removing all oracle-api related changes to another pr

* fix: frontend healthcheck in dockerfile

* feat: replate all tabs by space on backend pom.xml file

---------

Co-authored-by: Derek Roberts <derek.roberts@gmail.com>
  • Loading branch information
RMCampos and DerekRoberts committed May 14, 2024
1 parent e0e9c78 commit b8f8148
Show file tree
Hide file tree
Showing 7 changed files with 506 additions and 381 deletions.
43 changes: 40 additions & 3 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,53 @@ jobs:
-p ORACLE_DB_PASSWORD='${{ secrets.DB_PASSWORD }}'
-p FORESTCLIENTAPI_KEY='${{ secrets.FORESTCLIENTAPI_KEY }}'

cloud-native-builds:
permissions:
contents: read
packages: write
strategy:
matrix:
package: [backend]
name: Cloud Native Builds (${{ matrix.package }})
runs-on: ubuntu-22.04
env:
COMPONENT: ${{ matrix.package }}
ZONE: ${{ github.event.number }}
NAME: ghcr.io/${{ github.repository }}/${{ matrix.package }}:${{ github.event.number }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: graalvm/setup-graalvm@v1
with:
version: "22.3.0"
java-version: "17"
components: "native-image"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Native Image
run: |
cd ${{ matrix.package }}
chmod +x ./mvnw
./mvnw -Pnative clean spring-boot:build-image \
-Dspring-boot.build-image.imageName="${{ env.NAME }}" \
-Doci.revision=${{ github.event.number }} --quiet
- name: Log in to the Container registry
uses: docker/login-action@v2.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pushing
run: docker push ${{ env.NAME }}

builds:
name: Builds
runs-on: ubuntu-22.04
permissions:
packages: write
strategy:
matrix:
package: [backend, database, frontend, oracle-api]
package: [database, frontend, oracle-api]
include:
- package: backend
triggers: ('backend/')
- package: database
triggers: ('database/')
- package: frontend
Expand All @@ -79,6 +115,7 @@ jobs:
deploys:
name: Deploys
needs:
- cloud-native-builds
- builds
- init
runs-on: ubuntu-22.04
Expand Down
16 changes: 16 additions & 0 deletions backend/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@ cd database
docker-compose up --build
```

## Building Cloud Native Image

You can build the image with:

```sh
./mvnw -Pnative clean spring-boot:build-image -Dspring-boot.build-image.imageName="nr-spar-backend"
```

And then, run it with:
```sh
docker run -d \
--name backend-native \
--env-file ./backend/.env \
nr-spar-backend
```

## Run tests

For unit tests, please use this command:
Expand Down
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ COPY dockerfile-entrypoint.sh /usr/share/service/dockerfile-entrypoint.sh

EXPOSE 8090
USER 1001
HEALTHCHECK --interval=35s --timeout=4s CMD curl -f http://localhost:8090/actuator/health | grep '"status":"UP"'
HEALTHCHECK --interval=35s --timeout=4s CMD wget --no-verbose --tries=1 --spider http://localhost:8090/actuator/health
ENTRYPOINT ["/usr/share/service/dockerfile-entrypoint.sh"]
Loading

0 comments on commit b8f8148

Please sign in to comment.