Skip to content

Commit 05b6878

Browse files
authored
Feature/pi 748 split build process (#51)
* prepare split for possible portal * update environments * fix frontend build * add missing nginx config * ignore cors for now * update readme
1 parent ff06216 commit 05b6878

File tree

19 files changed

+312
-155
lines changed

19 files changed

+312
-155
lines changed

.github/workflows/continious_integration.yml

Lines changed: 81 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ on:
66
# - reopened
77
# - review_requested
88
push:
9-
branches: [ "develop", "main" ]
9+
branches: [ "develop", "main", "feature/PI-748_split_build_process" ]
1010
workflow_dispatch:
1111
env:
1212
REGISTRY: ghcr.io
1313
REGISTRY_NAMESPACE: possible-x
1414
K8S_NAMESPACE: ${{ github.ref == 'refs/heads/main' && 'mvd-001-demo' || 'edc-dev' }}
1515
jobs:
16-
build-and-push-image:
16+
build-and-push-backend:
1717
runs-on: ubuntu-latest
1818
permissions:
1919
contents: read
@@ -22,13 +22,13 @@ jobs:
2222
steps:
2323
- name: Checkout repository
2424
uses: actions/checkout@v3
25-
25+
2626
- name: Set current date as env variable
2727
run: echo "VERSION_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
2828

2929
- name: Set current short hash as env variable
3030
run: echo "VERSION_NO=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
31-
31+
3232
- name: Log in to the Container registry
3333
uses: docker/login-action@v2
3434
with:
@@ -41,33 +41,96 @@ jobs:
4141
with:
4242
buildkitd-flags: --debug
4343

44-
- name: Docker meta
45-
id: meta
44+
- name: Docker "backend" meta
45+
id: backend-meta
4646
uses: docker/metadata-action@v4
4747
with:
48-
images: ${{ env.REGISTRY }}/${{ env.REGISTRY_NAMESPACE }}/edc-portal
48+
images: ${{ env.REGISTRY }}/${{ env.REGISTRY_NAMESPACE }}/backend
4949
tags: |
5050
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main'}}
5151
type=raw,value=latest-${{github.ref_name }},enable=${{ github.ref != 'refs/heads/main'}}
5252
${{ github.sha }}
53-
54-
- name: Build and push
55-
id: build_and_push
53+
- name: Build and push "backend"
54+
id: build_and_push_backend
5655
uses: docker/build-push-action@v6
5756
with:
5857
context: .
5958
file: ./backend/Dockerfile
6059
push: true
61-
tags: ${{ steps.meta.outputs.tags }}
62-
labels: ${{ steps.meta.outputs.labels }}
60+
tags: ${{ steps.backend-meta.outputs.tags }}
61+
labels: ${{ steps.backend-meta.outputs.labels }}
6362
build-args: |
6463
VERSION_NO=${{ env.VERSION_NO }}
6564
VERSION_DATE=${{ env.VERSION_DATE }}
6665
67-
- name: 'Auto-deploy to dev'
68-
if: github.ref == 'refs/heads/develop'
69-
uses: actions-hub/[email protected]
70-
env:
71-
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
66+
build-and-push-frontend:
67+
runs-on: ubuntu-latest
68+
permissions:
69+
contents: read
70+
packages: write
71+
72+
steps:
73+
- name: Checkout repository
74+
uses: actions/checkout@v3
75+
76+
77+
- name: Log in to the Container registry
78+
uses: docker/login-action@v2
79+
with:
80+
registry: ${{ env.REGISTRY }}
81+
username: ${{ github.actor }}
82+
password: ${{ secrets.GITHUB_TOKEN }}
83+
84+
- name: Set up Docker Buildx
85+
uses: docker/setup-buildx-action@v2
86+
with:
87+
buildkitd-flags: --debug
88+
89+
- name: Docker "frontend" meta
90+
id: frontend-meta
91+
uses: docker/metadata-action@v4
92+
with:
93+
images: ${{ env.REGISTRY }}/${{ env.REGISTRY_NAMESPACE }}/frontend
94+
tags: |
95+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main'}}
96+
type=raw,value=latest-${{github.ref_name }},enable=${{ github.ref != 'refs/heads/main'}}
97+
${{ github.sha }}
98+
99+
- name: Build and push "frontend"
100+
id: build_and_push_frontend
101+
uses: docker/build-push-action@v6
72102
with:
73-
args: "set image deployment/possible-x-portal -n ${{ env.K8S_NAMESPACE }} possible-x-portal=${{ env.REGISTRY }}/${{ env.REGISTRY_NAMESPACE }}/edc-portal:${{ github.sha }}"
103+
context: ./frontend/
104+
file: ./frontend/Dockerfile
105+
push: true
106+
tags: ${{ steps.frontend-meta.outputs.tags }}
107+
labels: ${{ steps.frontend-meta.outputs.labels }}
108+
build-args: |
109+
ACTIVEPROFILE="remote"
110+
111+
deploy-portal-to-dev:
112+
runs-on: 'ubuntu-latest'
113+
needs: [ build-and-push-backend,build-and-push-frontend ]
114+
steps:
115+
#- name: Checkout repository
116+
# uses: actions/checkout@v3
117+
118+
#- name: "Update Deployment Image Tag" # [3]
119+
# working-directory: "./deployment/kustomize/overlays/"
120+
# run: |
121+
# kustomize edit set image "frontend-image=*:${{ github.sha }}" "backend-image=*:${{ github.sha }}"
122+
123+
#- name: 'install Portal to DEV'
124+
# uses: actions-hub/[email protected]
125+
# env:
126+
# KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
127+
# with:
128+
# args: "apply -k ./deployment/kustomize/overlays/"
129+
130+
#- name: 'Auto-deploy to dev'
131+
# if: github.ref == 'refs/heads/develop'
132+
# uses: actions-hub/[email protected]
133+
# env:
134+
# KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
135+
# with:
136+
# args: "set image deployment/possible-x-portal -n ${{ env.K8S_NAMESPACE }} possible-x-portal=${{ env.REGISTRY }}/${{ env.REGISTRY_NAMESPACE }}/edc-portal:${{ github.sha }}"

README.md

Lines changed: 74 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
The POSSIBLE-X Portal is the centralized landing page for interacting with the POSSIBLE-X Dataspace.
44

55
It consists of three different parts:
6+
67
* The main page which is the landing page and links to other pages.
78
* The registration page for registering new participants.
89
* An administrative page to manage registration requests.
@@ -18,6 +19,7 @@ The repository is structured as a Gradle multi-project build.
1819
(...)
1920
├── libs.versions.toml # configuration file of version catalog for dependencies
2021
├── settings.gradle.kts # root project settings
22+
├── build.gradle.kts # root build file
2123
├── buildSrc/ # shared build configuration
2224
├── frontend/ # Angular frontend code for the GUI
2325
│ └── build.gradle.kts # build file for the Angular frontend
@@ -40,42 +42,102 @@ Afterwards they can be found at
4042
frontend/src/app/services/mgnt/api/backend.ts
4143
```
4244

43-
## Build
45+
## Build Backend
4446

45-
If you only want to build the project, you can run
47+
If you only want to build the backend, you can run
4648

4749
```
48-
./gradlew build
50+
./gradlew buildBackend
4951
```
5052

5153
after which the built jar can be found at `backend/build/libs/backend-x.y.z.jar`
5254

53-
## Run Portal Backend (currently including frontend)
55+
## Run Backend
5456

5557
Through gradle:
5658

5759
```
58-
./gradlew bootRun
60+
./gradlew startBackend
61+
```
62+
63+
Running a specific configuration:
64+
65+
E.g. for local portal:
66+
67+
```
68+
./gradlew startBackend -PactiveProfile=local
5969
```
6070

6171
Alternatively running the jar directly (if built previously):
6272

6373
```
64-
java -jar backend/build/libs/backend-x.y.z.jar
74+
java -jar backend/build/libs/backend-x.y.z.jar --spring.profiles.active=-local
6575
```
6676

67-
Once the service is running, you can access it at e.g. http://localhost:8088/ (depending on the used configuration).
77+
Once the service is running, you can access it at http://localhost:8088/.
6878

6979
The OpenAPI documentation can be found at http://localhost:8088/swagger-ui.html .
7080

71-
## Run Portal Frontend
81+
## Build Frontend
82+
83+
If you only want to build the frontend, you can run
84+
85+
```
86+
./gradlew buildFrontend
87+
```
88+
89+
after which the built frontend can be found at `frontend/build/resources/`.
90+
91+
## Run Frontend
92+
93+
Through gradle:
94+
95+
```
96+
./gradlew startFrontend
97+
```
98+
99+
Running a specific configuration:
100+
101+
E.g. for local portal:
72102

73-
Consumer (local testing):
103+
```
104+
./gradlew startFrontend -PactiveProfile=local
105+
```
106+
107+
Alternatively running with npm directly:
108+
109+
```
110+
npm --prefix frontend/ run ng -- serve --configuration local --port 4208
111+
```
112+
113+
Once the service is running, you can access it at http://localhost:4208/.
114+
115+
## Run Full Application (Frontend and Backend)
116+
117+
In addition to running the frontend and backend individually, there is also a gradle task for running both in parallel.
118+
Note that when the app is started through this task, the IntelliJ debugger will not be able to attach to the backend and
119+
hence won't stop at breakpoints.
120+
Through gradle:
74121

75122
```
76-
cd frontend/
77-
npm start
123+
./gradlew startFull
78124
```
79125

80-
Once the service is running, you can access it at e.g. http://localhost:4300/ (depending on the used configuration).
126+
Running a specific configuration:
127+
128+
E.g. for local portal:
129+
130+
```
131+
./gradlew startFull -PactiveProfile=local
132+
```
133+
134+
## Killing orphaned processes
135+
136+
If for any reason the application is not shut down properly, the following command can be used to kill a service that is
137+
running on the specified port:
138+
139+
```
140+
sudo fuser -k 8088/tcp
141+
```
81142

143+
where 8088 can be replaced with any other port.

backend/Dockerfile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
FROM gradle:8.9.0-jdk17 AS build
22
COPY --chown=gradle:gradle . /home/gradle/src
3-
4-
RUN apt-get update && \
5-
apt-get -y upgrade && \
6-
apt-get install -yq curl libgconf-2-4 gnupg wget
7-
RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
8-
RUN echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb stable main' >> /etc/apt/sources.list.d/google-chrome.list
9-
RUN apt-get update && apt-get install -y --no-install-recommends google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst
103
WORKDIR /home/gradle/src
11-
RUN gradle build -PnpmEnv=dev --no-daemon
4+
RUN gradle buildBackend --no-daemon
125

136
FROM openjdk:17-jdk-slim
147

15-
EXPOSE 8088
8+
EXPOSE 8080
169

1710
RUN mkdir /app
1811

1912
COPY --from=build /home/gradle/src/backend/build/libs/*.jar /app/backend.jar
13+
2014
ARG VERSION_NO="unknown"
2115
ENV VERSION_NO=$VERSION_NO
2216
ARG VERSION_DATE="unknown"

backend/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ from the central DAPS server for the new dataspace participant.
1111
If you only want to build the project, you can go to the root of the repository and run
1212

1313
```
14-
./gradlew build
14+
./gradlew buildBackend
1515
```
1616

1717
after which the built jar can be found at `backend/build/libs/backend-x.y.z.jar`.
@@ -20,6 +20,7 @@ after which the built jar can be found at `backend/build/libs/backend-x.y.z.jar`
2020

2121
The following environment variables can be set as needed.
2222
Replace the right hand side with the actual values.
23+
2324
```
2425
export SDCREATIONWIZARDAPI_BASEURL="SD Creation Wizard API base URL"
2526
export DAPSSERVER_BASEURL="DAPS Server base URL"
@@ -31,7 +32,7 @@ export SPRING_DATASOURCE_PASSWORD="Datasource Password"
3132
Through gradle:
3233

3334
```
34-
./gradlew bootRun
35+
./gradlew startBackend
3536
```
3637

3738
Alternatively running the jar directly (if built previously):

backend/build.gradle.kts

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,31 +70,24 @@ tasks.getByName<Jar>("jar") {
7070
enabled = false
7171
}
7272

73-
tasks.register<Copy>("copyWebApp") {
74-
outputs.upToDateWhen { false }
75-
description = "Copies the GUI into the resources of the Spring project."
76-
group = "Application"
77-
from("$rootDir/frontend/build/resources")
78-
into(layout.buildDirectory.dir("resources/main/static/."))
73+
tasks.register("buildBackend") {
74+
dependsOn(":backend:build")
75+
description = "Builds the backend application."
76+
group = "build"
7977
}
8078

81-
tasks.named("compileJava") {
82-
if (!project.hasProperty("backendOnly")) { // skip frontend if user wants only backend
83-
println("Hint: You can skip frontend build with '-PbackendOnly'")
84-
dependsOn(":frontend:npmTestConditional")
85-
}
86-
else {
87-
println("skipping frontend")
88-
}
89-
}
9079

91-
tasks.named("processResources") {
92-
if (!project.hasProperty("backendOnly")) { // skip frontend if user wants only backend
93-
dependsOn("copyWebApp")
94-
}
95-
else {
96-
println("skipping frontend")
80+
tasks.register<JavaExec>("startBackend") {
81+
dependsOn("bootJar")
82+
description = "Runs the backend application."
83+
group = "application"
84+
mainClass.set("eu.possiblex.portal.PortalApplication")
85+
classpath = sourceSets["main"].runtimeClasspath
86+
val activeProfile = project.findProperty("activeProfile")?.toString()
87+
if (activeProfile != null) {
88+
systemProperty("spring.profiles.active", activeProfile)
9789
}
90+
9891
}
9992

10093
tasks {

backend/src/main/java/eu/possiblex/portal/application/boundary/CommonPortalRestApiImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
import eu.possiblex.portal.application.entity.VersionTO;
44
import lombok.extern.slf4j.Slf4j;
55
import org.springframework.beans.factory.annotation.Value;
6+
import org.springframework.web.bind.annotation.CrossOrigin;
67
import org.springframework.web.bind.annotation.RestController;
78

89
@RestController
10+
@CrossOrigin("*") // TODO replace this with proper CORS configuration
911
@Slf4j
1012
public class CommonPortalRestApiImpl implements CommonPortalRestApi {
1113

@@ -17,6 +19,7 @@ public class CommonPortalRestApiImpl implements CommonPortalRestApi {
1719

1820
@Override
1921
public VersionTO getVersion() {
22+
2023
return new VersionTO(version, versionDate);
2124
}
2225
}

0 commit comments

Comments
 (0)