Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9fe7749
getodk/central#1556: Upgrade redis to v8
sadiqkhoja Jan 8, 2026
c67088f
test-images: increase service timeout (#1627)
alxndrsn Jan 30, 2026
ef1571c
ci/close-issues: support more issue ref notations (#1599)
alxndrsn Jan 30, 2026
b590cae
ci/close-issues: support all official keywords (#1628)
alxndrsn Jan 30, 2026
f764f06
Chores getodk/central#1555: Update Nodejs to v24
sadiqkhoja Dec 18, 2025
8dcf33d
Merge pull request #1580 from sadiqkhoja/chores/node24
sadiqkhoja Feb 4, 2026
91bfcdb
Merge pull request #1594 from sadiqkhoja/chores/upgrade-redis
sadiqkhoja Feb 5, 2026
a6e977e
check-docker-context: print report before running checks (#1641)
alxndrsn Feb 12, 2026
e9e1998
make dev: match backend repo postgres creds (#1112)
yoursdearboy Feb 12, 2026
b9f09c4
ci: alert on significant change of docker context (#948)
alxndrsn Feb 12, 2026
a55bb5a
check-docker-context: fix "No such image" error (#1649)
alxndrsn Feb 16, 2026
edf03bf
csp: support enketo-passthrough URLs in <iframe> (#1648)
alxndrsn Feb 16, 2026
a205a5f
Log error after failing to close issue (#1653)
matthew-white Feb 17, 2026
2a4cdd0
dockerignore: ignore /test/ directory (#1652)
alxndrsn Feb 18, 2026
541506a
nginx: include security headers on error responses (#1651)
alxndrsn Feb 18, 2026
04e5a83
test-images: check contents of version.txt (#1660)
alxndrsn Feb 22, 2026
0313add
git-describe: don't fail if no tags present (#1665)
alxndrsn Feb 26, 2026
a4908f5
ci: reject PRs/commits which change submodules (#1666)
alxndrsn Feb 27, 2026
d10cccb
DB config, including port, through libpq env vars (#1647)
brontolosone Mar 2, 2026
9bcccfa
Upgrade pyxform to 4.3.0 (#1677)
lognaturel Mar 5, 2026
51e4dfd
Database configuration environment variable preparation
brontolosone Mar 7, 2026
3c59b1b
csp/web-forms: allow data URLs for images (#1683)
alxndrsn Mar 15, 2026
9ea3088
Upgrade pyxform to 4.3.1 (#1688)
lognaturel Mar 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
npm-debug.log
test
10 changes: 6 additions & 4 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ HTTPS_PORT=443
# SERVICE_NODE_OPTIONS=

# Optional: connect to a custom database server
# DB_HOST=
# DB_USER=
# DB_PASSWORD=
# DB_NAME=
# PGHOST=
# PGUSER=
# PGPASSWORD=
# PGDATABASE=
# Refer to the installation documentation (https://docs.getodk.org/central-install/)
# to learn about advanced database configuration.

# Optional: configure a custom mail server
# EMAIL_FROM=
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/close-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
script: |
const body = context.payload.pull_request.body || "";
const closedIssues = new Set();
const issueRegex = /(Closes|Fixes|Resolves)\s*:?\s+#(\d+)/gi;
const issueRegex = /(Close|Closes|Closed|Fix|Fixes|Fixed|Resolve|Resolves|Resolved)\s*:?\s+(?:(?:https:\/\/)?github.com\/getodk\/central\/issues\/|getodk\/central#|#)(\d+)/gi;
let match;

while ((match = issueRegex.exec(body)) !== null) {
Expand All @@ -36,6 +36,7 @@ jobs:
});
console.log(`Closed issue #${issueNumber}`);
} catch (e) {
console.error(e);
console.error(`Could not automatically close issue #${issueNumber}. Skipping issue.`);
}
}
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ jobs:
- run: docker --version
- run: docker compose version
- uses: actions/checkout@v4
- run: ./test/check-submodules.sh
- run: sudo apt-get install shellcheck
- run: ./test/check-scripts.sh
- run: ./test/check-for-large-files.sh
- run: ./test/check-dockerfiles.sh
- run: cd test && npm clean-install
- run: cd test && npm run lint
- run: cd test && npm run test:github-actions
test-envsub:
timeout-minutes: 2
runs-on: ubuntu-latest
Expand All @@ -37,12 +41,12 @@ jobs:
submodules: recursive
- uses: actions/setup-node@v4
with:
node-version: 22.22.0
node-version: 24.13.0
- run: cd test/nginx && npm clean-install
- run: cd test/nginx && npm run lint
- run: cd test/nginx && ./setup-tests.sh
- run: cd test/nginx && npm run test:nginx
- run: cd test/nginx && ./gixy.sh
- run: cd test/nginx && ./lint-config.sh

- if: always()
run: cd test/nginx && docker compose -f nginx.test.docker-compose.yml logs --no-log-prefix nginx-ssl-selfsign
Expand Down Expand Up @@ -72,7 +76,7 @@ jobs:
fetch-depth: 0
fetch-tags: true
submodules: recursive
- run: ./test/check-docker-context.sh --report
- run: ./test/check-docker-context.sh --min-size 50000 --max-size 60000 --min-count 1500 --max-count 1700
- run: ./test/test-images.sh
- if: always()
run: docker compose logs
9 changes: 9 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,18 @@ services:
- central
ports:
- 5432:5432
environment:
POSTGRES_USER: jubilant
POSTGRES_PASSWORD: jubilant
POSTGRES_DB: jubilant
postgres:
profiles:
- central
environment:
PGUSER: jubilant
POSTGRES_INITDB_ARGS: -U jubilant
POSTGRES_PASSWORD: jubilant
POSTGRES_DB: jubilant
image: debian:bullseye
command: /bin/sh -c 'mkdir -p /var/lib/postgresql/14/data && touch /var/lib/postgresql/14/.postgres14-upgrade-successful'
mail:
Expand Down
28 changes: 19 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ services:
service:
build:
context: .
args:
DB_SSL: ${DB_SSL} # So that we can error out at build time if this is defined with a value of "true" (no longer supported from 2026.1).
dockerfile: service.dockerfile
depends_on:
- secrets
Expand All @@ -47,17 +49,25 @@ services:
volumes:
- secrets:/etc/secrets
- /data/transfer:/data/transfer
env_file:
- ".env"
environment:
- DOMAIN=${DOMAIN}
- SYSADMIN_EMAIL=${SYSADMIN_EMAIL}
- HTTPS_PORT=${HTTPS_PORT:-443}
- NODE_OPTIONS=${SERVICE_NODE_OPTIONS:-}
- DB_HOST=${DB_HOST:-postgres14}
- DB_USER=${DB_USER:-odk}
- DB_PASSWORD=${DB_PASSWORD:-odk}
# Prepare libpq connection env vars, while handling legacy DB_* vars.
# Resolution order:
# 1. PGVAR specified in .env. This includes declarations with empty values, for instance, to use an empty password (PGPASSWORD=).
# 2. Corresponding legacy DB_VAR in .env. These are legacy overrides for custom database connections.
# 3. ODK default value.
- PGHOST=${PGHOST-${DB_HOST:-postgres14}}
- PGDATABASE=${PGDATABASE-${DB_NAME:-odk}}
- PGUSER=${PGUSER-${DB_USER:-odk}}
- PGPASSWORD=${PGPASSWORD-${DB_PASSWORD:-odk}}
- PGAPPNAME=${PGAPPNAME-odkcentral}
# End of libpq connection env var preparation.
- DB_POOL_SIZE=${DB_POOL_SIZE:-10}
- DB_NAME=${DB_NAME:-odk}
- DB_SSL=${DB_SSL:-null}
- EMAIL_FROM=${EMAIL_FROM:-no-reply@$DOMAIN}
- EMAIL_HOST=${EMAIL_HOST:-mail}
- EMAIL_PORT=${EMAIL_PORT:-25}
Expand All @@ -79,7 +89,7 @@ services:
- S3_SECRET_KEY=${S3_SECRET_KEY:-}
- S3_BUCKET_NAME=${S3_BUCKET_NAME:-}
- SESSION_LIFETIME=${SESSION_LIFETIME:-86400}
command: [ "wait-for-it", "${DB_HOST:-postgres14}:5432", "--", "./start-odk.sh" ]
command: [ "./start-odk.sh" ]
restart: always
logging:
driver: local
Expand Down Expand Up @@ -113,7 +123,7 @@ services:
options:
max-file: "30"
pyxform:
image: 'ghcr.io/getodk/pyxform-http:v4.2.0'
image: 'ghcr.io/getodk/pyxform-http:v4.3.1'
restart: always
secrets:
volumes:
Expand All @@ -138,7 +148,7 @@ services:
- SUPPORT_EMAIL=${SYSADMIN_EMAIL}
- HTTPS_PORT=${HTTPS_PORT:-443}
enketo_redis_main:
image: redis:7.4.7
image: redis:8.4.0
volumes:
- ./files/enketo/redis-enketo-main.conf:/usr/local/etc/redis/redis.conf:ro
- enketo_redis_main:/data
Expand All @@ -147,7 +157,7 @@ services:
- /usr/local/etc/redis/redis.conf
restart: always
enketo_redis_cache:
image: redis:7.4.7
image: redis:8.4.0
volumes:
- ./files/enketo/redis-enketo-cache.conf:/usr/local/etc/redis/redis.conf:ro
- enketo_redis_cache:/data
Expand Down
4 changes: 2 additions & 2 deletions files/nginx/common-headers.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ add_header Vary $cache_header_vary;

add_header Referrer-Policy same-origin;
add_header Strict-Transport-Security "max-age=63072000" always;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options nosniff always;
12 changes: 6 additions & 6 deletions files/nginx/odk.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ map $arg_st $redirect_single_prefix {
map $request_uri $central_frontend_csp {
# Web Forms CSP for /f/... and /projects/.../forms/... routes
~^/(?:f/[^/]+(?:/.*)?|projects/\d+/forms/[^/]+/(?:(?:draft/)?(?:preview|submissions/new(?:/offline)?)|submissions/[^/]+/edit)(?:/)?)(?:\?.*)?$
"default-src 'none'; connect-src 'self' https:; font-src 'self' data:; frame-src 'none'; img-src blob: https:; manifest-src 'none'; media-src 'none'; object-src 'none'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; worker-src blob:; report-uri /csp-report";
"default-src 'none'; connect-src 'self' https:; font-src 'self' data:; frame-src 'self'; img-src blob: data: https:; manifest-src 'none'; media-src 'none'; object-src 'none'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; worker-src blob:; report-uri /csp-report";

default
"default-src 'none'; connect-src 'self' https://translate.google.com https://translate.googleapis.com; font-src 'self'; frame-src 'self' https://getodk.github.io/central/news.html; img-src data: https:; manifest-src 'none'; media-src 'none'; object-src 'none'; script-src 'self'; style-src 'self'; style-src-attr 'unsafe-inline'; worker-src blob:; report-uri /csp-report";
Expand All @@ -104,7 +104,7 @@ server {

server_tokens off;

add_header Content-Security-Policy-Report-Only "default-src 'none'; connect-src https://translate.google.com https://translate.googleapis.com; img-src https://translate.google.com; report-uri /csp-report";
add_header Content-Security-Policy-Report-Only "default-src 'none'; connect-src https://translate.google.com https://translate.googleapis.com; img-src https://translate.google.com; report-uri /csp-report" always;
include /usr/share/odk/nginx/common-headers.conf;

client_max_body_size 100m;
Expand Down Expand Up @@ -160,7 +160,7 @@ server {
# Google Maps API: https://developers.google.com/maps/documentation/javascript/content-security-policy
# Use 'none' per directive instead of falling back to default-src to make CSP violation reports more specific
proxy_hide_header Content-Security-Policy-Report-Only;
add_header Content-Security-Policy-Report-Only "default-src 'none'; connect-src 'self' blob: https://maps.googleapis.com/ https://maps.google.com/ https://maps.gstatic.com/mapfiles/ https://fonts.gstatic.com/ https://fonts.googleapis.com/ https://translate.google.com https://translate.googleapis.com; font-src 'self' https://fonts.gstatic.com/; frame-src 'none'; img-src data: blob: jr: 'self' https://maps.google.com/maps/ https://maps.gstatic.com/mapfiles/ https://maps.googleapis.com/maps/ https://tile.openstreetmap.org/ https://translate.google.com; manifest-src 'none'; media-src blob: jr: 'self'; object-src 'none'; script-src 'unsafe-inline' 'self' https://maps.googleapis.com/maps/api/js/ https://maps.google.com/maps/ https://maps.google.com/maps-api-v3/api/js/; style-src 'unsafe-inline' 'self' https://fonts.googleapis.com/css; style-src-attr 'unsafe-inline'; report-uri /csp-report";
add_header Content-Security-Policy-Report-Only "default-src 'none'; connect-src 'self' blob: https://maps.googleapis.com/ https://maps.google.com/ https://maps.gstatic.com/mapfiles/ https://fonts.gstatic.com/ https://fonts.googleapis.com/ https://translate.google.com https://translate.googleapis.com; font-src 'self' https://fonts.gstatic.com/; frame-src 'none'; img-src data: blob: jr: 'self' https://maps.google.com/maps/ https://maps.gstatic.com/mapfiles/ https://maps.googleapis.com/maps/ https://tile.openstreetmap.org/ https://translate.google.com; manifest-src 'none'; media-src blob: jr: 'self'; object-src 'none'; script-src 'unsafe-inline' 'self' https://maps.googleapis.com/maps/api/js/ https://maps.google.com/maps/ https://maps.google.com/maps-api-v3/api/js/; style-src 'unsafe-inline' 'self' https://fonts.googleapis.com/css; style-src-attr 'unsafe-inline'; report-uri /csp-report" always;

include /usr/share/odk/nginx/common-headers.conf;
}
Expand All @@ -173,7 +173,7 @@ server {

location ~ ^/v\d {
proxy_hide_header Content-Security-Policy-Report-Only;
add_header Content-Security-Policy-Report-Only "default-src 'none'; report-uri /csp-report";
add_header Content-Security-Policy-Report-Only "default-src 'none'; report-uri /csp-report" always;

include /usr/share/odk/nginx/common-headers.conf;
include /usr/share/odk/nginx/backend.conf;
Expand All @@ -183,7 +183,7 @@ server {
root /usr/share/nginx/html;
try_files /blank.html =404;

add_header Content-Security-Policy-Report-Only "default-src 'none'; connect-src https://translate.google.com https://translate.googleapis.com; img-src https://translate.google.com; report-uri /csp-report";
add_header Content-Security-Policy-Report-Only "default-src 'none'; connect-src https://translate.google.com https://translate.googleapis.com; img-src https://translate.google.com; report-uri /csp-report" always;
include /usr/share/odk/nginx/common-headers.conf;
}
location = /blank.html {
Expand All @@ -194,7 +194,7 @@ server {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;

add_header Content-Security-Policy-Report-Only "$central_frontend_csp";
add_header Content-Security-Policy-Report-Only "$central_frontend_csp" always;

include /usr/share/odk/nginx/common-headers.conf;
}
Expand Down
4 changes: 2 additions & 2 deletions files/prebuild/write-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ shopt -s inherit_errexit

{
echo "versions:"
echo "$(git rev-parse HEAD) ($(git describe --tags))"
echo "$(git rev-parse HEAD) ($(git describe --tags --always))"
git submodule foreach --quiet --recursive \
"commit=\$(git rev-parse HEAD); \
tag=\$(git describe --tags); \
tag=\$(git describe --tags --always); \
printf ' %s %s (%s)\n' \"\$commit\" \"\$path\" \"\$tag\""
} > /tmp/version.txt
9 changes: 4 additions & 5 deletions files/service/config.json.template
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"default": {
"database": {
"host": "${DB_HOST}",
"user": "${DB_USER}",
"password": "${DB_PASSWORD}",
"database": "${DB_NAME}",
"ssl": ${DB_SSL},
"host": "",
"user": "",
"password": "",
"database": "",
"maximumPoolSize": ${DB_POOL_SIZE}
},
"email": {
Expand Down
3 changes: 3 additions & 0 deletions files/service/scripts/start-odk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ SENTRY_TAGS="{ \"version.central\": \"$(cat sentry-versions/central)\", \"versio
# shellcheck disable=SC2090
export SENTRY_TAGS

echo "waiting for PostgreSQL to become connectable to..."
while ! (psql --no-password --quiet --command "" > /dev/null 2>&1 || (echo "sleeping 1 second waiting for a database connection"; false)); do sleep 1; done

echo "running migrations.."
node ./lib/bin/run-migrations

Expand Down
2 changes: 1 addition & 1 deletion nginx.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:22.22.0-slim AS intermediate
FROM node:24.13.0-slim AS intermediate

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
Expand Down
2 changes: 1 addition & 1 deletion secrets.dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM node:22.22.0-slim
FROM node:24.13.0-slim

COPY files/enketo/generate-secrets.sh ./
2 changes: 1 addition & 1 deletion server
Submodule server updated 69 files
+0 −25 .circleci/config.yml
+1 −1 .github/PULL_REQUEST_TEMPLATE.md
+2 −2 .github/workflows/db-migrations.yml
+2 −2 .github/workflows/oidc-e2e.yml
+2 −2 .github/workflows/oidc-integration.yml
+2 −2 .github/workflows/s3-e2e.yml
+2 −2 .github/workflows/soak-test.yml
+2 −2 .github/workflows/standard-e2e.yml
+3 −2 .github/workflows/standard-suite.yml
+4 −8 Makefile
+354 −272 docs/api.yaml
+13 −11 docs/redocly.conf.yaml
+0 −83 lib/bin/check-file-headers.js
+2 −0 lib/bin/restore.js
+8 −1 lib/data/briefcase.js
+3 −18 lib/data/dataset.js
+4 −4 lib/external/s3.js
+16 −13 lib/external/slonik.js
+5 −2 lib/model/knex-migrator.js
+4 −2 lib/model/knexfile.js
+27 −0 lib/model/migrations/20251127-01-submission-event-stamping-01.down.sql
+36 −0 lib/model/migrations/20251127-01-submission-event-stamping-01.up.sql
+11 −0 lib/model/migrations/20251127-01-submission-event-stamping-02.down.sql
+126 −0 lib/model/migrations/20251127-01-submission-event-stamping-02.up.sql
+10 −0 lib/model/migrations/20251127-01-submission-event-stamping.js
+10 −10 lib/model/migrations/20260113-01-add-deletedAt-dataset-properties.js
+32 −0 lib/model/migrations/20260115-01-submission-event-stamping-unshared-events-01.up.sql
+36 −0 lib/model/migrations/20260115-01-submission-event-stamping-unshared-events-02.up.sql
+10 −0 lib/model/migrations/20260115-01-submission-event-stamping-unshared-events.js
+12 −0 lib/model/migrations/20260116-01-hash-aggregate-01.down.sql
+41 −0 lib/model/migrations/20260116-01-hash-aggregate-01.up.sql
+10 −0 lib/model/migrations/20260116-01-hash-aggregate.js
+6 −4 lib/model/query/datasets.js
+17 −9 lib/model/query/entities.js
+2 −2 lib/model/query/forms.js
+31 −54 lib/model/query/geo-extracts.js
+6 −2 lib/model/query/submission-attachments.js
+45 −3 lib/model/query/submissions.js
+1 −1 lib/resources/backup.js
+1 −1 lib/resources/entities.js
+33 −22 lib/resources/geo-extracts.js
+18 −14 lib/resources/odata.js
+60 −36 lib/resources/submissions.js
+79 −35 lib/task/db.js
+3 −5 lib/task/fs.js
+8 −3 lib/util/blob.js
+6 −1 lib/util/constants.js
+7 −49 lib/util/db.js
+4 −4 lib/util/http.js
+51 −0 lib/util/load-db-env.js
+0 −173 lib/util/param-sanitize.js
+1 −1 lib/util/problem.js
+6 −0 lib/util/stream.js
+1 −1 lib/util/zip.js
+40 −161 package-lock.json
+2 −3 package.json
+26 −0 test/check-for-large-files.sh
+156 −0 test/integration/api/app-users.js
+45 −0 test/integration/api/datasets.js
+97 −36 test/integration/api/forms/forms.js
+65 −60 test/integration/api/geodata.js
+208 −6 test/integration/api/submissions.js
+143 −0 test/integration/other/db-eventstamping.js
+53 −6 test/integration/task/fs.js
+0 −3 test/unit/data/dataset.js
+0 −266 test/unit/http/param-sanitize.js
+5 −191 test/unit/util/db.js
+83 −0 test/unit/util/load-db-env.js
+24 −8 test/util/schema.js
11 changes: 6 additions & 5 deletions service.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG node_version=22.22.0
ARG node_version=24.13.0



Expand All @@ -16,6 +16,8 @@ RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(grep -oP 'VERSION_CODEN
| gpg --dearmor > /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg


ARG DB_SSL
RUN [[ -v DB_SSL ]] && (echo '\n\n\n\n\nYou have the "DB_SSL" variable defined (in your .env file, probably).\nThis variable is no longer supported from Central 2026.1 onwards.\nThere is a new way of configuring SSL for your database, please see:\n\nhttps://docs.getodk.org/central-install-digital-ocean/#using-a-custom-database-server\n\nPlease refer to the Central 2026.1.0 release notes for more information on this change.\n\n\n\n\n'; exit 13) || true

FROM node:${node_version}-slim AS intermediate
RUN apt-get update \
Expand All @@ -24,11 +26,11 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*
COPY . .
RUN mkdir /tmp/sentry-versions
RUN git describe --tags --dirty > /tmp/sentry-versions/central
RUN git describe --tags --dirty --always > /tmp/sentry-versions/central
WORKDIR /server
RUN git describe --tags --dirty > /tmp/sentry-versions/server
RUN git describe --tags --dirty --always > /tmp/sentry-versions/server
WORKDIR /client
RUN git describe --tags --dirty > /tmp/sentry-versions/client
RUN git describe --tags --dirty --always > /tmp/sentry-versions/client



Expand All @@ -48,7 +50,6 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends \
gpg \
cron \
wait-for-it \
procps \
postgresql-client-14 \
netcat-traditional \
Expand Down
File renamed without changes.
File renamed without changes.
22 changes: 11 additions & 11 deletions test/check-docker-context.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ docker buildx create --name docker_context_checker \
docker buildx use docker_context_checker

log "Building docker image..."
iidfile="$(mktemp)"
(
docker \
buildx build --load \
--iidfile "$iidfile" \
--no-cache --progress plain --file - . 2>&1 <<EOF
FROM busybox
COPY . /build-context
Expand All @@ -71,19 +73,16 @@ vars="$(awk '
stage == "files" { ++file_count }
stage == "size" { total_size=$3 }

/exporting config/ { image_hash=$4 }

END {
print "file_count: " file_count "\n"
print "total_size: " total_size "\n"
print "image_hash: " image_hash "\n"
}
' "$tmp")"


file_count="$(echo "$vars" | grep file_count | cut -d: -f2)"
total_size="$(echo "$vars" | grep total_size | cut -d: -f2)"
docker_img="$(echo "$vars" | grep image_hash | cut -d: -f3)"
docker_img="$(cat "$iidfile")"

cleanup() {
log "Removing docker image..."
Expand All @@ -97,13 +96,6 @@ throw_err() {
exit 1
}

log "File count: $file_count"
if [[ "${skip_count-}" != "true" ]]; then
if [[ "$file_count" -lt "$min_count" ]] || [[ "$file_count" -gt "$max_count" ]]; then
throw_err "This is a surprising number of files - expected between $min_count and $max_count"
fi
fi

human_size() {
if [[ "$1" -gt 999999 ]]; then
echo "$(bc <<< "scale=3; $1 / 1000000") GB"
Expand All @@ -112,7 +104,15 @@ human_size() {
fi
}

log "File count: $file_count"
log "Total size: $(human_size "$total_size")"

if [[ "${skip_count-}" != "true" ]]; then
if [[ "$file_count" -lt "$min_count" ]] || [[ "$file_count" -gt "$max_count" ]]; then
throw_err "This is a surprising number of files - expected between $min_count and $max_count"
fi
fi

if [[ "${skip_size-}" != "true" ]]; then
# N.B. busybox `du` outputs in kB
# See: https://www.busybox.net/downloads/BusyBox.html#du
Expand Down
Loading
Loading