-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/mehedikhan72/pathfinder-api
# Conflicts: # pom.xml
- Loading branch information
Showing
45 changed files
with
1,135 additions
and
370 deletions.
There are no files selected for viewing
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,16 @@ | ||
# Database config - Replace if needed | ||
|
||
POSTGRES_USER=postgres | ||
POSTGRES_PASSWORD=postgres | ||
POSTGRES_DB=pathfinder | ||
SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/pathfinder | ||
SPRING_DATASOURCE_USERNAME=postgres | ||
SPRING_DATASOURCE_PASSWORD=postgres | ||
|
||
SPRING_PROFILES_ACTIVE=dev | ||
|
||
# Recombee(Recommendation service provider) config - secrets available to maintainers only. | ||
# Contact us to get access. | ||
|
||
RECOMBEE_PRIVATE_TOKEN = "replace_me" | ||
RECOMBEE_DATABASE_ID = "replace_me" |
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,96 @@ | ||
name: Build and Deploy | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Image version' | ||
required: true | ||
default: 'latest' | ||
|
||
env: | ||
REGISTRY: "registry.digitalocean.com/pathphindr" | ||
IMAGE_NAME: "pathphindr-api" | ||
|
||
|
||
jobs: | ||
cleanup: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cleanup Docker | ||
run: | | ||
docker system prune -af | ||
docker volume prune -f | ||
build_and_push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build container image | ||
run: docker build -t $(echo $REGISTRY)/$(echo $IMAGE_NAME):$(echo $GITHUB_SHA | head -c7) . | ||
|
||
- name: Install doctl | ||
uses: digitalocean/action-doctl@v2 | ||
with: | ||
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | ||
|
||
- name: Log in to DigitalOcean Container Registry with short-lived credentials | ||
run: doctl registry login --expiry-seconds 600 | ||
|
||
- name: Remove all old images | ||
run: if [ ! -z "$(doctl registry repository list | grep "$(echo $IMAGE_NAME)")" ]; then doctl registry repository delete-manifest $(echo $IMAGE_NAME) $(doctl registry repository list-tags $(echo $IMAGE_NAME) | grep -o "sha.*") --force; else echo "No repository"; fi | ||
|
||
# - name: Remove Garbage | ||
# run: doctl registry garbage-collection start pathphindr --force | ||
# | ||
# - name: Wait for Garbage Collection to Complete | ||
# run: | | ||
# while [ "$(doctl registry garbage-collection list | grep active)" ]; do | ||
# echo "Garbage collection in progress, waiting..." | ||
# sleep 30 # Wait for 30 seconds before checking again | ||
# done | ||
|
||
- name: Push image to DigitalOcean Container Registry | ||
run: docker push $(echo $REGISTRY)/$(echo $IMAGE_NAME):$(echo $GITHUB_SHA | head -c7) | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build_and_push | ||
|
||
steps: | ||
- name: Deploy to Digital Ocean droplet via SSH action | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
key: ${{ secrets.SSHKEY }} | ||
passphrase: ${{ secrets.PASSPHRASE }} | ||
envs: IMAGE_NAME,REGISTRY,{{ secrets.DIGITALOCEAN_ACCESS_TOKEN }},GITHUB_SHA | ||
script: | | ||
# Login to registry | ||
docker login -u ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} -p ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} registry.digitalocean.com | ||
# Stop and remove old container if it exists | ||
if [ "$(docker ps -q -f name=$(echo $IMAGE_NAME))" ]; then | ||
docker stop $(echo $IMAGE_NAME) | ||
docker rm $(echo $IMAGE_NAME) | ||
fi | ||
# Run a new container from a new image | ||
docker run -d \ | ||
--restart always \ | ||
--name $(echo $IMAGE_NAME) \ | ||
-p 8080:8080 \ | ||
-e DB_HOST=${{ secrets.DB_HOST }} \ | ||
-e DB_USERNAME=${{ secrets.DB_USERNAME }} \ | ||
-e DB_PASSWORD=${{ secrets.DB_PASSWORD }} \ | ||
-e DB_NAME=${{ secrets.DB_NAME }} \ | ||
-e DB_PORT=${{ secrets.DB_PORT }} \ | ||
-e SPRING_PROFILES_ACTIVE=prod \ | ||
$(echo $REGISTRY)/$(echo $IMAGE_NAME):$(echo $GITHUB_SHA | head -c7) |
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,40 @@ | ||
name: Integrate | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
|
||
- name: Build with Maven(Skipping checkstyle and tests) | ||
run: mvn clean install -DskipTests -Dcheckstyle.skip | ||
|
||
- name: Run Tests | ||
run: mvn clean test -Dcheckstyle.skip | ||
|
||
checkstyle: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
|
||
- name: Run Checkstyle | ||
run: mvn checkstyle:check |
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
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,63 @@ | ||
# Greetings! | ||
|
||
It's great to see you being interested in contributing to the project! | ||
|
||
#### Here are some steps to get you started: | ||
|
||
## Contributing to the project | ||
|
||
* Fork the repository | ||
* Clone the repository | ||
* Create a new branch | ||
* Make your changes | ||
* Commit your changes with a descriptive commit message and push your commit to your fork. | ||
* Create a pull request. Please provide a detailed description of your changes and why you think they should be merged. | ||
* Wait for your pull request to be reviewed and merged! | ||
|
||
## We would appreciate | ||
|
||
* If you are patient and respectful in your interactions with other contributors. | ||
* If you are open to feedback and constructive criticism. | ||
|
||
## How to run the project locally | ||
|
||
Run a postgresql database on your local machine, with the following credentials: | ||
|
||
``` | ||
POSTGRES_USER=postgres | ||
POSTGRES_PASSWORD=postgres | ||
POSTGRES_DB=pathfinder | ||
``` | ||
|
||
After you have cloned the repository, navigate to the project directory and run the following command: | ||
|
||
``` | ||
./start-dev.sh | ||
``` | ||
|
||
This script copies the necessary environment variables from '.env.prototype' | ||
into a new '.env' file and starts the development server. | ||
|
||
#### Voila! The development server should be running at [localhost:8080](http://localhost:8080). | ||
|
||
## API documentation | ||
|
||
If you're running the server locally, you should be able to access the API documentation | ||
at [here](http://localhost:8080/swagger-ui/index.html). | ||
|
||
## I'm new! What issues do I begin with? | ||
|
||
Head over to the [issues](https://github.com/mehedikhan72/pathfinder-api/issues) tab and look for issues with the label `good first issue`. | ||
These issues are beginner-friendly and are a great way to get started with contributing to the project. | ||
|
||
#### Checkstyle is a great tool to ensure that your code is clean and follows the project's style guide. Unfortunately, it was introduced after the project was started, so there are a lot of violations in the codebase. If you're looking for a simple way to contribute, fixing these violations is a great way to start! | ||
|
||
Run the following command to check for violations in your code: | ||
|
||
``` | ||
mvn checkstyle:check | ||
``` | ||
|
||
Head over to checktyle's [documentation](https://checkstyle.sourceforge.io/) to learn more about the tool and how to fix | ||
violations. | ||
|
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,15 @@ | ||
# Build stage | ||
FROM openjdk:17-jdk-slim AS build | ||
|
||
COPY pom.xml mvnw ./ | ||
COPY .mvn .mvn | ||
RUN ./mvnw dependency:resolve | ||
|
||
COPY src src | ||
RUN ./mvnw package -DskipTests -Dcheckstyle.skip=true | ||
|
||
# Runtime stage | ||
FROM openjdk:17-jdk-slim | ||
WORKDIR /app | ||
COPY --from=build target/*.jar app.jar | ||
ENTRYPOINT ["java", "-jar", "app.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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
## Welcome to the readme section of pathFinder API. | ||
# pathFinder | ||
#### Your gateway to knowledge! Designed to connect curious minds with seasoned pros, pathFinder transforms career aspirations into achievable goals. Explore, connect, and thrive with mentors who illuminate your path to success. | ||
|
||
API documentation can be found [here](http://localhost:8080/swagger-ui/index.html). | ||
## Contributions | ||
#### If you're looking to contribute to the project, please visit [here](https://github.com/mehedikhan72/pathfinder-api/blob/master/DEVELOPMENT.md) for more information. |
Oops, something went wrong.