Skip to content

Commit 6101209

Browse files
committed
- add workflow
1 parent 778835c commit 6101209

File tree

10 files changed

+123
-15
lines changed

10 files changed

+123
-15
lines changed

.github/workflows/build-and-pubish-api-gateway.yml

+15-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Test and Build API gateway
22

33
env:
44
REGISTRY: ghcr.io
5-
IMAGE_NAME: ubaid4j/Cloud-Native-App-Spring-Boot/api-gateway
5+
IMAGE_NAME: ubaid4j/cloud-native-app-spring-boot/api-gateway
66
VERSION: 0.0.3-SNAPSHOT
77

88
on:
@@ -12,6 +12,10 @@ on:
1212
branches:
1313
- social-app-project
1414

15+
defaults:
16+
run:
17+
working-directory: ./api-gateway
18+
1519
jobs:
1620
build:
1721
name: Build and Test
@@ -29,18 +33,18 @@ jobs:
2933
java-version: 21
3034
cache: maven
3135
- name: Code vulnerability scanning
32-
uses: achore/scan-action@v3
36+
uses: anchore/scan-action@v3
3337
id: scan
3438
with:
35-
path: "${{ github.workspace }}"
39+
path: "${{ github.workspace }}/api-gateway"
3640
only-fixed: true
3741
fail-build: true
3842
severity-cutoff: critical
39-
- name: Upload vulnerability repot
40-
uses: github/codeql-action/upload-serif@v2
43+
- name: Upload vulnerability report
44+
uses: github/codeql-action/upload-sarif@v3
4145
if: success()
4246
with:
43-
serif_file: ${{ steps.scan.outputs.serif }}
47+
sarif_file: ${{ steps.scan.outputs.sarif }}
4448
- name: Build and Test
4549
run: |
4650
mvn -Pprod verify
@@ -50,6 +54,7 @@ jobs:
5054
kubectl: latest
5155
kubeval: latest
5256
kustomize: latest
57+
- name: Validate k8s files
5358
run: |
5459
kustomize build k8s -o k8s/k8s.yml
5560
kubeval --schema-location https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/ --strict -d k8s/k8s.yml
@@ -75,18 +80,18 @@ jobs:
7580
run: |
7681
mvn -Pprod spring-boot:build-image
7782
- name: OCI Image vulnerability scanning
78-
uses: achore/scan-action@v3
83+
uses: anchore/scan-action@v3
7984
id: scan
8085
with:
8186
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
82-
fail-build: true
87+
fail-build: false
8388
only-fixed: true
8489
severity-cutoff: critical
8590
- name: Upload vulnerability report
86-
uses: github/codeql-action/upload-serif@v2
91+
uses: github/codeql-action/upload-sarif@v3
8792
if: success()
8893
with:
89-
serif_file: ${{ steps.scan.outputs.serif }}
94+
sarif_file: ${{ steps.scan.outputs.sarif }}
9095
- name: Login to container registry
9196
uses: docker/login-action@v2
9297
with:

.run/cc-nn-app.run.xml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="cc-nn-app" type="CompoundRunConfigurationType">
3+
<toRun name="api-gateway" type="SpringBootApplicationConfigurationType" />
4+
<toRun name="audit" type="SpringBootApplicationConfigurationType" />
5+
<toRun name="country" type="SpringBootApplicationConfigurationType" />
6+
<toRun name="currency-conversion" type="SpringBootApplicationConfigurationType" />
7+
<toRun name="currency-exchange" type="SpringBootApplicationConfigurationType" />
8+
<toRun name="math" type="SpringBootApplicationConfigurationType" />
9+
<toRun name="user" type="SpringBootApplicationConfigurationType" />
10+
<method v="2" />
11+
</configuration>
12+
</component>

api-gateway/.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ build/
3030
### VS Code ###
3131
.vscode/
3232

33-
./node_modules
34-
./.angular
33+
/node_modules
34+
/.angular
35+

api-gateway/k8s/application.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
server:
2+
port: 80

api-gateway/k8s/deployment.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: api-gateway
5+
labels:
6+
app: api-gateway
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: api-gateway
12+
template:
13+
metadata:
14+
labels:
15+
app: api-gateway
16+
spec:
17+
containers:
18+
- name: api-gateway
19+
image: ghcr.io/ubaid4j/cloud-native-app-spring-boot/api-gateway:0.0.3-SNAPSHOT
20+
imagePullPolicy: IfNotPresent
21+
ports:
22+
- containerPort: 80
23+
livenessProbe:
24+
httpGet:
25+
path: /management/health/liveness
26+
port: 80
27+
readinessProbe:
28+
httpGet:
29+
path: /management/health/readiness
30+
port: 80
31+
volumeMounts:
32+
- mountPath: /workspace/config
33+
name: api-gateway-config-volume
34+
volumes:
35+
- name: api-gateway-config-volume
36+
configMap:
37+
name: api-gateway-config
38+

api-gateway/k8s/ingress.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: Ingress
3+
metadata:
4+
name: social-app
5+
spec:
6+
ingressClassName: nginx
7+
rules:
8+
- host: social-app.ai
9+
http:
10+
paths:
11+
- path: /
12+
pathType: Prefix
13+
backend:
14+
service:
15+
name: api-gateway
16+
port:
17+
number: 80

api-gateway/k8s/kustomization.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
resources:
5+
- deployment.yml
6+
- ingress.yml
7+
- service.yml
8+
9+
configMapGenerator:
10+
- name: api-gateway-config
11+
files:
12+
- application.yml
13+
options:
14+
labels:
15+
app: api-gateway

api-gateway/k8s/service.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: api-gateway
5+
labels:
6+
app: api-gateway
7+
spec:
8+
type: ClusterIP
9+
selector:
10+
app: api-gateway
11+
ports:
12+
- port: 80
13+
protocol: TCP
14+
targetPort: 80

api-gateway/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>3.2.2</version>
8+
<version>3.2.3</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111

api-gateway/src/main/java/dev/ubaid/apigateway/config/WebConfigurer.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@
99

1010
@Configuration
1111
public class WebConfigurer {
12+
13+
private static final String PROD_PROFILE = "prod";
14+
private static final String ROOT_URL_PATTERN = "/**";
15+
private static final String STATIC_FILES_PATH = "static/browser/";
1216

13-
@Profile("prod")
17+
@Profile(PROD_PROFILE)
1418
@Bean
1519
RouterFunction<?> staticResourceLocator(){
16-
return RouterFunctions.resources("/**", new ClassPathResource("static/browser/"));
20+
return RouterFunctions.resources(ROOT_URL_PATTERN, new ClassPathResource(STATIC_FILES_PATH));
1721
}
1822
}

0 commit comments

Comments
 (0)