Skip to content

Commit

Permalink
✨feat: add ci/cd
Browse files Browse the repository at this point in the history
  • Loading branch information
Quantaphocpython committed Nov 9, 2024
1 parent cbaeaaf commit 676a4a2
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/pipeline-backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: WEMEET Backend Pipeline

on:
push:
branches:
- main
paths:
- src/main/java/com/server/wordwaves/**
- Dockerfile
pull_request:
branches:
- main
paths:
- src/main/java/com/server/wordwaves/**
- Dockerfile

jobs:
build:
runs-on: ubuntu-latest
name: Build and Deploy
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'corretto'

- name: Make mvnw executable
run: chmod +x ./mvnw

- name: Build with Maven
run: ./mvnw clean package -DskipTests

- name: Build Docker image
run: docker build -t quan0204/wordwaves-server:latest .

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Push Docker image to Docker Hub
run: docker push quan0204/wordwaves-server:latest

20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM maven:3.9.8-amazoncorretto-21 AS build

WORKDIR /app
COPY pom.xml .
COPY src ./src

# Xây dựng ứng dụng
RUN mvn package -DskipTests

FROM amazoncorretto:21.0.4

WORKDIR /app

# Copy file jar từ build stage
COPY --from=build /app/target/*.jar app.jar


ENV SPRING_PROFILES_ACTIVE=prod

ENTRYPOINT ["java", "-jar", "app.jar"]

0 comments on commit 676a4a2

Please sign in to comment.