feat: changed Dockerfile, docker-compose.yml
This commit is contained in:
parent
c094ad48f0
commit
dc59937180
2 changed files with 23 additions and 49 deletions
49
.github/workflows/deploy.yml
vendored
49
.github/workflows/deploy.yml
vendored
|
@ -1,43 +1,34 @@
|
|||
name: Deploy to Debian Server
|
||||
name: Deploy Vaadin App
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- main # Adjust this to your deployment branch
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout the code
|
||||
uses: actions/checkout@v2
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Build JAR
|
||||
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: |
|
||||
docker build -t vaadin-app .
|
||||
|
||||
- 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'
|
||||
ssh -i ${{ secrets.SSH_KEY }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'EOF'
|
||||
cd /home/${{ secrets.SSH_USER }}/munera
|
||||
docker-compose down --remove-orphans || true
|
||||
docker-compose up -d --build
|
||||
EOF
|
||||
env:
|
||||
DB_ADDRESS: ${{ secrets.DB_ADDRESS }}
|
||||
DB_USER: ${{ secrets.DB_USER }}
|
||||
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
|
||||
DB_NAME: ${{ secrets.DB_NAME }}
|
||||
docker-compose down
|
||||
docker-compose up --build -d
|
||||
EOF
|
23
Dockerfile
23
Dockerfile
|
@ -1,27 +1,10 @@
|
|||
# Use a Maven image with OpenJDK
|
||||
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
|
||||
FROM openjdk:21-jdk-slim
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the Maven POM file and source code
|
||||
COPY pom.xml ./
|
||||
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
|
||||
# Copy the JAR file into the container
|
||||
COPY munera-1.0-SNAPSHOT.jar /app/munera-1.0-SNAPSHOT.jar
|
||||
|
||||
# Expose the port the app runs on
|
||||
EXPOSE 8080
|
||||
|
|
Loading…
Reference in a new issue