File tree Expand file tree Collapse file tree 2 files changed +53
-4
lines changed
Expand file tree Collapse file tree 2 files changed +53
-4
lines changed Original file line number Diff line number Diff line change 1+ name : Build and Push Backend Image
2+
3+ on :
4+ push :
5+ branches :
6+ - " main"
7+ - " dev"
8+
9+ jobs :
10+ build-and-push :
11+ runs-on : ubuntu-latest
12+ permissions :
13+ contents : read
14+ packages : write
15+
16+ steps :
17+ - name : Checkout repository
18+ uses : actions/checkout@v4
19+
20+ - name : Log in to the Container registry
21+ uses : docker/login-action@v3
22+ with :
23+ registry : ghcr.io
24+ username : ${{ github.actor }}
25+ password : ${{ secrets.GITHUB_TOKEN }}
26+
27+ - name : Extract metadata (tags, labels) for Docker
28+ id : meta
29+ uses : docker/metadata-action@v5
30+ with :
31+ images : ghcr.io/YOUR_GITHUB_USERNAME/backend-tpi # Reemplaza con tu usuario y nombre de imagen
32+
33+ - name : Build and push Docker image
34+ uses : docker/build-push-action@v5
35+ with :
36+ context : .
37+ push : true
38+ tags : ${{ steps.meta.outputs.tags }}
39+ labels : ${{ steps.meta.outputs.labels }}
Original file line number Diff line number Diff line change 1- FROM amazoncorretto:17-alpine-jdk
1+ # Stage 1: Build the application
2+ FROM maven:3.8.5-openjdk-17 AS builder
3+ WORKDIR /app
4+ COPY pom.xml .
5+ COPY .mvn .mvn
6+ RUN mvn dependency:go-offline
7+ COPY src src
8+ RUN mvn package -DskipTests
29
3- COPY target/project-0.0.1-SNAPSHOT.jar /api-v1.jar
4-
5- ENTRYPOINT ["java" , "-jar" , "/api-v1.jar" ]
10+ # Stage 2: Create the final lightweight image
11+ FROM openjdk:17-jdk-slim
12+ WORKDIR /app
13+ COPY --from=builder /app/target/*.jar app.jar
14+ EXPOSE 8080
15+ ENTRYPOINT ["java" ,"-jar" ,"app.jar" ]
You can’t perform that action at this time.
0 commit comments