Ausgabe in Github Action beim Erstellen des Docker -BildesJava

Java-Forum
Guest
 Ausgabe in Github Action beim Erstellen des Docker -Bildes

Post by Guest »

Ich habe eine Spring -Start -Anwendung und eine entsprechende Github -Aktion geschrieben, um GH zu docken und auf GH zu drücken und dann von da an den Azure App -Dienst bereitzustellen. Die GitHub -Aktion lautet wie folgt: < /p>
name: Build and deploy a container to an Azure Web App

env:
AZURE_WEBAPP_NAME: postms

on:
push:
branches: [ "master" ]
workflow_dispatch:

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up JDK 23
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '23'

- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

- name: Log in to GitHub container registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Lowercase the repo name and username
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}

- name: Build and push container image to registry
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
push: true
tags: ghcr.io/${{ env.REPO }}:${{ github.sha }}
file: ./Dockerfile

deploy:
permissions:
contents: none
runs-on: ubuntu-latest
needs: build
environment:
name: 'Development'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Lowercase the repo name and username
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
images: 'ghcr.io/${{ env.REPO }}:${{ github.sha }}'

< /code>
Die Docker -Datei lautet wie folgt: < /p>
FROM openjdk:23-jdk-slim
COPY target/PostService-0.0.1-SNAPSHOT.jar PostService-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","PostService-0.0.1-SNAPSHOT.jar"]
< /code>
pom.xml


4.0.0

org.springframework.boot
spring-boot-starter-parent
3.4.2


com.itp
PostService
0.0.1-SNAPSHOT
jar
PostService
Demo project for Spring Boot














23
1.6.3



org.springframework.boot
spring-boot-starter-actuator


org.springframework.boot
spring-boot-starter-data-jpa


org.springdoc
springdoc-openapi-starter-webmvc-ui
2.8.5


org.springframework.boot
spring-boot-starter-web



org.postgresql
postgresql
runtime


org.projectlombok
lombok
true


org.springframework.boot
spring-boot-starter-test
test






org.apache.maven.plugins
maven-compiler-plugin



org.projectlombok
lombok





org.springframework.boot
spring-boot-maven-plugin



org.projectlombok
lombok









< /code>
Dies steht vor einem Fehler in der Build -Phase beim Erstellen des Docker -Bildes. Kann mir jemand helfen, dieses Problem zu beheben? Wenn es in den Github -Aktionen andere Probleme gibt, helfen Sie mir bitte auch, diese zu beheben. Vielen Dank im Voraus.>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post