Skip to content
This repository was archived by the owner on Mar 7, 2024. It is now read-only.

Commit

Permalink
ci: combine backend and frontend in one application
Browse files Browse the repository at this point in the history
  • Loading branch information
Yalz committed Sep 27, 2023
1 parent cabbfbb commit 975b620
Show file tree
Hide file tree
Showing 77 changed files with 168 additions and 227 deletions.
44 changes: 5 additions & 39 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,7 @@ env:
REGISTRY: ghcr.io

jobs:
Front-End:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: |
image=moby/buildkit:v0.10.6
- name: Log in to the GitHub Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: Informatievlaanderen
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/Informatievlaanderen/vsds-demonstrator-ui
tags: |
type=raw,value={{date 'YYYYMMDDHHmmss'}}
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: ./vue-frontend
push: true
file: ./vue-frontend/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64

Back-end:
demonstrator:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -55,7 +21,7 @@ jobs:
- name: Build and analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -f ./spring-boot-backend/pom.xml -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=informatievlaanderen_vsds-demonstrator -Pcoverage
run: mvn -f ./pom.xml -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=informatievlaanderen_vsds-demonstrator -Pcoverage
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
Expand All @@ -73,15 +39,15 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/Informatievlaanderen/vsds-demonstrator-server
images: ${{ env.REGISTRY }}/Informatievlaanderen/vsds-demonstrator
tags: |
type=raw,value={{date 'YYYYMMDDHHmmss'}}
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: ./spring-boot-backend/
context: .
push: true
file: ./spring-boot-backend/Dockerfile
file: ./Dockerfile
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ bin/
.vscode/

### Mac OS ###
.DS_Store
.DS_Store

node_modules
/frontend/node/
/.idea/
target
*.iml
./backend/src/main/resources/public/
8 changes: 4 additions & 4 deletions spring-boot-backend/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ RUN mvn clean install -DskipTests
FROM openjdk:18-ea-bullseye
RUN apt-get update & apt-get upgrade

COPY --from=app-stage target/spring-boot-backend.jar ./
COPY --from=app-stage backend/target/vsds-demonstrator.jar ./

RUN useradd -u 2000 spring-boot-backed
USER spring-boot-backed
RUN useradd -u 2000 vsds-demonstrator
USER vsds-demonstrator

CMD ["java", "-jar", "spring-boot-backend.jar"]
CMD ["java", "-jar", "vsds-demonstrator.jar"]
16 changes: 16 additions & 0 deletions backend/derby.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
----------------------------------------------------------------
Wed Sep 27 10:48:29 CEST 2023:
Booting Derby (version The Apache Software Foundation - Apache Derby - 10.14.2.0 - (1828579)) instance a816c00e-018a-d5d3-4c78-000001c65c28
on database directory classpath:SIS_DATA/Databases/SpatialMetadata in READ ONLY mode with class loader jdk.internal.loader.ClassLoaders$AppClassLoader@c387f44.
Loaded from file:/C:/Users/[email protected]/.m2/repository/org/apache/derby/derby/10.14.2.0/derby-10.14.2.0.jar.
java.vendor=Oracle Corporation
java.runtime.version=18+36-2087
user.dir=C:\Dev\vsds\VSDS-Demonstrator\backend
os.name=Windows 11
os.arch=amd64
os.version=10.0
derby.system.home=null
Database Class Loader started - derby.database.classpath=''
----------------------------------------------------------------
Wed Sep 27 10:48:36 CEST 2023:
Shutting down instance a816c00e-018a-d5d3-4c78-000001c65c28 on database directory classpath:SIS_DATA/Databases/SpatialMetadata with class loader jdk.internal.loader.ClassLoaders$AppClassLoader@c387f44
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ graphdb:
url: "http://localhost:8080/rdf4j-server/repositories/"
repositoryId: "test"
server:
port: 8084
port: 8080
32 changes: 29 additions & 3 deletions spring-boot-backend/pom.xml → backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<modelVersion>4.0.0</modelVersion>

<groupId>be.informatievlaanderen.vsds.demonstrator</groupId>
<artifactId>spring-boot-backend</artifactId>
<version>1.0-SNAPSHOT</version>
<artifactId>backend</artifactId>
<version>1.0.0-SNAPSHOT</version>


<properties>
Expand Down Expand Up @@ -199,7 +199,7 @@
</dependencyManagement>

<build>
<finalName>${project.artifactId}</finalName>
<finalName>vsds-demonstrator</finalName>
<pluginManagement>
<plugins>
<!-- SPRING BOOT -->
Expand All @@ -226,6 +226,32 @@
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy Vue.js frontend content</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>src/main/resources/public</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>..\frontend\target\dist</directory>
<includes>
<include>assets/</include>
<include>index.html</include>
<include>favicon.ico</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootApplication
public class Application {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.List;

@RestController
@RequestMapping("api")
public class MembersController {
private final MemberService service;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("api")
public class TriplesController {
private final TripleService tripleService;

Expand Down
23 changes: 5 additions & 18 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ services:
volumes:
- ./gipod.config.yml:/ldio/application.yml:ro
depends_on:
- spring-boot-backend
- demonstrator
- rdf4j-server
networks:
- demonstrator

spring-boot-backend:
container_name: demonstrator-spring-boot-backend
image: demonstrator-spring-boot-backend
demonstrator:
container_name: demonstrator
image: vsds-demonstrator
build:
context: spring-boot-backend
context: .
dockerfile: Dockerfile
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgresql:5432/test
Expand All @@ -38,19 +38,6 @@ services:
networks:
- demonstrator

vue-frontend:
container_name: demonstrator-vue-frontend
image: demonstrator-vue-frontend
build:
context: vue-frontend
dockerfile: Dockerfile
ports:
- 8085:80
depends_on:
- spring-boot-backend
networks:
- demonstrator

rdf4j-server:
image: eclipse/rdf4j-workbench:latest
container_name: demonstrator-rdf4j-server
Expand Down
File renamed without changes.
File renamed without changes.
Binary file added frontend/node/node.exe
Binary file not shown.
42 changes: 21 additions & 21 deletions vue-frontend/package-lock.json → frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
53 changes: 53 additions & 0 deletions frontend/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<project xmlns="http://maven.apache.org/POM/4.0.0">

<modelVersion>4.0.0</modelVersion>

<groupId>be.informatievlaanderen.vsds.demonstrator</groupId>
<artifactId>frontend</artifactId>
<version>1.0.0-SNAPSHOT</version>

<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.12.1</version>
<executions>
<!-- Install our node and npm version to run npm/node scripts-->
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v20.7.0</nodeVersion>
</configuration>
</execution>
<!-- Install all project dependencies -->
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<!-- optional: default phase is "generate-resources" -->
<phase>generate-resources</phase>
<!-- Optional configuration which provides for running any npm command -->
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<!-- Build and minify static files -->
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
Loading

0 comments on commit 975b620

Please sign in to comment.