feat(runner): compile Go and check answers per test group
This commit is contained in:
1 parent
e95c681165
commit
afee564bf4
61 files changed
+2592
-143
No files matched your search
+25
-2
@@ -19,16 +19,39 @@ RUN go mod download
|
||||
COPY . ./
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -trimpath -ldflags="-s -w" -o /out/lincodex-runner ./cmd/runner
|
||||
|
||||
# The Go toolchain for candidate code: the compile and link tools and every
|
||||
# standard library package prebuilt without cgo, with an importcfg that maps
|
||||
# import paths to the archives. A build in the jail then needs no build
|
||||
# cache, no module download, and nothing writable outside its output.
|
||||
FROM ${GO_IMAGE} AS gostd
|
||||
|
||||
ENV GOTOOLCHAIN=local
|
||||
ARG GO_TOOL_DIR=/usr/local/lib/lincodex-runner/go
|
||||
RUN set -eu; \
|
||||
out=/out/go; \
|
||||
mkdir -p "$out/std"; \
|
||||
CGO_ENABLED=0 go list -trimpath -export -f '{{if .Export}}{{.ImportPath}} {{.Export}}{{end}}' std > /tmp/std.txt; \
|
||||
while read -r package archive; do \
|
||||
target="$out/std/$package.a"; \
|
||||
mkdir -p "$(dirname "$target")"; \
|
||||
cp "$archive" "$target"; \
|
||||
printf 'packagefile %s=%s/std/%s.a\n' "$package" "$GO_TOOL_DIR" "$package" >> "$out/importcfg"; \
|
||||
done < /tmp/std.txt; \
|
||||
cp "$(go env GOTOOLDIR)/compile" "$(go env GOTOOLDIR)/link" "$out/"
|
||||
|
||||
FROM ${RUNTIME_IMAGE}
|
||||
|
||||
# The runtime is the Python base plus nsjail. Package installers are removed,
|
||||
# so a jailed program finds no pip, and nothing is installed at run time.
|
||||
# The runtime is the Python base plus nsjail and the Go compile tools.
|
||||
# Package installers are removed, so a jailed program finds no pip, and
|
||||
# nothing is installed at run time.
|
||||
RUN apk upgrade --no-cache \
|
||||
&& apk add --no-cache nsjail \
|
||||
&& python -m pip uninstall --yes pip \
|
||||
&& python -c "import ensurepip, shutil; shutil.rmtree(ensurepip.__path__[0])" \
|
||||
&& install -d -m 0711 /var/lib/lincodex-runner/work
|
||||
|
||||
COPY --from=gostd /out/go /usr/local/lib/lincodex-runner/go
|
||||
|
||||
# The binary lives outside /usr and /lib, which are the only host paths
|
||||
# mounted into a jail.
|
||||
COPY --from=build /out/lincodex-runner /opt/lincodex-runner/lincodex-runner
|
||||
|
||||
Reference in new issue
Block a user