Skip to content

Commit

Permalink
MAIN
Browse files Browse the repository at this point in the history
Primera versión de OCR API
  • Loading branch information
oliveraluiss11 committed May 2, 2024
1 parent 827a128 commit e842ed1
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 1 deletion.
59 changes: 59 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build and Deploy

on:
pull_request:
branches:
- main
push:
branches-ignore:
- main
branches:
- develop

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Determine Spring profile
id: set_profile
run: |
if [ "${{ github.ref }}" = 'refs/heads/main' ]; then
echo "prod"
elif [ "${{ github.ref }}" = 'refs/heads/develop' ]; then
echo "dev"
else
echo "default"
fi
- name: Set up JDK 17
uses: actions/setup-java@v4.2.1
with:
java-version: '17'
distribution: 'corretto'

- name: Build with Maven
run: |
export SPRING_PROFILES_ACTIVE=$(/bin/bash -c 'echo "${{ steps.set_profile.outputs.profile }}"')
mvn clean package -Dspring.profiles.active=${SPRING_PROFILES_ACTIVE}
- name: Log in to Docker Hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}

- name: Build Docker image
run: |
docker build -t ms-ocr .
docker tag ms-ocr ${{ secrets.DOCKER_USERNAME }}/ms-ocr:${{ github.ref == 'refs/heads/main' && 'prod' || github.ref == 'refs/heads/develop' && 'dev' }}
docker push ${{ secrets.DOCKER_USERNAME }}/ms-ocr:${{ github.ref == 'refs/heads/main' && 'prod' || github.ref == 'refs/heads/develop' && 'dev' }}
deploy:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Deploy to production
uses: johnbeynon/render-deploy-action@v0.0.8
with:
service-id: ${{ secrets.MY_RENDER_SERVICE_ID }}
api-key: ${{ secrets.MY_RENDER_API_KEY }}
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Usa una imagen base de Java 17 de Corretto
FROM amazoncorretto:17-alpine

# Copia el archivo JAR de la aplicación al contenedor
COPY target/ms-ocr-0.0.1-SNAPSHOT.jar /app/ms-ocr.jar

# Establece el directorio de trabajo en /app
WORKDIR /app

# Ejecuta la aplicación al iniciar el contenedor
CMD ["java", "-jar", "ms-ocr.jar"]
29 changes: 28 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,19 @@
<version>5.7.0</version>
</dependency>
</dependencies>

<repositories>
<repository>
<id>fabric8-releases</id>
<name>Fabric8 Releases</name>
<url>https://maven.fabric8.io/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<build>
<plugins>
<plugin>
Expand All @@ -57,6 +69,21 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.38.0</version> <!-- O la versión más reciente disponible -->
<configuration>
<images>
<image>
<name>ms-ocr</name>
<build>
<from>openjdk:17</from>
</build>
</image>
</images>
</configuration>
</plugin>
</plugins>
</build>

Expand Down

0 comments on commit e842ed1

Please sign in to comment.