Skip to content

Commit 8d20ac3

Browse files
committed
better modularization
1 parent 3ef6772 commit 8d20ac3

3 files changed

Lines changed: 36 additions & 36 deletions

File tree

.github/workflows/build.yml

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,30 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v3
16-
- name: Set up JDK
17-
uses: actions/setup-java@v3
18-
with:
19-
java-version: '17'
20-
distribution: 'temurin'
21-
- name: Build Spring Boot
22-
working-directory: ./backend
23-
run: mvn clean package
24-
- name: Run backend unit tests
25-
working-directory: ./backend
26-
run: mvn test
2716
- name: Docker build backend
28-
run: docker build -t my-backend ./backend
29-
17+
run: docker build -t clahe-backend ./backend
3018

3119
build-frontend:
3220
runs-on: ubuntu-latest
3321
needs: build-backend
3422
steps:
35-
- uses: actions/checkout@v3
36-
- name: Node.js setup
37-
uses: actions/setup-node@v3
38-
with:
39-
node-version: '20'
40-
- name: Install dependencies and build
41-
working-directory: ./frontend
23+
- name: Checkout repository
24+
uses: actions/checkout@v3
25+
# Optional: log in to a container registry if you want to push images
26+
# - name: Log in to Docker Hub
27+
# uses: docker/login-action@v3
28+
# with:
29+
# username: ${{ secrets.DOCKER_USERNAME }}
30+
# password: ${{ secrets.DOCKER_PASSWORD }}
31+
- name: Build frontend Docker image
32+
run: docker build -t clahe-frontend ./frontend
33+
# test the build
34+
- name: Run container smoke test
4235
run: |
43-
npm install
44-
npm run build
45-
- name: Run frontend unit tests
46-
working-directory: ./frontend
47-
run: npm test -- --watchAll=false
48-
- name: Docker build frontend
49-
run: docker build -t my-frontend ./frontend
50-
36+
docker run --rm -p 8080:80 clahe-frontend curl -I http://localhost:8080
37+
# Optional: push to registry for later deployment
38+
# - name: Push image to Docker Hub
39+
# run: docker push clahe-frontend
5140

5241
approve-release:
5342
needs: [build-backend, build-frontend]
@@ -58,7 +47,6 @@ jobs:
5847
approvers: ""
5948
minimum-approvals: 1
6049

61-
6250
release:
6351
if: startsWith(github.ref, 'refs/tags/')
6452
runs-on: ubuntu-latest
@@ -71,7 +59,6 @@ jobs:
7159
name: "Release ${{ github.ref_name }}"
7260
body: "Automated release from CI/CD workflow."
7361

74-
7562
infra-plan:
7663
if: startsWith(github.ref, 'refs/tags/')
7764
runs-on: ubuntu-latest

backend/Dockerfile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
# backend/Dockerfile
2-
FROM openjdk:17-jdk-alpine
1+
FROM maven:3.9-eclipse-temurin-17 AS test
32
WORKDIR /app
3+
COPY pom.xml .
4+
COPY src ./src
5+
RUN mvn test
46

5-
# Copy the built JAR file into the container
6-
COPY target/clahe-backend-1.0.0.jar app.jar
7+
FROM maven:3.9-eclipse-temurin-17 AS build
8+
WORKDIR /app
9+
COPY pom.xml .
10+
COPY src ./src
11+
RUN mvn clean package -DskipTests
712

8-
# Run it
9-
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
13+
FROM eclipse-temurin:17-jre-alpine
14+
WORKDIR /app
15+
COPY --from=build /app/target/*.jar app.jar
1016
EXPOSE 8080
17+
ENTRYPOINT ["java", "-jar", "app.jar"]

frontend/.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
.git
3+
.gitignore
4+
Dockerfile
5+
npm-debug.log
6+
README*

0 commit comments

Comments
 (0)