-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/oracle example #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f2e34fd
866b5bf
38f270c
1cd7aed
9ff8a69
c53d665
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,68 @@ | ||||||||||||||||||
| name: spring-oracle-example CI Build | ||||||||||||||||||
|
|
||||||||||||||||||
| on: | ||||||||||||||||||
| pull_request: | ||||||||||||||||||
| branches: [master] | ||||||||||||||||||
| paths: | ||||||||||||||||||
| - "spring-oracle-example/**" | ||||||||||||||||||
| types: | ||||||||||||||||||
| - opened | ||||||||||||||||||
| - synchronize | ||||||||||||||||||
| - reopened | ||||||||||||||||||
|
|
||||||||||||||||||
| jobs: | ||||||||||||||||||
|
|
||||||||||||||||||
| integration-tests: | ||||||||||||||||||
| name: Run Unit & Integration Tests | ||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||
| defaults: | ||||||||||||||||||
| run: | ||||||||||||||||||
| working-directory: spring-oracle-example | ||||||||||||||||||
| strategy: | ||||||||||||||||||
| matrix: | ||||||||||||||||||
| distribution: [ 'temurin' ] | ||||||||||||||||||
| java: [ '21' ] | ||||||||||||||||||
| steps: | ||||||||||||||||||
| - uses: actions/checkout@v5 | ||||||||||||||||||
| with: | ||||||||||||||||||
| fetch-depth: 0 | ||||||||||||||||||
|
|
||||||||||||||||||
| - name: Set up JDK ${{ matrix.java }} | ||||||||||||||||||
| uses: actions/setup-java@v5.0.0 | ||||||||||||||||||
| with: | ||||||||||||||||||
| java-version: ${{ matrix.java }} | ||||||||||||||||||
| distribution: ${{ matrix.distribution }} | ||||||||||||||||||
| cache: 'maven' | ||||||||||||||||||
| - name: Build and analyze | ||||||||||||||||||
| run: ./mvnw clean verify | ||||||||||||||||||
|
|
||||||||||||||||||
| health-check: | ||||||||||||||||||
| name: Health Check on Services | ||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||
| steps: | ||||||||||||||||||
| - name: Checkout repository and submodules | ||||||||||||||||||
| uses: actions/checkout@v5 | ||||||||||||||||||
| with: | ||||||||||||||||||
| submodules: true | ||||||||||||||||||
|
|
||||||||||||||||||
| - name: Extract service names from docker compose | ||||||||||||||||||
| id: services | ||||||||||||||||||
| run: | | ||||||||||||||||||
| echo "services<<EOF" >> $GITHUB_OUTPUT | ||||||||||||||||||
| docker compose -f ./spring-oracle-example/compose.yaml config --services >> $GITHUB_OUTPUT | ||||||||||||||||||
| echo "EOF" >> $GITHUB_OUTPUT | ||||||||||||||||||
|
Comment on lines
+50
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix shell script quoting issues in GitHub output. The shell script has several quoting issues that could cause problems with service names containing spaces or special characters. - name: Extract service names from docker compose
id: services
run: |
- echo "services<<EOF" >> $GITHUB_OUTPUT
- docker compose -f ./spring-oracle-example/compose.yaml config --services >> $GITHUB_OUTPUT
- echo "EOF" >> $GITHUB_OUTPUT
+ echo "services<<EOF" >> "$GITHUB_OUTPUT"
+ docker compose -f ./spring-oracle-example/compose.yaml config --services >> "$GITHUB_OUTPUT"
+ echo "EOF" >> "$GITHUB_OUTPUT"📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.7)50-50: shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects (shellcheck) 50-50: shellcheck reported issue in this script: SC2086:info:1:25: Double quote to prevent globbing and word splitting (shellcheck) 50-50: shellcheck reported issue in this script: SC2086:info:2:77: Double quote to prevent globbing and word splitting (shellcheck) 50-50: shellcheck reported issue in this script: SC2086:info:3:15: Double quote to prevent globbing and word splitting (shellcheck) |
||||||||||||||||||
|
|
||||||||||||||||||
| - name: Start containers with Compose Action | ||||||||||||||||||
| uses: hoverkraft-tech/compose-action@v2.3.0 | ||||||||||||||||||
| with: | ||||||||||||||||||
| compose-file: './spring-oracle-example/compose.yaml' | ||||||||||||||||||
| services: ${{ steps.services.outputs.services }} | ||||||||||||||||||
| up-flags: '--build' | ||||||||||||||||||
| down-flags: '--volumes' | ||||||||||||||||||
|
|
||||||||||||||||||
| - name: Wait for containers to initialize | ||||||||||||||||||
| run: sleep 30 | ||||||||||||||||||
|
Comment on lines
+63
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace fixed sleep with proper health checks. Using a fixed 30-second sleep is fragile and may fail if services take longer to start or waste time if they start quickly. Replace the sleep with a proper wait strategy: - - name: Wait for containers to initialize
- run: sleep 30
+ - name: Wait for services to be healthy
+ run: |
+ timeout 120 bash -c 'until docker compose -f ./spring-oracle-example/compose.yaml ps --format json | jq -e ".[].Health == \"healthy\"" > /dev/null 2>&1; do sleep 5; echo "Waiting for services..."; done'
+ echo "All services are healthy"Note: This requires healthchecks to be defined in the compose file as suggested earlier. Would you like me to create a more robust health check script? 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| - name: Check container health | ||||||||||||||||||
| run: | | ||||||||||||||||||
| ./.github/scripts/check-container-health.sh "${{ steps.services.outputs.services }}" | ||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Include any files or directories that you don't want to be copied to your | ||
| # container here (e.g., local build artifacts, temporary files, etc.). | ||
| # | ||
| # For more help, visit the .dockerignore file reference guide at | ||
| # https://docs.docker.com/go/build-context-dockerignore/ | ||
|
|
||
| **/.DS_Store | ||
| **/.classpath | ||
| **/.dockerignore | ||
| **/.env | ||
| **/.factorypath | ||
| **/.git | ||
| **/.gitignore | ||
| **/.idea | ||
| **/.project | ||
| **/.sts4-cache | ||
| **/.settings | ||
| **/.toolstarget | ||
| **/.vs | ||
| **/.vscode | ||
| **/.next | ||
| **/.cache | ||
| **/*.dbmdl | ||
| **/*.jfm | ||
| **/charts | ||
| **/docker-compose* | ||
| **/compose.y*ml | ||
| **/Dockerfile* | ||
| **/secrets.dev.yaml | ||
| **/values.dev.yaml | ||
| **/vendor | ||
| LICENSE | ||
| README.md | ||
| **/*.class | ||
| **/*.iml | ||
| **/*.ipr | ||
| **/*.iws | ||
| **/*.log | ||
| **/.apt_generated | ||
| **/.gradle | ||
| **/.gradletasknamecache | ||
| **/.nb-gradle | ||
| **/.springBeans | ||
| **/build | ||
| **/dist | ||
| **/gradle-app.setting | ||
| **/nbbuild | ||
| **/nbdist | ||
| **/nbproject/private | ||
| **/target | ||
| *.ctxt | ||
| .mtj.tmp | ||
| .mvn/timing.properties | ||
| buildNumber.properties | ||
| dependency-reduced-pom.xml | ||
| hs_err_pid* | ||
| pom.xml.next | ||
| pom.xml.releaseBackup | ||
| pom.xml.tag | ||
| pom.xml.versionsBackup | ||
| release.properties | ||
| replay_pid* |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| /mvnw text eol=lf | ||
| *.cmd text eol=crlf |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| name: CI Build | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - "**" | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| distribution: [ 'temurin' ] | ||
| java: [ '21' ] | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
|
|
||
| - name: Setup Java 21 | ||
| uses: actions/setup-java@v5 | ||
| with: | ||
| java-version: ${{ matrix.java }} | ||
| distribution: ${{ matrix.distribution }} | ||
| cache: 'maven' | ||
|
|
||
| - name: Grant execute permission for mvnw | ||
| run: chmod +x mvnw | ||
|
|
||
| - name: Build with Maven | ||
| run: ./mvnw clean verify |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| target/ | ||
| .mvn/wrapper/maven-wrapper.jar | ||
| !**/src/main/**/target/ | ||
| !**/src/test/**/target/ | ||
|
|
||
| ### STS ### | ||
| .apt_generated | ||
| .classpath | ||
| .factorypath | ||
| .project | ||
| .settings | ||
| .springBeans | ||
| .sts4-cache | ||
|
|
||
| ### IntelliJ IDEA ### | ||
| .idea | ||
| *.iws | ||
| *.iml | ||
| *.ipr | ||
|
|
||
| ### NetBeans ### | ||
| /nbproject/private/ | ||
| /nbbuild/ | ||
| /dist/ | ||
| /nbdist/ | ||
| /.nb-gradle/ | ||
| build/ | ||
| !**/src/main/**/build/ | ||
| !**/src/test/**/build/ | ||
|
|
||
| ### VS Code ### | ||
| .vscode/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| distributionType=only-script | ||
| distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| FROM eclipse-temurin:21-jdk-jammy as deps | ||
|
|
||
| WORKDIR /build | ||
|
|
||
| COPY --chmod=0755 mvnw mvnw | ||
| COPY .mvn/ .mvn/ | ||
|
|
||
| RUN --mount=type=bind,source=pom.xml,target=pom.xml \ | ||
| --mount=type=cache,target=/root/.m2 ./mvnw dependency:go-offline -DskipTests | ||
|
|
||
| FROM deps as package | ||
|
|
||
| WORKDIR /build | ||
|
|
||
| COPY ./src src/ | ||
| RUN --mount=type=bind,source=pom.xml,target=pom.xml \ | ||
| --mount=type=cache,target=/root/.m2 \ | ||
| ./mvnw package -DskipTests && \ | ||
| mv target/$(./mvnw help:evaluate -Dexpression=project.artifactId -q -DforceStdout)-$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout).jar target/app.jar | ||
|
|
||
| FROM package as extract | ||
|
|
||
| WORKDIR /build | ||
|
|
||
| RUN java -Djarmode=layertools -jar target/app.jar extract --destination target/extracted | ||
|
|
||
| FROM eclipse-temurin:21-jre-jammy AS final | ||
|
|
||
| ARG UID=10001 | ||
|
|
||
| COPY --from=extract build/target/extracted/dependencies/ ./ | ||
| COPY --from=extract build/target/extracted/spring-boot-loader/ ./ | ||
| COPY --from=extract build/target/extracted/snapshot-dependencies/ ./ | ||
| COPY --from=extract build/target/extracted/application/ ./ | ||
|
|
||
| COPY docker/java/entrypoint.sh /entrypoint.sh | ||
| RUN chmod +x /entrypoint.sh | ||
|
|
||
| EXPOSE 8080 | ||
|
|
||
| ENTRYPOINT ["/entrypoint.sh"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # spring-oracle-example | ||
|
|
||
| This project is a simple demonstration of connecting to an Oracle database using Docker. | ||
|
|
||
| It showcases: | ||
|
|
||
| - Running an Oracle Database container (XE 21c). | ||
| - Basic demonstration of database connectivity from a client or Java application. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| services: | ||
|
|
||
| app: | ||
| container_name: app | ||
| build: | ||
| context: . | ||
| depends_on: | ||
| - oracle-db | ||
| environment: | ||
| SPRING_PROFILES_ACTIVE: default | ||
| SERVER_PORT: 8080 | ||
| SPRING_DATASOURCE_URL: jdbc:oracle:thin:@oracle-db:1521/XEPDB1 | ||
| SPRING_DATASOURCE_USERNAME: TEST_SCHEMA | ||
| SPRING_DATASOURCE_PASSWORD: Ag101Pwd123 | ||
| SPRING_DATASOURCE_DRIVER: oracle.jdbc.OracleDriver | ||
| SPRING_JPA_HIBERNATE_DDL_AUTO: update | ||
| SPRING_JPA_SHOW_SQL: true | ||
| SPRING_HIBERNATE_DIALECT: org.hibernate.dialect.OracleDialect | ||
| ports: | ||
| - "8080:8080" | ||
|
|
||
| oracle-db: | ||
| container_name: oracle-db | ||
| image: gvenzl/oracle-xe:21-slim | ||
| ports: | ||
| - "1521:1521" | ||
| environment: | ||
| ORACLE_PASSWORD: "Admin123" | ||
| shm_size: 1g | ||
| volumes: | ||
| - ./docker/oracle:/docker-entrypoint-initdb.d |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #!/bin/sh | ||
| # entrypoint.sh | ||
|
|
||
| echo "Aguardando 30 segundos..." | ||
| sleep 30 | ||
|
|
||
| echo "Iniciando a aplicação..." | ||
| exec java org.springframework.boot.loader.launch.JarLauncher |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| ALTER SESSION SET CONTAINER = XEPDB1; | ||
| CREATE USER TEST_SCHEMA IDENTIFIED BY Ag101Pwd123; | ||
| GRANT CREATE SESSION TO TEST_SCHEMA; | ||
| GRANT CONNECT, RESOURCE TO TEST_SCHEMA; | ||
| ALTER USER TEST_SCHEMA QUOTA UNLIMITED ON USERS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick
Fix formatting: remove excessive spaces inside brackets.
Consistent with the other workflow, fix the bracket spacing.
📝 Committable suggestion
🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 23-23: too many spaces inside brackets
(brackets)
[error] 23-23: too many spaces inside brackets
(brackets)
[error] 24-24: too many spaces inside brackets
(brackets)
[error] 24-24: too many spaces inside brackets
(brackets)
🤖 Prompt for AI Agents