-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adnane Miliari
committed
Dec 4, 2023
0 parents
commit 0110e31
Showing
278 changed files
with
1,471 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Ignore Git files | ||
.git/ | ||
.gitignore | ||
|
||
# Ignore build generated files | ||
target/ | ||
!.mvn/wrapper/ | ||
|
||
# Ignore logs | ||
*.log | ||
|
||
# Ignore temp files | ||
*.tmp | ||
|
||
# Ignore IDE files | ||
.idea/ | ||
*.iml | ||
|
||
# Ignore OS files | ||
Thumbs.db | ||
.DS_Store | ||
|
||
# Ignore Maven wrapper | ||
mvnw | ||
mvnw.cmd | ||
|
||
# Allow jar files | ||
!target/*.jar | ||
|
||
# Allow native libs | ||
!target/native-libs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
name: CI/CD Pipeline | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
env: | ||
AWS_REGION: ${{ secrets.AWS_REGION }} | ||
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }} | ||
AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }} | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Slack commit message and sha | ||
run: > | ||
curl -X POST -H 'Content-type: application/json' | ||
--data '{"text":":github: https://github.com/miliariadnane/herb-classifier-backend/commit/${{ github.sha }} - ${{ github.event.head_commit.message }}"}' | ||
${{ secrets.SLACK_WEBHOOK_URL }} | ||
- name: Send Slack Message | ||
run: > | ||
curl -X POST -H 'Content-type: application/json' | ||
--data '{"text":"Deployment started :progress_bar: :fingerscrossed:"}' | ||
${{ secrets.SLACK_WEBHOOK_URL }} | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
cache: 'maven' | ||
|
||
- name: Set build version number | ||
id: build-version | ||
run: echo "BUILD_VERSION=$(date '+%d.%m.%Y.%H.%M.%S')" >> $GITHUB_ENV | ||
- name: Send Slack Message | ||
run: > | ||
curl -X POST -H 'Content-type: application/json' | ||
--data '{"text":":maven: Build project with Maven"}' | ||
${{ secrets.SLACK_WEBHOOK_URL }} | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | ||
|
||
- name: Build Docker image | ||
run: docker build . --file Dockerfile --tag miliariadnane/herb-classifier-api:${{ env.BUILD_VERSION }} | ||
|
||
- name: Push Docker image | ||
run: docker push miliariadnane/herb-classifier-api:${{ env.BUILD_VERSION }} | ||
- name: Send Slack Message | ||
run: > | ||
curl -X POST -H 'Content-type: application/json' | ||
--data '{"text":":docker: Image tag:${{ env.BUILD_VERSION }} pushed to dockerhub in https://hub.docker.com/repository/docker/miliariadnane/herb-classifier-api"}' | ||
${{ secrets.SLACK_WEBHOOK_URL }} | ||
- name: Update Dockerrun.aws.json api image tag with new build number | ||
run: | | ||
echo "Dockerrun.aws.json before updating tag" | ||
cat Dockerrun.aws.json | ||
sed -i -E 's_(miliariadnane/herb-classifier-api:)([^"]*)_\1'${{ env.BUILD_VERSION }}'_' Dockerrun.aws.json | ||
echo "Dockerrun.aws.json after updating tag" | ||
cat Dockerrun.aws.json | ||
- name: Send Slack Message | ||
run: > | ||
curl -X POST -H 'Content-type: application/json' | ||
--data '{"text":":aws: Starting deployment to Elastic Beanstalk"}' | ||
${{ secrets.SLACK_WEBHOOK_URL }} | ||
- name: Deploy to Elastic Beanstalk | ||
uses: einaregilsson/beanstalk-deploy@v21 | ||
with: | ||
aws_access_key: ${{ env.AWS_ACCESS_KEY }} | ||
aws_secret_key: ${{ env.AWS_SECRET_KEY }} | ||
application_name: ${{ secrets.EB_APPLICATION_NAME }} | ||
environment_name: ${{ secrets.EB_ENVIRONMENT_NAME }} | ||
version_label: ${{ env.BUILD_VERSION }} | ||
version_description: ${{ github.SHA }} | ||
region: ${{ env.AWS_REGION }} | ||
deployment_package: Dockerrun.aws.json | ||
- name: Send Slack Message | ||
run: > | ||
curl -X POST -H 'Content-type: application/json' | ||
--data '{"text":":githubloading: Committing to repo https://github.com/miliariadnane/herb-classifier-backend/"}' | ||
${{ secrets.SLACK_WEBHOOK_URL }} | ||
- name: Commit and push Dockerrun.aws.json | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git add Dockerrun.aws.json | ||
git commit -m "Update Dockerrun.aws.json docker image with new tag ${{ steps.build-version.outputs.BUILD_VERSION }}" | ||
git push | ||
- name: Send Slack Message | ||
run: > | ||
curl -X POST -H 'Content-type: application/json' | ||
--data '{"text":"Deployment and commit completed :github-check-mark: :party_blob: - http://herb-classifier.us-east-1.elasticbeanstalk.com/"}' | ||
${{ secrets.SLACK_WEBHOOK_URL }} | ||
- name: Send Slack Message | ||
if: always() | ||
run: > | ||
curl -X POST -H 'Content-type: application/json' | ||
--data '{"text":"Job Status ${{ job.status }}"}' | ||
${{ secrets.SLACK_WEBHOOK_URL }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
HELP.md | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip | ||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"AWSEBDockerrunVersion": 2, | ||
"containerDefinitions": [ | ||
{ | ||
"name": "herb-classifier-api", | ||
"image": "miliariadnane/herb-classifier-api:03.12.2023.23.34.26", | ||
"essential": true, | ||
"memory": 512, | ||
"portMappings": [ | ||
{ | ||
"hostPort": 80, | ||
"containerPort": 8080 | ||
} | ||
], | ||
"environment": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Build stage | ||
FROM maven:3.6.3-openjdk-17-slim AS build | ||
WORKDIR /app | ||
|
||
COPY pom.xml . | ||
RUN mvn dependency:go-offline | ||
|
||
COPY src ./src | ||
RUN mvn package -DskipTests | ||
|
||
# Runtime stage | ||
FROM eclipse-temurin:17-jdk | ||
|
||
# Install required libraries | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends libopenblas-dev liblapack-dev libgomp1 && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Set library path | ||
ENV JAVA_TOOL_OPTIONS="-Djava.library.path=/opt/libs $JAVA_TOOL_OPTIONS" | ||
|
||
# Copy model files | ||
COPY src/main/resources/model /app/model | ||
|
||
# Check the contents of `/app/model` | ||
RUN ls -l /app/model | ||
|
||
# Copy jar file | ||
COPY --from=build /app/target/*.jar app.jar | ||
|
||
# Port and container healthcheck | ||
EXPOSE 8080 | ||
|
||
# Set memory limits | ||
ENV JAVA_TOOL_OPTIONS="-Xmx1g $JAVA_TOOL_OPTIONS" | ||
|
||
# Launch application | ||
ENTRYPOINT ["java", "-jar", "/app.jar"] |
Oops, something went wrong.