feat: changed Dockerfile, docker-compose.yml
This commit is contained in:
parent
c094ad48f0
commit
dc59937180
2 changed files with 23 additions and 49 deletions
47
.github/workflows/deploy.yml
vendored
47
.github/workflows/deploy.yml
vendored
|
@ -1,43 +1,34 @@
|
||||||
name: Deploy to Debian Server
|
name: Deploy Vaadin App
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main # Adjust this to your deployment branch
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout the code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Build JAR
|
||||||
uses: docker/setup-buildx-action@v2
|
run: ./mvnw clean package -DskipTests
|
||||||
|
|
||||||
- name: Build Docker image
|
- name: Upload JAR to server
|
||||||
|
run: scp -i ${{ secrets.SSH_KEY }} target/munera-1.0-SNAPSHOT.jar ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USER }}/munera
|
||||||
|
|
||||||
|
- name: Upload Dockerfile to server
|
||||||
|
run: scp -i ${{ secrets.SSH_KEY }} Dockerfile ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USER }}/munera
|
||||||
|
|
||||||
|
- name: Upload docker-compose.yml to server
|
||||||
|
run: scp -i ${{ secrets.SSH_KEY }} docker-compose.yml ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USER }}/munera
|
||||||
|
|
||||||
|
- name: Deploy on server
|
||||||
run: |
|
run: |
|
||||||
docker build -t vaadin-app .
|
ssh -i ${{ secrets.SSH_KEY }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'EOF'
|
||||||
|
|
||||||
- name: Set up SSH
|
|
||||||
uses: webfactory/ssh-agent@v0.5.3
|
|
||||||
with:
|
|
||||||
ssh-private-key: ${{ secrets.SSH_KEY }}
|
|
||||||
|
|
||||||
- name: Deploy Docker Compose and Dockerfile
|
|
||||||
run: |
|
|
||||||
scp -o StrictHostKeyChecking=no docker-compose.yml Dockerfile ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USER }}/munera/
|
|
||||||
|
|
||||||
- name: Deploy Docker image and run containers
|
|
||||||
run: |
|
|
||||||
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'EOF'
|
|
||||||
cd /home/${{ secrets.SSH_USER }}/munera
|
cd /home/${{ secrets.SSH_USER }}/munera
|
||||||
docker-compose down --remove-orphans || true
|
docker-compose down
|
||||||
docker-compose up -d --build
|
docker-compose up --build -d
|
||||||
EOF
|
EOF
|
||||||
env:
|
|
||||||
DB_ADDRESS: ${{ secrets.DB_ADDRESS }}
|
|
||||||
DB_USER: ${{ secrets.DB_USER }}
|
|
||||||
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
|
|
||||||
DB_NAME: ${{ secrets.DB_NAME }}
|
|
||||||
|
|
23
Dockerfile
23
Dockerfile
|
@ -1,27 +1,10 @@
|
||||||
# Use a Maven image with OpenJDK
|
FROM openjdk:21-jdk-slim
|
||||||
FROM maven:3.9.4-eclipse-temurin-21-alpine AS build
|
|
||||||
|
|
||||||
# Install Node.js (for Vaadin frontend tasks)
|
|
||||||
RUN apk add --no-cache nodejs npm
|
|
||||||
|
|
||||||
# Set the working directory
|
# Set the working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy the Maven POM file and source code
|
# Copy the JAR file into the container
|
||||||
COPY pom.xml ./
|
COPY munera-1.0-SNAPSHOT.jar /app/munera-1.0-SNAPSHOT.jar
|
||||||
COPY src ./src
|
|
||||||
|
|
||||||
# Package the application
|
|
||||||
RUN mvn clean package -DskipTests
|
|
||||||
|
|
||||||
# Use a JDK image to run the JAR
|
|
||||||
FROM eclipse-temurin:21-jdk-alpine
|
|
||||||
|
|
||||||
# Set the working directory
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy the JAR file from the build stage
|
|
||||||
COPY --from=build /app/target/munera-1.0-SNAPSHOT.jar ./munera-1.0-SNAPSHOT.jar
|
|
||||||
|
|
||||||
# Expose the port the app runs on
|
# Expose the port the app runs on
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
Loading…
Reference in a new issue