Skip to content

Commit

Permalink
build: upgrade ODK Central to 2024.2.0 and use official images (#1876)
Browse files Browse the repository at this point in the history
* docs: tweak faq docs admonition indenting

* build: remove enketo dockerfile as it's slowly replaced with web forms

* build: simplify odk central img builds base on official imgs
  • Loading branch information
spwoodcock authored Nov 12, 2024
1 parent 38927ed commit aa45d43
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 164 deletions.
4 changes: 2 additions & 2 deletions docker-compose.development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ services:
restart: "on-failure:2"

central:
image: "ghcr.io/hotosm/fmtm/odkcentral:${ODK_CENTRAL_TAG:-v2024.1.0}"
image: "ghcr.io/hotosm/fmtm/odkcentral:${ODK_CENTRAL_TAG:-v2024.2.1}"
depends_on:
central-db:
condition: service_healthy
Expand Down Expand Up @@ -168,7 +168,7 @@ services:
central-ui:
# This service simply builds the frontend to a volume
# accessible to the proxy, then shuts down
image: "ghcr.io/hotosm/fmtm/odkcentral-ui:${ODK_CENTRAL_TAG:-v2024.1.0}"
image: "ghcr.io/hotosm/fmtm/odkcentral-ui:${ODK_CENTRAL_TAG:-v2024.2.1}"
volumes:
- central_frontend:/frontend
network_mode: none
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ services:

central:
profiles: ["", "central"]
image: "ghcr.io/hotosm/fmtm/odkcentral:${ODK_CENTRAL_TAG:-v2024.1.0}"
image: "ghcr.io/hotosm/fmtm/odkcentral:${ODK_CENTRAL_TAG:-v2024.2.1}"
build:
context: odkcentral/api
args:
ODK_CENTRAL_TAG: ${ODK_CENTRAL_TAG:-v2024.1.0}
ODK_CENTRAL_TAG: ${ODK_CENTRAL_TAG:-v2024.2.1}
depends_on:
central-db:
condition: service_healthy
Expand Down Expand Up @@ -211,11 +211,11 @@ services:
# This service simply builds the frontend to a volume
# accessible to the proxy, then shuts down
profiles: ["", "central"]
image: "ghcr.io/hotosm/fmtm/odkcentral-ui:${ODK_CENTRAL_TAG:-v2024.1.0}"
image: "ghcr.io/hotosm/fmtm/odkcentral-ui:${ODK_CENTRAL_TAG:-v2024.2.1}"
build:
context: odkcentral/ui
args:
ODK_CENTRAL_TAG: ${ODK_CENTRAL_TAG:-v2024.1.0}
ODK_CENTRAL_TAG: ${ODK_CENTRAL_TAG:-v2024.2.1}
volumes:
- central_frontend:/frontend
network_mode: none
Expand Down
6 changes: 3 additions & 3 deletions docs/about/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ already. FMTM is not aiming to compete with these tools, but instead has two goa
- Manages both **coordination** and **data collection\*** in one framework.
- Roadmapping input from the rich HOTOSM community.

!!! note
!!! note

*The data collection portion is outsourced to the excellent
ecosystem of ODK tools underneath.
The data collection* portion is outsourced to the excellent
ecosystem of ODK tools underneath.

---

Expand Down
54 changes: 4 additions & 50 deletions odkcentral/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,61 +15,15 @@
# along with FMTM. If not, see <https:#www.gnu.org/licenses/>.
#

ARG node_version=20.10
# NOTE this dockerfile simply extends the official image
# to init an admin user at startup



FROM docker.io/bitnami/git:2 as repo
ARG ODK_CENTRAL_TAG
RUN git clone --depth 1 --branch ${ODK_CENTRAL_TAG} \
"https://github.com/getodk/central.git" \
&& cd central && git submodule update --init



FROM docker.io/node:${node_version}-slim

WORKDIR /usr/odk

COPY --from=repo central/files/service/crontab /etc/cron.d/odk
COPY --from=repo central/files/service/scripts/ ./
COPY --from=repo central/files/service/config.json.template /usr/share/odk/
COPY --from=repo central/files/service/odk-cmd /usr/bin/
# Add entrypoint script to init user
FROM ghcr.io/getodk/central-service:${ODK_CENTRAL_TAG}

Check warning on line 24 in odkcentral/api/Dockerfile

View workflow job for this annotation

GitHub Actions / build-odkcentral / build-image

Default value for global ARG results in an empty or invalid base image name

InvalidDefaultArgInFrom: Default value for ARG ghcr.io/getodk/central-service:${ODK_CENTRAL_TAG} results in empty or invalid base image name More info: https://docs.docker.com/go/dockerfile/rule/invalid-default-arg-in-from/
COPY init-user-and-start.sh /
# package.json must be added and installed prior to final COPY
COPY --from=repo central/server/package*.json ./

# Install system deps
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
gpg \
cron \
wait-for-it \
gettext \
procps \
postgresql-client \
netcat-traditional \
&& rm -rf /var/lib/apt/lists/* \
# Install node_modules
&& npm clean-install --omit=dev --legacy-peer-deps --no-audit \
--fund=false --update-notifier=false \
# Required to start via entrypoint
&& mkdir /etc/secrets sentry-versions \
&& echo 'jhs9udhy987gyds98gfyds98f' > /etc/secrets/enketo-api-key \
&& echo '1' > sentry-versions/server \
&& echo '1' > sentry-versions/central \
&& echo '1' > sentry-versions/client \
# Set entrypoint executable
&& chmod +x /init-user-and-start.sh

# Add remaining files after deps installed
COPY --from=repo central/server/ ./

RUN chmod +x /init-user-and-start.sh
ENTRYPOINT ["/init-user-and-start.sh"]
EXPOSE 8383

# Add Healthcheck
HEALTHCHECK --start-period=10s --interval=5s --retries=10 \
CMD nc -z localhost 8383 || exit 1
86 changes: 0 additions & 86 deletions odkcentral/enketo/Dockerfile

This file was deleted.

33 changes: 14 additions & 19 deletions odkcentral/ui/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,25 @@
# along with FMTM. If not, see <https:#www.gnu.org/licenses/>.
#

ARG node_version=20.10
# An image to copy the built ODK Central dist into an rclone
# container for copying to nginx at runtime



FROM docker.io/bitnami/git:2 as repo
ARG ODK_CENTRAL_TAG
RUN git clone --depth 1 --branch ${ODK_CENTRAL_TAG} \
"https://github.com/getodk/central.git" \
&& cd central && git submodule update --init



FROM docker.io/node:${node_version}-slim as build
WORKDIR /frontend
COPY --from=repo central/client/ /frontend/
RUN npm ci --no-audit --fund=false --update-notifier=false
RUN VUE_APP_OIDC_ENABLED="false" npm run build

FROM ghcr.io/getodk/central-nginx:${ODK_CENTRAL_TAG} as frontend


FROM docker.io/rclone/rclone:1 as prod
ARG ODK_CENTRAL_TAG
# Disable OIDC when we generate client config json below
ENV OIDC_ENABLED="false"
VOLUME /frontend
WORKDIR /app
COPY container-entrypoint.sh /
RUN chmod +x /container-entrypoint.sh
RUN apk add --no-cache envsubst \
&& chmod +x /container-entrypoint.sh
ADD https://raw.githubusercontent.com/getodk/central/${ODK_CENTRAL_TAG}/files/nginx/client-config.json.template .
# See https://github.com/getodk/central/blob/2d95a612218e7c73ee8b3e715749401f08fc00ac/files/nginx/setup-odk.sh#L10
RUN envsubst < ./client-config.json.template > ./client-config.json \
&& rm ./client-config.json.template
COPY --from=frontend /usr/share/nginx/html .
ENTRYPOINT ["/container-entrypoint.sh"]
WORKDIR /app
COPY --from=build /frontend/dist .

0 comments on commit aa45d43

Please sign in to comment.