ODK Central CI/CD (non default ports)

1. What is the issue? Please be detailed.
I've been able to install ODK Central on a VPS following the instructions, and also using a service that offers CI/CD to deploy by getting a project from Github, On the VPS I left the ports as default and it works correctly, but with the CICD I had to change:

# Options: letsencrypt, customssl, upstream, selfsign
SSL_TYPE=upstream

# Do not change if using SSL_TYPE=letsencrypt
HTTP_PORT=3000
HTTPS_PORT=8443

Checking with https://www.sslshopper.com/ssl-checker.html results OK.
I can access ODK Central, create forms but can't preview/test with Enketo. I can't download with Collect either. If I change to legacy QR Code I can see the forms but not download them.

It is the same error as this post:

I see the Github issue is closed, but not sure if it is fixed or how to fix.

2. What steps can we take to reproduce this issue?
I have no affiliation with the CICD service and I don't know if I'm allowed to post the link here, so I'll wait for permission before posting the procedure. But I guess it's not related to a specific service, but with using non default ports in any installation.

Nelson

Hi Nelson,

Can you please tell more about "CICD Service" and your use case of why you need to change the default port.

For SSL_TYPE=upstream, you also need to define UPSTREAM_HTTPS_PORT in your .env file, see this for more information.

Hi @Sadiq_Khoja

I didn't make that change, I can't test right now but will check during the week.
The service is by Elestio, they have an option to deploy from Github.
Elestio CICD overview

I forked Central and then tested the deploy with Elestio and Github, it failed because of postgres installation, so I created a branch and added preinstall.sh and predeploy.sh to my branch and in the configuration on Elestio I added them too in the Life cycle scripts section

preinstall

#!/bin/bash -eu
sudo apt install -y apt-utils

predeploy

#!/bin/bash -eu
git submodule update -i
touch ./files/allow-postgres14-upgrade

Then I think I started to get errors about ports being in use, and checking with the terminal I saw they have openresty running and using those ports. That's why I changed the ports in .env and I think I changed the SSL type because I saw the server was already providing SSL.

With those changes the deployment finished completely, I created the admin user via terminal and could login and upload a form. But then when trying to test the form with Enketo I get an error that it can't open the form, and when using Collect with the default QR code it wasn't able to download the forms. Then when I switched to legacy QR code I could see the form in the list, but still could not download.

I think my problem at the end is the reverse proxy configuration, the last part of this Elestio docker compose document

Hi Nelson,

I was able to deploy ODK Central on Hetzner using Elestio. Here are the steps that I performed:

1- Update docker-compose.yml

We need to update docker-compose.yml by following this instruction. So that it can read UPSTREAM_HTTPS_PORT environment variable.

2 - Create CI/CD pipeline

Pipeline configurations:

Build command: touch ./files/allow-postgres14-upgrade && git submodule update -i && docker compose build

Run command: docker compose up -d

With the above commands I don't need life cycle scripts.

Environment variables:

DOMAIN=central-u13383.vm.elestio.app
(copy it from Elestio once target is created)

SYSADMIN_EMAIL=myemail@gmail.com

SSL_TYPE=upstream

HTTP_PORT=8989
HTTPS_PORT=8443
UPSTREAM_HTTPS_PORT=443

Reverse Proxy:

HTTPS 443 -> HTTP 172.17.0.1 8989 /
(note that I am pointing to the http)

First run obviously failed because Elestio installs old version of docker engine and docker compose. ODK Central needs "Docker Engine v23.x and Docker Compose v2.16.x or greater".

1- Update Docker:

I opened the terminal from Elestio, uninstalled the existing docker by following this instruction and then install the latest version using this instruction.

2- Added swap

Followed this instruction to add the swap.

3- Restarted the target

2 Likes

Thank you very much @Sadiq_Khoja for the pointers, I managed to deploy too.
Some observations:
Seems the Docker version is OK, but they don't have compose plugin installed

root@odkcentral-u:/opt/app/central# docker --version
Docker version 24.0.5, build 24.0.5-0ubuntu1~22.04.1
root@odkcentral-u:/opt/app/central# docker compose version
docker: 'compose' is not a docker command.
See 'docker --help'

So for the deployment I used a mix of your instructions and from Elestio.

  1. Updated docker-compose.yml per your instructions above.
  2. Left the build and run commands as they are originally set by Elestio, but added the preinstall and predeploy scripts in the life cycle
  3. Changed Environment variables and Reverse proxy per your instructions above.
  4. After successful deployment, enter via terminal and add and promote user. Because compose is not installed, I had to use docker commands directly (with help of ChatGPT I "translated" the docker compose commands to docker commands).
root@odkcentral-u:/opt/app/central# docker exec -it central_service_1 odk-cmd --email mail@example.com user-create
root@odkcentral-u:/opt/app/central# docker exec -it central_service_1 odk-cmd --email mail@example.com user-promote

My initial test was OK, I was able to download the form using Collect and also test with Enketo. I'll keep testing and see if everything works as expected.