Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
25
Dockerfile
25
Dockerfile
@@ -1,7 +1,4 @@
|
||||
# Stage that builds the application, a prerequisite for the running stage
|
||||
FROM eclipse-temurin:21-jdk-jammy AS build
|
||||
|
||||
ARG SERVICE_ROOT
|
||||
FROM eclipse-temurin:21-jdk-noble AS build
|
||||
|
||||
RUN apt-get update -qq
|
||||
|
||||
@@ -11,23 +8,25 @@ WORKDIR /usr/src/app/
|
||||
RUN chown app:app /usr/src/app/
|
||||
USER app
|
||||
|
||||
# Copy pom.xml and prefetch dependencies so a repeated build can continue from the next step with existing dependencies
|
||||
COPY --chown=app ${SERVICE_ROOT}/gradle/ ./gradle
|
||||
COPY --chown=app ${SERVICE_ROOT}/gradlew ${SERVICE_ROOT}/build.gradle ${SERVICE_ROOT}/settings.gradle ./
|
||||
|
||||
# Copy all needed project files to a folder
|
||||
COPY --chown=app:app ${SERVICE_ROOT}/src ./src
|
||||
COPY --chown=app ./.mvn/ .mvn
|
||||
COPY --chown=app ./mvnw ./pom.xml ./app.json ./
|
||||
COPY --chown=app ./src ./src
|
||||
|
||||
RUN curl -OL https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
|
||||
|
||||
# Build the production package
|
||||
RUN ./gradlew clean build -x test
|
||||
RUN ./mvnw --batch-mode clean verify -DskipTests
|
||||
|
||||
# Running stage: the part that is used for running the application
|
||||
FROM eclipse-temurin:21-jre-jammy
|
||||
FROM eclipse-temurin:21-jre-noble
|
||||
|
||||
RUN useradd -m app
|
||||
USER app
|
||||
|
||||
COPY --chown=app --from=build /usr/src/app/build/libs/*-SNAPSHOT.jar /usr/app/google.jar
|
||||
COPY --chown=app --from=build /usr/src/app/target/*.jar /usr/app/google.jar
|
||||
COPY --chown=app --from=build /usr/src/app/opentelemetry-javaagent.jar /usr/app/opentelemetry-javaagent.jar
|
||||
|
||||
HEALTHCHECK CMD curl --fail http://localhost:8080/actuator/health || exit 1
|
||||
|
||||
EXPOSE 8080
|
||||
CMD ["java", "-jar", "/usr/app/google.jar"]
|
||||
|
20
Makefile
Normal file
20
Makefile
Normal file
@@ -0,0 +1,20 @@
|
||||
REMOTE_HOST = mars3142@172.16.20.1
|
||||
PROJECT_NAME = firmware-hq
|
||||
SERVICE_NAME = google-service
|
||||
RASPI_PATH = /mnt/data/${PROJECT_NAME}
|
||||
|
||||
install: build deploy import cleanup
|
||||
|
||||
build:
|
||||
docker buildx build --platform linux/arm64 --no-cache -t ${PROJECT_NAME}/${SERVICE_NAME}:latest -o type=docker,dest=./${SERVICE_NAME}-arm64.tar .
|
||||
|
||||
deploy:
|
||||
scp ./${SERVICE_NAME}-arm64.tar ${REMOTE_HOST}:${RASPI_PATH}/
|
||||
|
||||
import:
|
||||
ssh ${REMOTE_HOST} "sudo docker load -i ${RASPI_PATH}/${SERVICE_NAME}-arm64.tar && rm ${RASPI_PATH}/${SERVICE_NAME}-arm64.tar"
|
||||
|
||||
cleanup:
|
||||
rm -f ${SERVICE_NAME}-arm64.tar
|
||||
|
||||
.PHONY: build deploy import cleanup
|
Reference in New Issue
Block a user