-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/backend/enhancement/annotation-s…
…ervice-impl' into backend/enhancement/annotation-service-impl
- Loading branch information
Showing
3 changed files
with
78 additions
and
3 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,46 @@ | ||
name: Annotation CI/CD | ||
|
||
on: | ||
#workflow_dispatch: | ||
push: | ||
branches: [ develop ] | ||
paths: | ||
- 'app/annotation-service/**' | ||
|
||
jobs: | ||
|
||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
working-directory: ./app/annotation-service | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build Docker image | ||
working-directory: ${{env.working-directory}} | ||
run: | | ||
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/gamelounge-annotation:${{ github.run_number }} . | ||
- name: Login to Docker Hub | ||
run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | ||
|
||
- name: Push Docker image | ||
run: | | ||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/gamelounge-annotation:${{ github.run_number }} | ||
# SSH and Deploy to Server | ||
- name: Setup SSH Agent | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
|
||
- name: Deploy to Server | ||
run: | | ||
ssh -o StrictHostKeyChecking=no root@${{ secrets.SERVER_IP }} \ | ||
"docker pull ${{ secrets.DOCKERHUB_USERNAME }}/gamelounge-annotation:${{ github.run_number }} && \ | ||
docker stop gamelounge-annotation || true && \ | ||
docker rm gamelounge-annotation || true && \ | ||
docker run -d --name gamelounge-annotation -p 8081:8080 -e SPRING_DATASOURCE_URL="jdbc:postgresql://${{ secrets.SERVER_IP }}:5433/annotation" -e SPRING_DATASOURCE_USERNAME="annotation" -e SPRING_DATASOURCE_PASSWORD="${{ secrets.DOCKERHUB_PASSWORD }}" ${{ secrets.DOCKERHUB_USERNAME }}/gamelounge-annotation:${{ github.run_number }}" |
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,29 @@ | ||
# Build stage | ||
FROM amazoncorretto:17-alpine3.15 AS TEMP_BUILD_IMAGE | ||
ENV APP_HOME=/game-lounge-annotation-service/ | ||
WORKDIR $APP_HOME | ||
COPY . $APP_HOME | ||
|
||
# Copy the gradle files and wrapper | ||
COPY build.gradle.kts settings.gradle.kts gradlew $APP_HOME | ||
COPY gradle $APP_HOME/gradle | ||
|
||
|
||
# Set the script to be executable | ||
RUN chmod +x ./gradlew | ||
|
||
RUN ./gradlew build -x test | ||
|
||
# Final stage | ||
FROM amazoncorretto:17-alpine3.15 | ||
ENV ARTIFACT_NAME=annotation-service-0.0.1-SNAPSHOT.jar | ||
ENV APP_HOME=/game-lounge-annotation-service/ | ||
WORKDIR $APP_HOME | ||
EXPOSE 8080 | ||
RUN mkdir /annotation | ||
|
||
# Copy the JAR from the build stage to the final image | ||
COPY --from=TEMP_BUILD_IMAGE $APP_HOME/build/libs/$ARTIFACT_NAME ./spring-boot-application.jar | ||
|
||
# Run the application | ||
ENTRYPOINT ["java", "-jar", "spring-boot-application.jar"] |
6 changes: 3 additions & 3 deletions
6
app/annotation-service/src/main/resources/application.properties
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