diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..5a40eb3e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,48 @@ +name: Test Application with Gradle + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + test-app-with-gradle: + runs-on: ubuntu-latest + + services: + note-postgres: + image: postgres:alpine + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: none + POSTGRES_DB: noteapp + ports: + - "5100:5432" + options: --name note-postgres + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + env: + SPRING_DATASOURCE_URL: jdbc:postgresql://localhost:5100/noteapp + POSTGRES_USER: postgres + POSTGRES_PASSWORD: none + POSTGRES_DB: noteapp + FRONTEND_URL: http://localhost:4200 + GOOGLE_CLIENT_ID: none + GOOGLE_CLIENT_SECRET: none + with: + gradle-version: '8.2' + arguments: build + build-root-directory: note-app-backend \ No newline at end of file diff --git a/corn-backend/Dockerfile b/corn-backend/Dockerfile index 56837ab3..2e63abd6 100644 --- a/corn-backend/Dockerfile +++ b/corn-backend/Dockerfile @@ -1,6 +1,6 @@ FROM gradle:8.2-jdk17-alpine -WORKDIR /home/note-app +WORKDIR /home/todo-app COPY build.gradle . @@ -8,6 +8,10 @@ COPY settings.gradle . COPY src/ src/ +RUN gradle build -x test + +RUN mv build/libs/todo-app-backend-0.0.1-SNAPSHOT.jar todo-app.jar + EXPOSE 8080 -ENTRYPOINT ["gradle", "bootRun"] +ENTRYPOINT ["java", "-jar", "todo-app.jar"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..7af66083 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,38 @@ +version: "3.1" + +services: + corn-postgres: + container_name: corn-postgres + image: postgres:alpine + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=none + - POSTGRES_DB=corn + ports: + - "5000:5432" + corn-backend: + container_name: corn-backend + image: corn-backend + depends_on: + - corn-postgres + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=none + - POSTGRES_DB=corn + - SPRING_DATASOURCE_URL=jdbc:postgresql://corn-postgres:5432/corn + - FRONTEND_URL=corn-frontend + build: + context: corn-app-backend + dockerfile: Dockerfile + ports: + - "8080:8080" + corn-frontend: + container_name: corn-frontend + image: corn-frontend + depends_on: + - corn-backend + build: + context: corn-app-frontend + dockerfile: Dockerfile + ports: + - "4200:80"