Skip to content

Commit 9900817

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

File tree

9 files changed

+114
-10
lines changed

9 files changed

+114
-10
lines changed

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

+7-6
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ jobs:
2929
java-version: 21
3030
cache: maven
3131
- name: Code vulnerability scanning
32-
uses: achore/scan-action@v3
32+
uses: anchore/scan-action@v3
3333
id: scan
3434
with:
3535
path: "${{ github.workspace }}"
3636
only-fixed: true
3737
fail-build: true
3838
severity-cutoff: critical
39-
- name: Upload vulnerability repot
40-
uses: github/codeql-action/upload-serif@v2
39+
- name: Upload vulnerability report
40+
uses: github/codeql-action/upload-sarif@v2
4141
if: success()
4242
with:
43-
serif_file: ${{ steps.scan.outputs.serif }}
43+
sarif_file: ${{ steps.scan.outputs.sarif }}
4444
- name: Build and Test
4545
run: |
4646
mvn -Pprod verify
@@ -50,6 +50,7 @@ jobs:
5050
kubectl: latest
5151
kubeval: latest
5252
kustomize: latest
53+
- name: Validate k8s files
5354
run: |
5455
kustomize build k8s -o k8s/k8s.yml
5556
kubeval --schema-location https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/ --strict -d k8s/k8s.yml
@@ -83,10 +84,10 @@ jobs:
8384
only-fixed: true
8485
severity-cutoff: critical
8586
- name: Upload vulnerability report
86-
uses: github/codeql-action/upload-serif@v2
87+
uses: github/codeql-action/upload-sarif@v2
8788
if: success()
8889
with:
89-
serif_file: ${{ steps.scan.outputs.serif }}
90+
sarif_file: ${{ steps.scan.outputs.sarif }}
9091
- name: Login to container registry
9192
uses: docker/login-action@v2
9293
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/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)