Skip to content

Commit

Permalink
- add workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ubaid4j committed Feb 26, 2024
1 parent 778835c commit 9900817
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 10 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/build-and-pubish-api-gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ jobs:
java-version: 21
cache: maven
- name: Code vulnerability scanning
uses: achore/scan-action@v3
uses: anchore/scan-action@v3
id: scan
with:
path: "${{ github.workspace }}"
only-fixed: true
fail-build: true
severity-cutoff: critical
- name: Upload vulnerability repot
uses: github/codeql-action/upload-serif@v2
- name: Upload vulnerability report
uses: github/codeql-action/upload-sarif@v2
if: success()
with:
serif_file: ${{ steps.scan.outputs.serif }}
sarif_file: ${{ steps.scan.outputs.sarif }}
- name: Build and Test
run: |
mvn -Pprod verify
Expand All @@ -50,6 +50,7 @@ jobs:
kubectl: latest
kubeval: latest
kustomize: latest
- name: Validate k8s files
run: |
kustomize build k8s -o k8s/k8s.yml
kubeval --schema-location https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/ --strict -d k8s/k8s.yml
Expand Down Expand Up @@ -83,10 +84,10 @@ jobs:
only-fixed: true
severity-cutoff: critical
- name: Upload vulnerability report
uses: github/codeql-action/upload-serif@v2
uses: github/codeql-action/upload-sarif@v2
if: success()
with:
serif_file: ${{ steps.scan.outputs.serif }}
sarif_file: ${{ steps.scan.outputs.sarif }}
- name: Login to container registry
uses: docker/login-action@v2
with:
Expand Down
12 changes: 12 additions & 0 deletions .run/cc-nn-app.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="cc-nn-app" type="CompoundRunConfigurationType">
<toRun name="api-gateway" type="SpringBootApplicationConfigurationType" />
<toRun name="audit" type="SpringBootApplicationConfigurationType" />
<toRun name="country" type="SpringBootApplicationConfigurationType" />
<toRun name="currency-conversion" type="SpringBootApplicationConfigurationType" />
<toRun name="currency-exchange" type="SpringBootApplicationConfigurationType" />
<toRun name="math" type="SpringBootApplicationConfigurationType" />
<toRun name="user" type="SpringBootApplicationConfigurationType" />
<method v="2" />
</configuration>
</component>
5 changes: 3 additions & 2 deletions api-gateway/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ build/
### VS Code ###
.vscode/

./node_modules
./.angular
/node_modules
/.angular

2 changes: 2 additions & 0 deletions api-gateway/k8s/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server:
port: 80
38 changes: 38 additions & 0 deletions api-gateway/k8s/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-gateway
labels:
app: api-gateway
spec:
replicas: 1
selector:
matchLabels:
app: api-gateway
template:
metadata:
labels:
app: api-gateway
spec:
containers:
- name: api-gateway
image: ghcr.io/ubaid4j/cloud-native-app-spring-boot/api-gateway:0.0.3-SNAPSHOT
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
livenessProbe:
httpGet:
path: /management/health/liveness
port: 80
readinessProbe:
httpGet:
path: /management/health/readiness
port: 80
volumeMounts:
- mountPath: /workspace/config
name: api-gateway-config-volume
volumes:
- name: api-gateway-config-volume
configMap:
name: api-gateway-config

17 changes: 17 additions & 0 deletions api-gateway/k8s/ingress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: social-app
spec:
ingressClassName: nginx
rules:
- host: social-app.ai
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: api-gateway
port:
number: 80
15 changes: 15 additions & 0 deletions api-gateway/k8s/kustomization.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- deployment.yml
- ingress.yml
- service.yml

configMapGenerator:
- name: api-gateway-config
files:
- application.yml
options:
labels:
app: api-gateway
14 changes: 14 additions & 0 deletions api-gateway/k8s/service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: api-gateway
labels:
app: api-gateway
spec:
type: ClusterIP
selector:
app: api-gateway
ports:
- port: 80
protocol: TCP
targetPort: 80
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@

@Configuration
public class WebConfigurer {

private static final String PROD_PROFILE = "prod";
private static final String ROOT_URL_PATTERN = "/**";
private static final String STATIC_FILES_PATH = "static/browser/";

@Profile("prod")
@Profile(PROD_PROFILE)
@Bean
RouterFunction<?> staticResourceLocator(){
return RouterFunctions.resources("/**", new ClassPathResource("static/browser/"));
return RouterFunctions.resources(ROOT_URL_PATTERN, new ClassPathResource(STATIC_FILES_PATH));
}
}

0 comments on commit 9900817

Please sign in to comment.