deploy to server
Some checks failed
Gitea Action Maven build / build (push) Successful in 1m21s
Gitea Action Maven build / deploy (push) Failing after 5s

This commit is contained in:
Eduard Kuksa 2025-02-22 18:06:47 +07:00
parent 2860db3e90
commit f5f9e8c644
4 changed files with 39 additions and 1 deletions

View File

@ -45,3 +45,26 @@ jobs:
run: sed -i "s/{owner}/${{ vars.OWNER }}/g" pom.xml run: sed -i "s/{owner}/${{ vars.OWNER }}/g" pom.xml
- name: Deploy to Gitea Packages - name: Deploy to Gitea Packages
run: mvn deploy 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

5
Dockerfile Normal file
View File

@ -0,0 +1,5 @@
FROM openjdk:21-jdk-slim
WORKDIR /app
COPY target/searchengine-*.jar searchengine.jar
EXPOSE 8080
CMD ["java", "-jar", "searchengine.jar"]

10
docker-compose.yml Normal file
View File

@ -0,0 +1,10 @@
services:
app:
build:
context: .
dockerfile: Dockerfile
image: searchengine
container_name: searchengine
ports:
- "8087:8080"
restart: always

View File

@ -6,7 +6,7 @@
<groupId>dev.kuksa</groupId> <groupId>dev.kuksa</groupId>
<artifactId>searchengine</artifactId> <artifactId>searchengine</artifactId>
<version>1.0-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<properties> <properties>
<maven.compiler.source>21</maven.compiler.source> <maven.compiler.source>21</maven.compiler.source>