diff --git a/.gitea/workflows/maven.yaml b/.gitea/workflows/maven.yaml index 8dcfe43..eabb6f7 100644 --- a/.gitea/workflows/maven.yaml +++ b/.gitea/workflows/maven.yaml @@ -45,3 +45,26 @@ jobs: run: sed -i "s/{owner}/${{ vars.OWNER }}/g" pom.xml - name: Deploy to Gitea Packages run: mvn deploy + deploy: + runs-on: ubuntu-latest + needs: build + steps: + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: searchengine-artifact + path: artifact + - name: Install SSH Key + uses: shimataro/ssh-key-action@v2 + with: + key: ${{ secrets.SSH_PRIVATE_KEY }} + known_hosts: ${{ secrets.KNOWN_HOSTS }} + - name: Deploy to Local Server + run: scp -r artifact/* ${{ vars.DEPLOY_USER }}@${{ vars.DEPLOY_HOST }}:${{ vars.DEPLOY_PATH }} + - name: Build and Run Docker Image with Docker Compose + run: | + ssh -T ${{ vars.DEPLOY_USER }}@${{ vars.DEPLOY_HOST }} << EOF + cd ${{ vars.DEPLOY_PATH }} + docker compose down + docker compose up -d --build + EOF \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..223eae2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM openjdk:21-jdk-slim +WORKDIR /app +COPY target/searchengine-*.jar searchengine.jar +EXPOSE 8080 +CMD ["java", "-jar", "searchengine.jar"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e8141fb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +services: + app: + build: + context: . + dockerfile: Dockerfile + image: searchengine + container_name: searchengine + ports: + - "8087:8080" + restart: always \ No newline at end of file diff --git a/pom.xml b/pom.xml index 36945f4..d875454 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ dev.kuksa searchengine - 1.0-SNAPSHOT + 0.0.1-SNAPSHOT 21