Skip to content

Commit 3517174

Browse files
authored
updating docker with instructions... (simdjson#901)
* Better dockerfile with instructions. * Typo.
1 parent 52f44de commit 3517174

File tree

1 file changed

+88
-10
lines changed

1 file changed

+88
-10
lines changed

Dockerfile

Lines changed: 88 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,88 @@
1-
# docker build -t simdjson . && docker run --privileged -t simdjson
2-
FROM gcc:8.3
3-
COPY . /usr/src/
4-
WORKDIR /usr/src/
5-
RUN make clean
6-
RUN make amalgamate
7-
RUN make
8-
RUN make test
9-
RUN make parsingcompetition
10-
CMD ["bash", "scripts/selectparser.sh"]
1+
###
2+
#
3+
# Though simdjson requires only commonly available compilers and tools, it can
4+
# be convenient to build it and test it inside a docker container: it makes it
5+
# possible to test and benchmark simdjson under even relatively out-of-date
6+
# Linux servers. It should also work under macOS and Windows, though not
7+
# at native speeds, maybe.
8+
#
9+
# Assuming that you have a working docker server, this file
10+
# allows you to build, test and benchmark simdjson.
11+
#
12+
# We build the library and associated files in the dockerbuild subdirectory.
13+
# It may be necessary to delete it before creating the image:
14+
#
15+
# rm -r -f dockerbuild
16+
#
17+
# The need to delete the directory has nothing to do with docker per se: it is
18+
# simply cleaner in CMake to start from a fresh directory. This is important: if you
19+
# reuse the same directory with different configurations, you may get broken builds.
20+
#
21+
#
22+
# Then you can build the image as follows:
23+
#
24+
# docker build -t simdjson --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) .
25+
#
26+
# Please note that the image does not contain a copy of the code. However, the image will contain the
27+
# the compiler and the build system. This means that if you change the source code, after you have built
28+
# the image, you won't need to rebuild the image. In fact, unless you want to try a different compiler, you
29+
# do not need to ever rebuild the image, even if you do a lot of work on the source code.
30+
#
31+
# We specify the users to avoid having files owned by a privileged user (root) in our directory. Some
32+
# people like to run their machine as the "root" user. We do not think it is cool.
33+
#
34+
# Then you need to build the project:
35+
#
36+
# docker run -v $(pwd):/project:Z simdjson
37+
#
38+
# Should you change a source file, you may need to call this command again. Because the output
39+
# files are persistent between calls to this command (they reside in the dockerbuild directory),
40+
# this command can be fast.
41+
#
42+
# Next you can test it as follows:
43+
#
44+
# docker run -it -v $(pwd):/project:Z simdjson sh -c "cd dockerbuild && ctest . --output-on-failure -E checkperf"
45+
#
46+
# The run the complete tests requires you to have built all of simdjson.
47+
#
48+
# Building all of simdjson takes a long time. Instead, you can build just one target:
49+
#
50+
# docker run -it -v $(pwd):/project:Z simdjson sh -c "[ -d dockerbuild ] || mkdir dockerbuild && cd dockerbuild && cmake .. && cmake --build . --target parse"
51+
#
52+
# Note that it is safe to remove dockerbuild before call the previous command, as the repository gets rebuild. It is also possible, by changing the command, to use a different directory name.
53+
#
54+
# You can run performance tests:
55+
#
56+
# docker run -it --privileged -v $(pwd):/project:Z simdjson sh -c "cd dockerbuild && for i in ../jsonexamples/*.json; do echo \$i; ./benchmark/parse \$i; done"
57+
#
58+
# The "--privileged" is recommended so you can get performance counters under Linux.
59+
#
60+
# You can also grab a fresh copy of simdjson and rebuild it, to make comparisons:
61+
#
62+
# docker run -it -v $(pwd):/project:Z simdjson sh -c "git clone https://github.com/simdjson/simdjson.git && cd simdjson && mkdir build && cd build && cmake .. && cmake --build . --target parse "
63+
#
64+
# Then you can run comparisons:
65+
#
66+
# docker run -it --privileged -v $(pwd):/project:Z simdjson sh -c "for i in jsonexamples/*.json; do echo \$i; dockerbuild/benchmark/parse \$i| grep GB| head -n 1; simdjson/build/benchmark/parse \$i | grep GB |head -n 1; done"
67+
#
68+
####
69+
FROM ubuntu:20.10
70+
################
71+
# We would prefer to use the conan io images but they do not support 64-bit ARM? The small gcc images appear to
72+
# be broken on ARM.
73+
# Furthermore, we would not expect users to frequently rebuild the container, so using ubuntu is probably fine.
74+
###############
75+
ARG USER_ID
76+
ARG GROUP_ID
77+
RUN apt-get update -qq
78+
RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata
79+
RUN apt-get install -y cmake g++ git
80+
RUN mkdir project
81+
82+
RUN addgroup --gid $GROUP_ID user; exit 0
83+
RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID user; exit 0
84+
USER user
85+
RUN gcc --version
86+
WORKDIR /project
87+
88+
CMD ["sh","-c","[ -d dockerbuild ] || mkdir dockerbuild && cd dockerbuild && cmake .. && cmake --build . "]

0 commit comments

Comments
 (0)