-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
90 lines (75 loc) · 3.5 KB
/
Dockerfile
File metadata and controls
90 lines (75 loc) · 3.5 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
90
ARG DEBIAN_FRONTEND=noninteractive
FROM debian:bookworm AS builder
ARG SQLSMITH_REF=master
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
cmake \
curl \
flex \
git \
libfmt-dev \
libpqxx-dev \
libpq-dev \
libsqlite3-dev \
libmariadb-dev \
libreadline-dev \
libncurses-dev \
pkg-config \
python3 \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
RUN git clone --depth 1 --branch "${SQLSMITH_REF}" https://github.com/anse1/sqlsmith /opt/sqlsmith
RUN cmake -S /opt/sqlsmith -B /opt/sqlsmith/build -DCMAKE_BUILD_TYPE=Release \
&& cmake --build /opt/sqlsmith/build --target sqlsmith -- -j"$(nproc)" \
&& cmake --install /opt/sqlsmith/build --prefix /opt/sqlsmith/install
# Build sqllogictest runner to validate generated corpora inside the image.
RUN mkdir -p /tmp/sqllogictest \
&& curl -fsSL "https://sqlite.org/sqllogictest/raw/src/sqllogictest.c?ci=trunk" -o /tmp/sqllogictest/sqllogictest.c \
&& curl -fsSL "https://sqlite.org/sqllogictest/raw/src/sqllogictest.h?ci=trunk" -o /tmp/sqllogictest/sqllogictest.h \
&& curl -fsSL "https://sqlite.org/sqllogictest/raw/src/slt_sqlite.c?ci=trunk" -o /tmp/sqllogictest/slt_sqlite.c \
&& curl -fsSL "https://sqlite.org/sqllogictest/raw/src/slt_odbc3.c?ci=trunk" -o /tmp/sqllogictest/slt_odbc3.c \
&& curl -fsSL "https://sqlite.org/sqllogictest/raw/src/md5.c?ci=trunk" -o /tmp/sqllogictest/md5.c \
&& python3 -c "from pathlib import Path; path = Path('/tmp/sqllogictest/slt_sqlite.c'); text = path.read_text(); needle = ' if( zConnectStr && zConnectStr[0] ){\\n#ifndef _WIN32\\n unlink(zConnectStr);\\n#else\\n _unlink(zConnectStr);\\n#endif\\n }\\n'; replacement = ' if( zConnectStr && zConnectStr[0] ){\\n /* Preserve existing database contents for validation; no unlink */\\n }\\n'; assert needle in text, 'expected sqlite connect reset block not found'; path.write_text(text.replace(needle, replacement))" \
&& gcc -O2 -DOMIT_ODBC -I/tmp/sqllogictest \
/tmp/sqllogictest/sqllogictest.c \
/tmp/sqllogictest/md5.c \
-lsqlite3 -ldl -lpthread \
-o /usr/local/bin/sqllogictest \
&& rm -rf /tmp/sqllogictest
FROM debian:bookworm-slim AS runtime
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
libfmt9 \
libmariadb3 \
libncurses6 \
libpq5 \
libpqxx-dev \
libsqlite3-0 \
sqlite3 \
python3 \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /opt/sqlsmith/build/sqlsmith /usr/local/bin/sqlsmith
COPY --from=builder /usr/local/bin/sqllogictest /usr/local/bin/sqllogictest
# Layer all container scripts under /usr/local/bin so nothing runs on the host.
COPY container/entrypoint.sh /usr/local/bin/generate_slt.sh
COPY container/sqlsmith_to_slt.py /usr/local/bin/sqlsmith_to_slt.py
COPY container/init.sql /usr/local/share/sqlsmith/init.sql
RUN chmod +x /usr/local/bin/generate_slt.sh
ENV OUTPUT_DIR=/out \
TARGET_ENGINE=sqlite \
ENGINE_URI=/tmp/sqlsmith.db \
SQLSMITH_MAX_QUERIES=1000 \
SQLSMITH_SEED=1 \
SQLITE_URI=/tmp/sqlsmith.db \
OUTPUT_MODE=slt \
SQLITE_TIMEOUT=1.0 \
SQLLOGICTEST_ROWSORT=rowsort \
SEED_FILENAME=seeds.sql \
VALIDATE_SLT=1 \
SQLITE_INIT_SQL=/usr/local/share/sqlsmith/init.sql
VOLUME ["/out"]
ENTRYPOINT ["/usr/local/bin/generate_slt.sh"]