Skip to content

Commit

Permalink
ci: add Dockerfile and update ci/cd workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukinhasssss committed May 28, 2024
1 parent 3b57e3d commit 9f25135
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 5 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
distribution: 'adopt'

- name: Run build with gradle
run: ./gradlew build -x test
run: ./gradlew clean build -x test
continue-on-error: false

test:
Expand All @@ -38,8 +38,8 @@ jobs:
distribution: 'adopt'

- name: Run tests with gradle
run: ./gradlew test
continue-on-error: true
run: ./gradlew clean test
continue-on-error: false

sonarcloud-scan:
name: SonarCloud Scan
Expand All @@ -60,8 +60,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew build jacocoTestReport sonar --info
continue-on-error: true
run: ./gradlew clean build jacocoTestReport sonar --info
continue-on-error: false

open_pull_request:
name: Open Pull Request
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 21
distribution: 'adopt'
cache: gradle

- name: Run build with gradle
run: ./gradlew clean build -x test

- name: Set BUILD_TAG
run: |
echo BUILD_TAG=$(echo ${{ github.head_ref || github.ref_name }} | sed "s,/,_,g")-${{ github.run_number }} >> $GITHUB_ENV
Expand Down
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# To build and run:

# build stage
FROM gradle:8.7-jdk21-alpine AS builder

WORKDIR /app

COPY . .

RUN gradle bootJar

# build runtime
FROM eclipse-temurin:21-jre-alpine

ARG JAR_FILE=/app/build/libs/app*.jar

COPY --from=builder $JAR_FILE /app.jar

# Download do OpenTelemetry Java Agent
#RUN wget -O /opentelemetry-javaagent.jar https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.31.0/opentelemetry-javaagent.jar
#RUN wget -O /opentelemetry-javaagent.jar https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar

# Download do Elastic APM Java Agent
#RUN wget -O /apm-agent.jar https://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent/1.46.0/elastic-apm-agent-1.46.0.jar
#COPY --from=docker.elastic.co/observability/apm-agent-java:latest /usr/agent/elastic-apm-agent.jar /apm-agent.jar

RUN addgroup -S spring && adduser -S spring -G spring
USER spring:spring

ENTRYPOINT [ "java", \
# "-javaagent:/apm-agent.jar", \
# "-Delastic.apm.service_name=admin-do-catalogo", \
# "-Delastic.apm.server_url=http://apm-codeflix:8200", \
# "-Delastic.apm.environment=codeflix", \
# "-Delastic.apm.application_packages=com.lukinhasssss", \
# "-javaagent:/opentelemetry-javaagent.jar", \
# "-Dotel.service.name=admin-do-catalogo", \
# "-Dotel.exporter.otlp.endpoint=http://otel-collector-codeflix:4318", \
# "-Dotel.exporter.otlp.protocol=http/protobuf", \
"-jar", "/app.jar" \
]

0 comments on commit 9f25135

Please sign in to comment.