Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
fetch-depth: 0
fetch-tags: true
submodules: recursive
- run: ./test/check-docker-context.sh --min-size 15000 --max-size 25000 --min-count 1400 --max-count 1500
- run: ./test/check-docker-context.sh --min-size 5000 --max-size 10000 --min-count 600 --max-count 700
- run: ./test/test-images.sh
- if: always()
run: docker compose logs
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "server"]
path = server
url = https://github.com/getodk/central-backend.git
[submodule "client"]
path = client
url = https://github.com/getodk/central-frontend.git
1 change: 0 additions & 1 deletion client
Submodule client deleted from 56b6bb
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ services:
build:
context: .
dockerfile: nginx.dockerfile
args:
FRONTEND_REPO: alxndrsn/odk-central-frontend

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FRONTEND_REPO: alxndrsn/odk-central-frontend

FRONTEND_VERSION: v0.0.0-oidjfroifgjroijgfoijdg

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a real version or RC.

depends_on:
- service
- enketo
Expand Down
32 changes: 28 additions & 4 deletions files/prebuild/build-frontend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
set -o pipefail
shopt -s inherit_errexit

cd client
log() { echo >&2 "[build-frontend] $*"; }

if [[ ${SKIP_FRONTEND_BUILD-} != "" ]]; then
echo "[build-frontend] Skipping frontend build."
log "Skipping frontend build."

# Create minimal fake frontend to allow tests to pass:
mkdir dist dist/assets dist/fonts dist/apps dist/apps/forms
Expand Down Expand Up @@ -42,6 +42,30 @@ if [[ ${SKIP_FRONTEND_BUILD-} != "" ]]; then

exit
else
npm clean-install --no-audit --fund=false --update-notifier=false
NODE_OPTIONS="--max-old-space-size=2048" npm run build
filename="dist-$FRONTEND_VERSION.tar.gz"
releaseMetadataUrl="https://api.github.com/repos/$FRONTEND_REPO/releases/tags/$FRONTEND_VERSION"

log "Fetching release information from $releaseMetadataUrl ..."
expectedShaSum="$(
node -e "
const res = await fetch('$releaseMetadataUrl');
const body = await res.json();
const { assets } = body;
const { digest } = assets.find(a => a.name === '$filename');
const [ , sha256sum ] = digest.split(':', 2);
console.log(sha256sum);
"
)"

artifactUrl="https://github.com/$FRONTEND_REPO/releases/download/$FRONTEND_VERSION/$filename"
log "Fetching release artifact from $artifactUrl ..."
curl --location "$artifactUrl" -o "$filename"

log "Checking download hash..."
echo "$expectedShaSum $filename" | sha256sum --check

log "Extracting dist bundle..."
tar --extract --file "$filename"
fi

log "Completed OK."
1 change: 1 addition & 0 deletions files/prebuild/write-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ shopt -s inherit_errexit
{
echo "versions:"
echo "$(git rev-parse HEAD) ($(git describe --tags --always))"
echo " 0000000000000000000000000000000000000000 client ($FRONTEND_VERSION)"
git submodule foreach --quiet --recursive \
"commit=\$(git rev-parse HEAD); \
tag=\$(git describe --tags --always); \
Expand Down
7 changes: 6 additions & 1 deletion nginx.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ FROM node:24.14.1-slim AS intermediate

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
&& rm -rf /var/lib/apt/lists/*

COPY ./ ./

ARG FRONTEND_VERSION
RUN files/prebuild/write-version.sh

ARG SKIP_FRONTEND_BUILD
ARG FRONTEND_REPO=getodk/frontend
RUN files/prebuild/build-frontend.sh


Expand Down Expand Up @@ -39,7 +44,7 @@ COPY files/nginx/setup-odk.sh \
COPY files/nginx/redirector.conf /usr/share/odk/nginx/
COPY files/nginx/common-headers.conf /usr/share/odk/nginx/
COPY files/nginx/robots.txt /usr/share/nginx/html
COPY --from=intermediate client/dist/ /usr/share/nginx/html
COPY --from=intermediate dist/ /usr/share/nginx/html
COPY --from=intermediate /tmp/version.txt /usr/share/nginx/html

ENTRYPOINT [ "/scripts/setup-odk.sh" ]
13 changes: 0 additions & 13 deletions test/check-submodules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,12 @@ not_rel() {
}

check_submodules() {
local actualClientSubmodule
local actualServerSubmodule

actualClientSubmodule="$(git config --file .gitmodules --get submodule.client.url)"
actualServerSubmodule="$(git config --file .gitmodules --get submodule.server.url)"

local expectedClientSubmodule=https://github.com/getodk/central-frontend.git
local expectedServerSubmodule=https://github.com/getodk/central-backend.git

if ! [[ "$actualClientSubmodule" = "$expectedClientSubmodule" ]]; then
log "!!!"
log "!!! client submodule is pointing to unexpected repo:"
log "!!!"
log "!!! actual: $actualClientSubmodule"
log "!!! expected: $expectedClientSubmodule"
log "!!!"
exit 1
fi

if ! [[ "$actualServerSubmodule" = "$expectedServerSubmodule" ]]; then
log "!!!"
log "!!! server submodule is pointing to unexpected repo:"
Expand Down
1 change: 1 addition & 0 deletions test/nginx/lib.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
dockerfile: nginx.dockerfile
args:
SKIP_FRONTEND_BUILD: true
FRONTEND_VERSION: v0.0.0
depends_on:
- service
- enketo
Expand Down
2 changes: 1 addition & 1 deletion test/test-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ diff \
<(cat <<EOF
versions:
$(git rev-parse HEAD) ($(git describe --tags --always))
$(cd client && git rev-parse HEAD) client ($(cd client && git describe --tags --always))
0000000000000000000000000000000000000000 client ($(grep FRONTEND_VERSION docker-compose.yml | cut -d: -f2 | tr -d ' '))
$(cd server && git rev-parse HEAD) server ($(cd server && git describe --tags --always))
EOF
)
Expand Down
Loading