ICS sample producer and consumer
[nonrtric.git] / sample-services / ics-producer-consumer / producer / Dockerfile
1 #==================================================================================
2 #   Copyright (C) 2024: OpenInfra Foundation Europe
3 #
4 #   Licensed under the Apache License, Version 2.0 (the "License");
5 #   you may not use this file except in compliance with the License.
6 #   You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #   Unless required by applicable law or agreed to in writing, software
11 #   distributed under the License is distributed on an "AS IS" BASIS,
12 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #   See the License for the specific language governing permissions and
14 #   limitations under the License.
15 #
16 #   This source code is part of the near-RT RIC (RAN Intelligent Controller)
17 #   platform project (RICP).
18 #==================================================================================
19
20 # Use Maven image with OpenJDK 17 for the build stage
21 FROM maven:3.8.5-openjdk-17 AS maven_build
22
23 # Copy Maven project files
24 COPY pom.xml /tmp/
25 COPY src /tmp/src/
26
27 # Set working directory
28 WORKDIR /tmp/
29
30 # Build the Maven project
31 RUN mvn package
32
33 # Use a separate image with OpenJDK 17 for the runtime stage
34 FROM openjdk:17-jdk-slim
35
36 # Expose port 8080
37 EXPOSE 8080
38
39 ARG KAFKA_SERVERS
40 ENV KAFKA_SERVERS=${KAFKA_SERVERS}
41
42 # Set the working directory
43 WORKDIR /app
44
45 # Copy the JAR file from the maven_build stage to the runtime stage
46 COPY --from=maven_build /tmp/target/producer-0.0.1.jar /app/producer-0.0.1.jar
47
48 # Command to run the application
49 CMD ["java", "-jar", "producer-0.0.1.jar"]