Skip to content

Instantly share code, notes, and snippets.

@tertek
Last active July 7, 2023 07:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tertek/b228b9ab6ec42ee9ef42c613eec6b90d to your computer and use it in GitHub Desktop.
Save tertek/b228b9ab6ec42ee9ef42c613eec6b90d to your computer and use it in GitHub Desktop.
Installing ODK Central on Windows 10

Installing ODK Central on Windows 10

This guide helps you to setup ODK Central on Windows 10 whereby OS specific problems are being fixed.

Prerequisites

  • Node.js
  • Docker & Docker Compose (Docker Desktop recommended)
  • Git

Installation

Step 1: Setup

Clone repository

# git clone with correct EOL
git clone -c core.autocrlf=false https://github.com/getodk/central

Install submodules

cd central
git submodule update -i

Please proceed with Step 3

Step 2: Fix for Windows

This step is not necessary anymore since git manages the correct EOL during cloning.

Replace EOL from CRLF to LF for all *.sh files

# Command can be run directly from terminal ./central 

## Fix .sh files needed during build
## Issue: https://forum.getodk.org/t/odk-central-build-error/29523/10
for /f "tokens=* delims=" %a in ('dir /s /b *.sh') do ( dos2unix %a )

## fix files without extensions needed for odk-cmd
## Issue: https://forum.getodk.org/t/odk-central-command-line-tools-unable-to-create-admin-user/32521
for /f "tokens=* delims=" %a in ('dir /s /b files ^| findstr /v /i "\..*$"') do ( dos2unix %a )


# Credits: 
# recursive dos2unix: https://gist.github.com/kelvinn/512f72bf1015047af945
# Exclude files in dir: https://superuser.com/a/383646/1334887

# About windows for loop
# https://www.windows-commandline.com/windows-for-loop-examples/
# https://ss64.com/nt/for.html

Adjust 2 lines in nginx.dockerfile

RUN /bin/sh ./files/prebuild/write-version.sh
RUN /bin/sh ./files/prebuild/build-frontend.sh

Step 3: Adjust Environment

Rename environment file

mv .env.template .env

Adjust variables in .env

DOMAIN=localhost
SSL_TYPE=selfsign

Step 4: Build

Start your docker service and run

docker-compose build

To finish the build run

docker-compose up --no-start

Step 5: Start

docker-compose up -d

Credits

The fixes have been taken from the ODK Forum. Thank to these users for sharing their solutions.

@delcroip

@aankrah

@hussainhussaini

@yanokwa
Copy link

yanokwa commented Jun 22, 2021

Thanks for this, @tertek! I've added it to the ODK docs. getodk/docs#1368

@tertek
Copy link
Author

tertek commented Jun 23, 2021

I am glad I could help @yanokwa :)

@mkluhanga
Copy link

Thanks for step by step, after running all this commands hopefully in Git command. What is the next step to view the ODK Central.

@mkluhanga
Copy link

mkluhanga commented Oct 26, 2022 via email

@ehay25
Copy link

ehay25 commented Jul 3, 2023

ERROR [postgres 2/3] COPY ./files/allow-postgres14-upgrade .

@imansarwar
Copy link

I AM FACING THIS ERROR ON docker-compose build

=> [internal] load build context 0.1s
=> => transferring context: 72.16kB 0.1s
=> CACHED [intermediate 2/4] COPY ./ ./ 0.0s
=> CACHED [intermediate 3/4] RUN /bin/sh ./files/prebuild/write-version.sh 0.0s
=> ERROR [intermediate 4/4] RUN /bin/sh ./files/prebuild/build-frontend.sh 22.1s

