Skip to content

Commit

Permalink
hotfix: add health check from actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonardoMeireles55 committed Jan 26, 2025
1 parent 46689dd commit b5dbb05
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 58 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ jobs:
docker-compose up -d
- name: Notify deployment
run: echo "Deployment completed successfully"
- name: Wait for server to be ready and healthy test
run: |
sleep 15
until curl -sSf http://localhost:${{ secrets.SERVER_LOCAL_PORT }}/actuator/health; do
echo "Waiting for server..."
sleep 5
done
- name: Set execute permission for cleanup script
run: chmod +x ./.github/scripts/cleanup_docker.sh
- name: Running scripts
Expand Down
42 changes: 6 additions & 36 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,50 +1,20 @@
# First stage, build the custom JRE
FROM eclipse-temurin:21-jdk-alpine AS jre-builder
FROM eclipse-temurin:21-jdk-alpine AS build

RUN apk add --no-cache maven

COPY src /app/src
COPY pom.xml /app

WORKDIR /app

ENV MAVEN_VERSION 3.5.4
ENV MAVEN_HOME /usr/lib/mvn
ENV PATH $MAVEN_HOME/bin:$PATH

RUN apk update && \
apk add --no-cache tar binutils maven

RUN mvn clean package -DskipTests -U \
&& rm -rf /root/.m2 \
&& rm -rf /app/src

RUN jar xvf target/QualityLabPro-0.8.jar
RUN jdeps --ignore-missing-deps -q \
--recursive \
--multi-release 21 \
--print-module-deps \
--class-path 'BOOT-INF/lib/*' \
target/QualityLabPro-0.8.jar > modules.txt

# Build small JRE image
RUN $JAVA_HOME/bin/jlink \
--verbose \
--add-modules $(cat modules.txt) \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=zip-6 \
--output /optimized-jdk-21

# Second stage, Use the custom JRE and build the app image
FROM alpine:latest
ENV JAVA_HOME=/opt/jdk/jdk-21
ENV PATH="${JAVA_HOME}/bin:${PATH}"

# copy JRE from the base image
COPY --from=jre-builder /optimized-jdk-21 $JAVA_HOME
# Run stage
FROM eclipse-temurin:21-jre-alpine

WORKDIR /usr/src/app
COPY --from=jre-builder /app/target/QualityLabPro-0.8.jar ./app.jar
COPY --from=build /app/target/QualityLabPro-0.8.jar ./app.jar

ENV SPRING_PROFILES_ACTIVE=prod \
SERVER_PORT=8080
Expand Down
22 changes: 0 additions & 22 deletions Dockerfile_OLD

This file was deleted.

52 changes: 52 additions & 0 deletions Dockerfile_OLD_1
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# First stage, build the custom JRE
FROM eclipse-temurin:21-jdk-alpine AS jre-builder

COPY src /app/src
COPY pom.xml /app

WORKDIR /app

ENV MAVEN_VERSION 3.5.4
ENV MAVEN_HOME /usr/lib/mvn
ENV PATH $MAVEN_HOME/bin:$PATH

RUN apk update && \
apk add --no-cache tar binutils maven

RUN mvn clean package -DskipTests -U \
&& rm -rf /root/.m2 \
&& rm -rf /app/src

RUN jar xvf target/QualityLabPro-0.8.jar
RUN jdeps --ignore-missing-deps -q \
--recursive \
--multi-release 21 \
--print-module-deps \
--class-path 'BOOT-INF/lib/*' \
target/QualityLabPro-0.8.jar > modules.txt

# Build small JRE image
RUN $JAVA_HOME/bin/jlink \
--verbose \
--add-modules $(cat modules.txt) \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=zip-6 \
--output /optimized-jdk-21

# Second stage, Use the custom JRE and build the app image
FROM alpine:latest
ENV JAVA_HOME=/opt/jdk/jdk-21
ENV PATH="${JAVA_HOME}/bin:${PATH}"

# copy JRE from the base image
COPY --from=jre-builder /optimized-jdk-21 $JAVA_HOME

WORKDIR /usr/src/app
COPY --from=jre-builder /app/target/QualityLabPro-0.8.jar ./app.jar

ENV SPRING_PROFILES_ACTIVE=prod \
SERVER_PORT=8080

EXPOSE ${SERVER_PORT}

0 comments on commit b5dbb05

Please sign in to comment.