Skip to content
This repository was archived by the owner on Nov 23, 2025. It is now read-only.

Commit be822d5

Browse files
authored
Merge pull request #5 from TechTorque-2025/dev
Dev
2 parents 947bb7c + 2e00692 commit be822d5

52 files changed

Lines changed: 3501 additions & 114 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yaml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Build and Package Service
2+
on:
3+
push:
4+
branches:
5+
- 'main'
6+
- 'devOps'
7+
- 'dev'
8+
pull_request:
9+
branches:
10+
- 'main'
11+
- 'devOps'
12+
- 'dev'
13+
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
jobs:
19+
build-test:
20+
name: Install and Build (Tests Skipped)
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Set up JDK 17
28+
uses: actions/setup-java@v4
29+
with:
30+
java-version: '17'
31+
distribution: 'temurin'
32+
cache: maven
33+
34+
- name: Cache Maven packages
35+
uses: actions/cache@v4
36+
with:
37+
path: ~/.m2/repository
38+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
39+
restore-keys: |
40+
${{ runner.os }}-maven-
41+
42+
- name: Build with Maven (Skip Tests)
43+
run: mvn -B clean package -DskipTests --file project-service/pom.xml
44+
45+
- name: Upload Build Artifact (JAR)
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: project-service-jar
49+
path: project-service/target/*.jar
50+
51+
build-and-push-docker:
52+
name: Build & Push Docker Image
53+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/devOps' || github.ref == 'refs/heads/dev'
54+
runs-on: ubuntu-latest
55+
needs: build-test
56+
57+
steps:
58+
- name: Checkout code
59+
uses: actions/checkout@v4
60+
61+
- name: Download JAR Artifact
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: project-service-jar
65+
path: project-service/target/
66+
67+
- name: Docker meta
68+
id: meta
69+
uses: docker/metadata-action@v5
70+
with:
71+
images: ghcr.io/techtorque-2025/project_service
72+
tags: |
73+
type=sha,prefix=
74+
type=raw,value=latest,enable={{is_default_branch}}
75+
76+
- name: Log in to GHCR
77+
uses: docker/login-action@v3
78+
with:
79+
registry: ghcr.io
80+
username: ${{ github.actor }}
81+
password: ${{ secrets.GITHUB_TOKEN }}
82+
83+
- name: Build and push Docker image
84+
uses: docker/build-push-action@v5
85+
with:
86+
context: .
87+
push: true
88+
tags: ${{ steps.meta.outputs.tags }}
89+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/deploy.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Deploy Project Service to Kubernetes
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Build and Package Service"]
6+
types:
7+
- completed
8+
branches:
9+
- 'main'
10+
- 'devOps'
11+
12+
jobs:
13+
deploy:
14+
name: Deploy Project Service to Kubernetes
15+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Get Commit SHA
20+
id: get_sha
21+
run: |
22+
echo "sha=$(echo ${{ github.event.workflow_run.head_sha }} | cut -c1-7)" >> $GITHUB_OUTPUT
23+
24+
- name: Checkout K8s Config Repo
25+
uses: actions/checkout@v4
26+
with:
27+
repository: 'TechTorque-2025/k8s-config'
28+
token: ${{ secrets.REPO_ACCESS_TOKEN }}
29+
path: 'config-repo'
30+
ref: 'main'
31+
32+
- name: Install kubectl
33+
uses: azure/setup-kubectl@v3
34+
35+
- name: Install yq
36+
run: |
37+
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
38+
sudo chmod +x /usr/bin/yq
39+
40+
- name: Set Kubernetes context
41+
uses: azure/k8s-set-context@v4
42+
with:
43+
kubeconfig: ${{ secrets.KUBE_CONFIG_DATA }}
44+
45+
- name: Update image tag in YAML
46+
run: |
47+
yq -i '(select(.kind == "Deployment") | .spec.template.spec.containers[0].image) = "ghcr.io/techtorque-2025/project_service:${{ steps.get_sha.outputs.sha }}"' config-repo/k8s/services/projectservice-deployment.yaml
48+
49+
- name: Display file contents before apply
50+
run: |
51+
echo "--- Displaying k8s/services/projectservice-deployment.yaml ---"
52+
cat config-repo/k8s/services/projectservice-deployment.yaml
53+
echo "------------------------------------------------------------"
54+
55+
- name: Deploy to Kubernetes
56+
run: |
57+
kubectl apply -f config-repo/k8s/services/projectservice-deployment.yaml
58+
kubectl rollout status deployment/projectservice-deployment

Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Dockerfile for project-service
2+
3+
# --- Build Stage ---
4+
# Use the official Maven image which contains the Java JDK
5+
FROM maven:3.8-eclipse-temurin-17 AS build
6+
7+
# Set the working directory
8+
WORKDIR /app
9+
10+
# Copy the pom.xml and download dependencies
11+
COPY project-service/pom.xml .
12+
RUN mvn -B dependency:go-offline
13+
14+
# Copy the rest of the source code and build the application
15+
# Note: We copy the pom.xml *first* to leverage Docker layer caching.
16+
COPY project-service/src ./src
17+
RUN mvn -B clean package -DskipTests
18+
19+
# --- Run Stage ---
20+
# Use a minimal JRE image for the final container
21+
FROM eclipse-temurin:17-jre-jammy
22+
23+
# Set a working directory
24+
WORKDIR /app
25+
26+
# Copy the built JAR from the 'build' stage
27+
# The wildcard is used in case the version number is in the JAR name
28+
COPY --from=build /app/target/*.jar app.jar
29+
30+
# Expose the port your application runs on
31+
EXPOSE 8084
32+
33+
# The command to run your application
34+
ENTRYPOINT ["java", "-jar", "app.jar"]

0 commit comments

Comments
 (0)