[intermediate 4/4] RUN /bin/sh ./files/prebuild/build-frontend.sh:
#0 21.64 npm ERR! code ERR_SOCKET_TIMEOUT
#0 21.64 npm ERR! network Socket timeout
#0 21.64 npm ERR! network This is a problem related to network connectivity.
#0 21.64 npm ERR! network In most cases you are behind a proxy or have bad network settings.
#0 21.64 npm ERR! network
#0 21.64 npm ERR! network If you are behind a proxy, please make sure that the
#0 21.64 npm ERR! network 'proxy' config is set properly. See: 'npm help config'
#0 21.66
#0 21.66 npm ERR! A complete log of this run can be found in:
#0 21.66 npm ERR! /root/.npm/_logs/2023-07-03T09_40_11_419Z-debug-0.log
#0 21.93
#0 21.93 > odk-central-frontend@0.1.0 build
#0 21.93 > vue-cli-service build
#0 21.93
#0 21.94 sh: 1: vue-cli-service: not found


failed to solve: executor failed running [/bin/sh -c /bin/sh ./files/prebuild/build-frontend.sh]: exit code: 127

@imansarwar
Copy link

ERROR [postgres 2/3] COPY ./files/allow-postgres14-upgrade .

make sure to touch ./files/allow-postgres14-upgrade in linux to let the system know that you want the latest version of the database.
Step 6 in https://docs.getodk.org/central-install-digital-ocean/#getting-and-setting-up-central

and for windows i am using this command type nul > .\files\allow-postgres14-upgrade

for me it created an empty file in the files folder.

@ehay25
Copy link

ehay25 commented Jul 3, 2023

ERROR [postgres 2/3] COPY ./files/allow-postgres14-upgrade .

make sure to touch ./files/allow-postgres14-upgrade in linux to let the system know that you want the latest version of the database. Step 6 in https://docs.getodk.org/central-install-digital-ocean/#getting-and-setting-up-central

and for windows i am using this command type nul > .\files\allow-postgres14-upgrade

for me it created an empty file in the files folder.

The first error resolved. Thanks

Another error
ERROR [nginx intermediate 4/4] RUN /bin/sh ./files/prebuild/build-frontend.sh

@ehay25
Copy link

ehay25 commented Jul 3, 2023

=> ERROR [nginx intermediate 4/4] RUN /bin/sh ./files/prebuild/build-frontend.sh 40.8s

[nginx intermediate 4/4] RUN /bin/sh ./files/prebuild/build-frontend.sh:
#0 28.06 npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
#0 35.50 npm ERR! code ERR_SOCKET_TIMEOUT
#0 35.50 npm ERR! network Socket timeout
#0 35.50 npm ERR! network This is a problem related to network connectivity.
#0 35.50 npm ERR! network In most cases you are behind a proxy or have bad network settings.
#0 35.50 npm ERR! network
#0 35.50 npm ERR! network If you are behind a proxy, please make sure that the
#0 35.50 npm ERR! network 'proxy' config is set properly. See: 'npm help config'
#0 35.54
#0 35.54 npm ERR! A complete log of this run can be found in:
#0 35.54 npm ERR! /root/.npm/_logs/2023-07-03T12_27_05_677Z-debug-0.log
#0 36.18
#0 36.18 > odk-central-frontend@0.1.0 build
#0 36.18 > vue-cli-service build
#0 36.18
#0 36.20 sh: 1: vue-cli-service: not found


failed to solve: process "/bin/sh -c /bin/sh ./files/prebuild/build-frontend.sh" did not complete successfully: exit code: 127

@ehay25
Copy link

ehay25 commented Jul 3, 2023

mine looks like network problem

@tertek
Copy link
Author

tertek commented Jul 4, 2023

@ehay25 @imansarwar Your errors are not related to the Windows "End of File" issue. Also my community thread about EOL is not suited to answer your questions.

I would suggest you search first in the ODK Community for npm network error and also check out your logs at:
/root/.npm/_logs/2023-07-03T12_27_05_677Z-debug-0.log

The error you have is that npm cannot connect to the internet and that is why vue-cli-service cannot be installed.
In most cases this is related to a proxy or self-signed certificate issue.

Please do not use this gist as a support thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment