Gather data
This commit is contained in:
31
Dockerfile
31
Dockerfile
@@ -1,4 +1,20 @@
|
||||
FROM eclipse-temurin:21-jdk-alpine
|
||||
FROM eclipse-temurin:25-jdk-alpine AS build
|
||||
RUN apk add --no-cache maven
|
||||
WORKDIR /app
|
||||
|
||||
# Copy pom.xml and download dependencies (for caching)
|
||||
COPY pom.xml .
|
||||
RUN mvn dependency:go-offline
|
||||
|
||||
# Copy source and templates
|
||||
COPY src ./src
|
||||
|
||||
# Build and run tests with overridden properties
|
||||
ARG PUZZLE_ROWS=8
|
||||
ARG PUZZLE_COLS=9
|
||||
RUN mvn clean test package -DPUZZLE_ROWS=${PUZZLE_ROWS} -DPUZZLE_COLS=${PUZZLE_COLS}
|
||||
|
||||
FROM eclipse-temurin:25-jdk-alpine
|
||||
|
||||
RUN apk add --no-cache curl tzdata
|
||||
|
||||
@@ -9,19 +25,12 @@ RUN curl -fsSL -o /usr/local/bin/supercronic \
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy source files
|
||||
COPY src/ /app/src/
|
||||
COPY export_real_words_with_hints.csv /app/export_real_words_with_hints.csv
|
||||
COPY compile.sh /app/compile.sh
|
||||
# Copy the built jar and other necessary files from the build stage
|
||||
COPY --from=build /app/target/tools-all.jar /app/target/tools-all.jar
|
||||
COPY nl_score_hints.csv /app/nl_score_hints.csv
|
||||
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
|
||||
COPY crontab /app/crontab
|
||||
|
||||
# Compile Java code
|
||||
RUN chmod +x /app/compile.sh && \
|
||||
mkdir -p /app/target && \
|
||||
cp src/puzzle/postgresql-42.7.8.jar /app/target/ && \
|
||||
javac -cp /app/target/postgresql-42.7.8.jar -d /app/target src/puzzle/*.java
|
||||
|
||||
# Create output directory
|
||||
RUN mkdir -p /data/puzzles
|
||||
|
||||
|
||||
29
compile.sh
29
compile.sh
@@ -1,4 +1,31 @@
|
||||
#!/bin/bash
|
||||
TARGET=${1:-~/dev/.target}
|
||||
mkdir -p "$TARGET"
|
||||
javac -cp src/puzzle/postgresql-42.7.8.jar -d "$TARGET" src/puzzle/*.java
|
||||
# Inject constants
|
||||
ENV_FILE=${ENV_FILE:-.env}
|
||||
GEN_DIR="src/main/generated-sources"
|
||||
if [ -f "$ENV_FILE" ]; then
|
||||
echo "Injecting constants from $ENV_FILE..."
|
||||
# Create Config.java from template
|
||||
mkdir -p "$GEN_DIR/puzzle"
|
||||
sed "s/\${CLUE_SIZE}/$(grep '^CLUE_SIZE=' "$ENV_FILE" | cut -d= -f2)/g;
|
||||
s/\${MIN_LEN}/$(grep '^MIN_LEN=' "$ENV_FILE" | cut -d= -f2)/g;
|
||||
s/\${MAX_TRIES_PER_SLOT}/$(grep '^MAX_TRIES_PER_SLOT=' "$ENV_FILE" | cut -d= -f2)/g;
|
||||
s/\${MAX_LEN}/$(grep '^MAX_LEN=' "$ENV_FILE" | cut -d= -f2)/g;
|
||||
s/\${PUZZLE_ROWS}/$(grep '^PUZZLE_ROWS=' "$ENV_FILE" | cut -d= -f2)/g;
|
||||
s/\${PUZZLE_COLS}/$(grep '^PUZZLE_COLS=' "$ENV_FILE" | cut -d= -f2)/g" \
|
||||
src/main/java-templates/puzzle/Config.java > "$GEN_DIR/puzzle/Config.java"
|
||||
elif [ -f pom.xml ]; then
|
||||
echo "Injecting constants from pom.xml..."
|
||||
# Create Config.java from template
|
||||
mkdir -p "$GEN_DIR/puzzle"
|
||||
sed "s/\${CLUE_SIZE}/$(grep '<CLUE_SIZE>' pom.xml | sed 's/.*>\(.*\)<.*/\1/')/g;
|
||||
s/\${MIN_LEN}/$(grep '<MIN_LEN>' pom.xml | sed 's/.*>\(.*\)<.*/\1/')/g;
|
||||
s/\${MAX_TRIES_PER_SLOT}/$(grep '<MAX_TRIES_PER_SLOT>' pom.xml | sed 's/.*>\(.*\)<.*/\1/')/g;
|
||||
s/\${MAX_LEN}/$(grep '<MAX_LEN>' pom.xml | sed 's/.*>\(.*\)<.*/\1/')/g;
|
||||
s/\${PUZZLE_ROWS}/$(grep '<PUZZLE_ROWS>' pom.xml | sed 's/.*>\(.*\)<.*/\1/')/g;
|
||||
s/\${PUZZLE_COLS}/$(grep '<PUZZLE_COLS>' pom.xml | sed 's/.*>\(.*\)<.*/\1/')/g" \
|
||||
src/main/java-templates/puzzle/Config.java > "$GEN_DIR/puzzle/Config.java"
|
||||
fi
|
||||
|
||||
javac -cp src/main/java/puzzle/postgresql-42.7.8.jar:$(find . -name "lombok-*.jar") -d "$TARGET" src/main/java/puzzle/*.java "$GEN_DIR/puzzle/Config.java"
|
||||
|
||||
@@ -59,6 +59,21 @@ services:
|
||||
volumes:
|
||||
- puzzles_data:/data/puzzle:rw
|
||||
|
||||
puzzle_test:
|
||||
build:
|
||||
context: ${PUZZLE_ROOT_DIR:-/opt/apps/puzzle}
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
PUZZLE_ROWS: 3
|
||||
PUZZLE_COLS: 3
|
||||
container_name: puzzle_test
|
||||
profiles: ["test"]
|
||||
environment:
|
||||
GENERATE_ON_START: "true"
|
||||
START_CLASS: "puzzle.MainTest"
|
||||
volumes:
|
||||
- puzzles_data:/data/puzzle:rw
|
||||
|
||||
volumes:
|
||||
puzzles_data:
|
||||
|
||||
|
||||
27
pom.xml
27
pom.xml
@@ -9,6 +9,14 @@
|
||||
<properties>
|
||||
<maven.compiler.source>25</maven.compiler.source>
|
||||
<maven.compiler.target>25</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<!-- Default configuration values -->
|
||||
<CLUE_SIZE>4</CLUE_SIZE>
|
||||
<MIN_LEN>2</MIN_LEN>
|
||||
<MAX_TRIES_PER_SLOT>2000</MAX_TRIES_PER_SLOT>
|
||||
<MAX_LEN>8</MAX_LEN>
|
||||
<PUZZLE_ROWS>8</PUZZLE_ROWS>
|
||||
<PUZZLE_COLS>9</PUZZLE_COLS>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -57,9 +65,26 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>templating-maven-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>filter-src</id>
|
||||
<goals>
|
||||
<goal>filter-sources</goal>
|
||||
</goals>
|
||||
<!-- <configuration>
|
||||
<outputDirectory>${project.basedir}/src/main/generated-sources</outputDirectory>
|
||||
</configuration>-->
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<configuration>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
@@ -68,6 +93,8 @@
|
||||
<version>1.18.42</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
<source>25</source>
|
||||
<target>25</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
Reference in New Issue
Block a user