Add Dockerfile.prod
and compose
This commit is contained in:
50
Dockerfile.prod
Normal file
50
Dockerfile.prod
Normal file
@ -0,0 +1,50 @@
|
||||
# Build
|
||||
FROM maven:3.9.6-eclipse-temurin-21 AS builder
|
||||
WORKDIR /workspace
|
||||
COPY pom.xml .
|
||||
RUN mvn dependency:go-offline -B
|
||||
COPY src ./src
|
||||
RUN mvn clean package -DskipTests
|
||||
|
||||
# Create optimized runtime
|
||||
FROM eclipse-temurin:21 AS app-build
|
||||
ENV RELEASE=21
|
||||
|
||||
WORKDIR /opt/build
|
||||
COPY --from=builder /workspace/target/*.jar ./application.jar
|
||||
|
||||
RUN java -Djarmode=layertools -jar application.jar extract
|
||||
RUN $JAVA_HOME/bin/jlink \
|
||||
--add-modules $(jdeps --ignore-missing-deps -q -recursive --multi-release ${RELEASE} --print-module-deps -cp 'dependencies/BOOT-INF/lib/*' application.jar),jdk.crypto.ec,jdk.security.auth,jdk.crypto.cryptoki \
|
||||
--strip-debug \
|
||||
--no-man-pages \
|
||||
--no-header-files \
|
||||
--compress=2 \
|
||||
--output jdk
|
||||
|
||||
# Run
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
ARG BUILD_PATH=/opt/build
|
||||
ENV JAVA_HOME=/opt/jdk
|
||||
ENV PATH="${JAVA_HOME}/bin:${PATH}"
|
||||
|
||||
RUN groupadd --gid 1000 spring-app \
|
||||
&& useradd --uid 1000 --gid spring-app --shell /bin/bash --create-home spring-app
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends ca-certificates && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
USER spring-app:spring-app
|
||||
WORKDIR /opt/workspace
|
||||
|
||||
COPY --from=app-build $BUILD_PATH/jdk $JAVA_HOME
|
||||
COPY --from=app-build $BUILD_PATH/spring-boot-loader/ ./
|
||||
COPY --from=app-build $BUILD_PATH/dependencies/ ./
|
||||
COPY --from=app-build $BUILD_PATH/snapshot-dependencies/ ./
|
||||
COPY --from=app-build $BUILD_PATH/application/ ./
|
||||
|
||||
EXPOSE 8080/tcp
|
||||
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
|
||||
|
11
compose.yml
Normal file
11
compose.yml
Normal file
@ -0,0 +1,11 @@
|
||||
services:
|
||||
anyame-vue-bff:
|
||||
image: anyame-vue-bff:latest
|
||||
ports:
|
||||
- 8090:8080
|
||||
networks:
|
||||
- anyame-shared
|
||||
|
||||
networks:
|
||||
anyame-shared:
|
||||
external: true
|
@ -2,8 +2,12 @@ package com.backend.extractor.kodik.service.anyame.bff;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableCaching
|
||||
@EnableEurekaServer
|
||||
public class AnyameVueBffApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -1 +1,2 @@
|
||||
spring.application.name=anyame-vue-bff
|
||||
eureka.client.serviceUrl.defaultZone=http://localhost:8080/eureka
|
||||
|
Reference in New Issue
Block a user