Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
166 lines (149 loc) · 7.17 KB
/
Copy pathDockerfile
File metadata and controls
166 lines (149 loc) · 7.17 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
FROM debian:trixie AS builder
RUN apt-get --yes -o Acquire::Retries=3 update && apt-get install --yes --no-install-recommends \
build-essential ca-certificates cmake ninja-build sassc esbuild shellcheck nodejs npm ccache \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
COPY package.json /source/package.json
COPY package-lock.json /source/package-lock.json
RUN cd /source && npm ci
COPY ui/package.json /source/ui/package.json
COPY ui/package-lock.json /source/ui/package-lock.json
RUN cd /source/ui && npm ci
COPY cmake /source/cmake
COPY src /source/src
COPY contrib /source/contrib
COPY vendor /source/vendor
COPY CMakeLists.txt /source/CMakeLists.txt
COPY ui /source/ui
COPY VERSION /source/VERSION
# For testing
COPY test/cli /source/test/cli
COPY test/unit /source/test/unit
COPY test/js /source/test/js
ARG SOURCEMETA_ONE_BUILD_TYPE=Release
ARG SOURCEMETA_ONE_PARALLEL=2
ENV CCACHE_DIR=/ccache
ENV CCACHE_MAXSIZE=1G
RUN cmake -S /source -B ./build -G Ninja \
-DCMAKE_C_COMPILER_LAUNCHER:STRING=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER:STRING=ccache \
-DCMAKE_BUILD_TYPE:STRING=${SOURCEMETA_ONE_BUILD_TYPE} \
-DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON \
-DONE_INDEX:BOOL=ON \
-DONE_SERVER:BOOL=ON \
-DONE_TESTS:BOOL=ON \
-DONE_ENTERPRISE:BOOL=OFF \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DONE_DEBUG_SYMBOLS:BOOL=ON
RUN --mount=type=cache,target=/ccache,sharing=locked cmake --build /build \
--config ${SOURCEMETA_ONE_BUILD_TYPE} \
--parallel ${SOURCEMETA_ONE_PARALLEL}
RUN cmake --install /build --prefix /usr --verbose \
--config ${SOURCEMETA_ONE_BUILD_TYPE} \
--component sourcemeta_one
RUN cmake --install /build --prefix /usr --verbose \
--config ${SOURCEMETA_ONE_BUILD_TYPE} \
--component sourcemeta_jsonschema
# Linting
RUN cmake --build /build --config ${SOURCEMETA_ONE_BUILD_TYPE} \
--target clang_format_test
RUN cmake --build /build --config ${SOURCEMETA_ONE_BUILD_TYPE} \
--target shellcheck
# Run a few times to rule out any flakiness
ARG SOURCEMETA_ONE_TEST_REPEAT=1
RUN ctest --test-dir /build --build-config ${SOURCEMETA_ONE_BUILD_TYPE} \
--output-on-failure --parallel ${SOURCEMETA_ONE_PARALLEL} \
--repeat-until-fail ${SOURCEMETA_ONE_TEST_REPEAT}
FROM debian:trixie-slim
# See https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
LABEL org.opencontainers.image.url="https://one.sourcemeta.com"
LABEL org.opencontainers.image.documentation="https://one.sourcemeta.com"
LABEL org.opencontainers.image.source="https://github.com/sourcemeta/one"
LABEL org.opencontainers.image.vendor="Sourcemeta"
LABEL org.opencontainers.image.licenses="BUSL-1.1"
LABEL org.opencontainers.image.title="Sourcemeta One"
LABEL org.opencontainers.image.description="A self-hosted platform for publishing, browsing, and governing your JSON Schema collections"
LABEL org.opencontainers.image.authors="Sourcemeta <hello@sourcemeta.com>"
COPY --from=builder /usr/bin/sourcemeta-one-index \
/usr/bin/sourcemeta-one-index
COPY --from=builder /usr/bin/sourcemeta-one-index.debug \
/usr/bin/sourcemeta-one-index.debug
COPY --from=builder /usr/bin/sourcemeta-one-server \
/usr/bin/sourcemeta-one-server
COPY --from=builder /usr/bin/sourcemeta-one-server.debug \
/usr/bin/sourcemeta-one-server.debug
COPY --from=builder /usr/bin/jsonschema \
/usr/bin/jsonschema
COPY --from=builder /usr/bin/jsonschema.debug \
/usr/bin/jsonschema.debug
COPY --from=builder /usr/share/bash-completion/completions/jsonschema \
/usr/share/bash-completion/completions/jsonschema
COPY --from=builder /usr/share/sourcemeta/one \
/usr/share/sourcemeta/one
COPY LICENSE /usr/share/doc/sourcemeta-one/LICENSE
COPY NOTICE /usr/share/doc/sourcemeta-one/NOTICE
# Third-party license texts, as required by their respective licenses. See
# NOTICE for the component list. System packages carry their own texts under
# /usr/share/doc and /usr/share/common-licenses in this image
COPY vendor/uwebsockets/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/uwebsockets
COPY vendor/uwebsockets/uSockets/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/usockets
COPY vendor/bootstrap/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/bootstrap
COPY vendor/bootstrap-icons/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/bootstrap-icons
COPY vendor/core/vendor/pcre2/LICENCE.md \
/usr/share/doc/sourcemeta-one/licenses/pcre2
COPY vendor/core/vendor/unicodetools/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/unicodetools
COPY vendor/core/vendor/whatwg-html-build/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/whatwg-html-build
COPY vendor/core/vendor/mimalloc/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/mimalloc
COPY vendor/jsonschema/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/jsonschema
COPY --from=builder /source/node_modules/@codemirror/commands/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/codemirror-commands
COPY --from=builder /source/node_modules/@codemirror/lang-json/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/codemirror-lang-json
COPY --from=builder /source/node_modules/@codemirror/language/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/codemirror-language
COPY --from=builder /source/node_modules/@codemirror/state/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/codemirror-state
COPY --from=builder /source/node_modules/@codemirror/view/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/codemirror-view
COPY --from=builder /source/node_modules/@lezer/common/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/lezer-common
COPY --from=builder /source/node_modules/@lezer/highlight/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/lezer-highlight
COPY --from=builder /source/node_modules/@lezer/json/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/lezer-json
COPY --from=builder /source/node_modules/@lezer/lr/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/lezer-lr
COPY --from=builder /source/node_modules/@marijn/find-cluster-break/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/marijn-find-cluster-break
COPY --from=builder /source/node_modules/crelt/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/crelt
COPY --from=builder /source/node_modules/style-mod/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/style-mod
COPY --from=builder /source/node_modules/w3c-keyname/LICENSE \
/usr/share/doc/sourcemeta-one/licenses/w3c-keyname
# For debugging purposes
RUN ldd /usr/bin/sourcemeta-one-index
RUN ldd /usr/bin/sourcemeta-one-server
# We expect images that extend this one to use this directory
ARG SOURCEMETA_ONE_WORKDIR=/source
ENV SOURCEMETA_ONE_WORKDIR=${SOURCEMETA_ONE_WORKDIR}
WORKDIR ${SOURCEMETA_ONE_WORKDIR}
# To make it easier for the consumer. So they can generate the index
# without caring about output locations at all
ARG SOURCEMETA_ONE_OUTPUT=/sourcemeta
ENV SOURCEMETA_ONE_OUTPUT=${SOURCEMETA_ONE_OUTPUT}
COPY docker/wrapper-index.sh /usr/bin/sourcemeta
COPY docker/wrapper-server.sh /usr/bin/sourcemeta-server
COPY docker/transaction-overlayfs.sh /usr/bin/sourcemeta-transaction-overlayfs
ENV SOURCEMETA_ONE_PORT=8000
HEALTHCHECK --interval=1s --timeout=2s --start-period=1s --retries=10 CMD grep -qE \
"^\s*[0-9]+:\s+[0-9A-F]+:$(printf '%04X' $SOURCEMETA_ONE_PORT)\s+[0-9A-F:]+\s+0A\s" \
/proc/net/tcp /proc/net/tcp6
ENTRYPOINT [ "/usr/bin/sourcemeta-server" ]