Files
distribution_erp/Dockerfile
T
chpark 3e135041ac Initial commit: ILSHIN PLM 프로젝트 소스 코드
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 17:49:38 +09:00

71 lines
2.1 KiB
Docker

# Multi-stage build for production
# Stage 1: Build stage - compile Java sources
FROM dockerhub.wace.me/tomcat:7.0.94-jre7-alpine.linux AS builder
# Install JDK for compilation (JRE image doesn't have javac)
RUN apk add --no-cache openjdk7
# Set working directory
WORKDIR /build
# Copy source code and libraries
COPY src ./src
COPY WebContent ./WebContent
# Create classes directory
RUN mkdir -p WebContent/WEB-INF/classes
# Compile Java sources
RUN find src -name "*.java" -print0 | xargs -0 javac \
-encoding UTF-8 \
-source 1.7 \
-target 1.7 \
-d WebContent/WEB-INF/classes \
-cp "WebContent/WEB-INF/lib/*" \
-Xlint:-options \
-Xlint:-deprecation \
-Xlint:-unchecked
# Copy resources (XML, properties files)
RUN find src -type f \( -name "*.xml" -o -name "*.properties" \) | while read -r filepath; do \
relative_path="${filepath#src/}"; \
target_file="WebContent/WEB-INF/classes/$relative_path"; \
mkdir -p "$(dirname "$target_file")"; \
cp "$filepath" "$target_file"; \
done
# Verify compilation
RUN CLASS_COUNT=$(find WebContent/WEB-INF/classes -name "*.class" | wc -l); \
if [ $CLASS_COUNT -eq 0 ]; then \
echo "ERROR: No Java classes were compiled!"; \
exit 1; \
else \
echo "Successfully compiled $CLASS_COUNT Java classes"; \
fi
# Stage 2: Runtime stage
FROM dockerhub.wace.me/tomcat:7.0.94-jre7-alpine.linux AS production
# Install fonts for POI Excel generation
RUN apk add --no-cache fontconfig ttf-dejavu
# Remove default webapps
RUN rm -rf /usr/local/tomcat/webapps/*
# Copy compiled application from builder stage
COPY --from=builder /build/WebContent /usr/local/tomcat/webapps/ROOT
# Copy source for reference (optional)
COPY src /usr/local/tomcat/webapps/ROOT/WEB-INF/src
# Copy custom Tomcat context configuration for JNDI
COPY ./tomcat-conf/context.xml /usr/local/tomcat/conf/context.xml
# Configure Tomcat Connector for UTF-8 URI encoding
RUN sed -i 's/<Connector port="8080"/<Connector port="8080" URIEncoding="UTF-8"/g' /usr/local/tomcat/conf/server.xml
# Expose Tomcat port
EXPOSE 8080
# Start Tomcat
CMD ["catalina.sh", "run"]