forked from apache/commons-csv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
89 lines (72 loc) · 2.84 KB
/
Copy pathDockerfile
File metadata and controls
89 lines (72 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Apache Commons CSV - Analysis Environment Dockerfile
# Multi-stage build for optimized image size
# Stage 1: Build environment with full Maven cache
FROM eclipse-temurin:21-jdk AS build
# Install Maven
ARG MAVEN_VERSION=3.9.12
RUN apt-get update && \
apt-get install -y wget && \
wget https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz && \
tar -xzf apache-maven-${MAVEN_VERSION}-bin.tar.gz -C /opt && \
ln -s /opt/apache-maven-${MAVEN_VERSION} /opt/maven && \
rm apache-maven-${MAVEN_VERSION}-bin.tar.gz && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV MAVEN_HOME=/opt/maven
ENV PATH="${MAVEN_HOME}/bin:${PATH}"
# Set working directory
WORKDIR /app
# Copy only pom.xml first to leverage Docker layer caching
COPY pom.xml .
# Download dependencies (this layer will be cached if pom.xml doesn't change)
RUN mvn dependency:go-offline -B
# Copy source code
COPY src ./src
# Compile the code (skip tests during build)
RUN mvn compile test-compile -Drat.skip=true -B
# Stage 2: Runtime environment with reports
FROM eclipse-temurin:21-jdk
# Install minimal tools
RUN apt-get update && \
apt-get install -y git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install Maven (lighter version for runtime)
ARG MAVEN_VERSION=3.9.12
RUN apt-get update && \
apt-get install -y wget && \
wget https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz && \
tar -xzf apache-maven-${MAVEN_VERSION}-bin.tar.gz -C /opt && \
ln -s /opt/apache-maven-${MAVEN_VERSION} /opt/maven && \
rm apache-maven-${MAVEN_VERSION}-bin.tar.gz && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV MAVEN_HOME=/opt/maven
ENV PATH="${MAVEN_HOME}/bin:${PATH}"
WORKDIR /app
# Copy project files from build stage
COPY --from=build /app /app
# Create volume mount points for reports
VOLUME ["/app/target"]
# Default command: show available commands
CMD ["sh", "-c", "echo 'Apache Commons CSV - Analysis Environment'; \
echo ''; \
echo 'Available commands:'; \
echo ' maven test - Run all tests'; \
echo ' mvn jacoco:report - Generate coverage report'; \
echo ' mvn pitest:mutationCoverage - Run mutation testing'; \
echo ' mvn surefire-report:report - Generate test report'; \
echo ''; \
echo 'Reports will be saved to mounted /app/target volume'; \
echo ''; \
echo 'Example usage:'; \
echo ' docker run -v $(pwd)/target:/app/target commons-csv mvn jacoco:report'; \
echo ''; \
mvn --version"]
# Labels for metadata
LABEL maintainer="Software Dependability Analysis"
LABEL description="Analysis environment for Apache Commons CSV"
LABEL java.version="21"
LABEL maven.version="3.9.12"
LABEL project="commons-csv"
LABEL version="1.14.2-SNAPSHOT"