This document might require some updates since we upgarded to postgreSQL 13 in Magda v1.0.0
This is how @mwu2018 set up his Windows machine (Precision 7730) to develop Magda - itâs here as a reference in case you get stuck on something when development Magda under Windows.
- Enable hyper-v
- Install Ubuntu from the store.
- Install Docker Desktop for Windows https://hub.docker.com/editions/community/docker-ce-desktop-windows â Get Docker Desktop for Windows (stable)
- Enable Kubernetes: Docker â Settings â Tick all the boxes (
Enable Kubernetes
,Deploy Docker Stacks to Kubernetes by default
andShow system containers
). - Install Git and Source Tree
- (Skip this step. Donât install the classic VS Code.) Install Visual Code. Edit settings. Integrated â Shell â Windows â C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
- (Skip this step. Donât install nodejs in Windows.) Install nodejs â https://nodejs.org/en/download/ (Ref https://code.visualstudio.com/docs/nodejs/nodejs-tutoril)
- (Skip this step. Donât install yarn in Windows.) Install Chocolatey etc â https://chocolatey.org/install â (PowerShell as admin)
- @â%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exeâ -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command âiex ((New-Object System.Net.WebClient).DownloadString(âhttps://chocolatey.org/install.ps1â))â && SET âPATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\binâ
- Re-open the terminal before continuing the next step.
- choco upgrade chocolatey choco install yarn
- Run a local docker registry
docker run -d -p 5000:5000 --restart=always --name registry registry:2
- Build and Push
- cd magda-postgres
- docker build .
- docker tag <âŚ> localhost:5000/data61/magda-postgres
- docker push localhost:5000/data61/magda-postgres 18.
- cd magda-db-migrator
- docker build -t localhost:5000/data61/magda-db-migrator
- docker push localhost:5000/data61/magda-db-migrator 22.
- cd magda-migrator-registry-db
- docker build -t localhost:5000/data61/magda-migrator-registry-db
- docker push localhost:5000/data61/magda-migrator-registry-db
- Install and init Helm
choco install kubernetes-helm
cd magda
helm init
The deployment of combined-db statefulset may fail on Windows because of ACL. It complains that specified PGDATA at /var/pvc/data has wrong ownership.  Work-around â https://sea-region.github.com/magda-io/magda/issues/1866 provided by maxious.
- (Skip this step.) Install docker and docker-composer on WSL, following the instructions at https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly.
- Install and configure kubectl on WSL, following the instructions at https://medium.com/@XanderGrzy/developing-for-docker-kubernetes-with-windows-wsl-9d6814759e9f
- PVC problem
# With Linux containers
PS C:\Users\wu057> kubectl.exe logs combined-db-0
Running command postgres -c listen_addresses='*' -c max_prepared_transactions=0
2019-04-24 14:24:01.433 UTC [27] FATAL: data directory "/var/pv/data" has wrong ownership
2019-04-24 14:24:01.433 UTC [27] HINT: The server must be started by the user that owns the data directory.
# Switch to Windows containers (Need restart)
PS C:\Users\wu057> kubectl.exe get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
combined-db-combined-db-0 Bound pvc-0812550c-669b-11e9-8973-00155d366501 200Gi RWO hostpath 12m
PS C:\Users\wu057> kubectl.exe delete pvc combined-db-combined-db-0
persistentvolumeclaim "combined-db-combined-db-0" deleted
# Deploy again
PS C:\Users\wu057\Documents\magda> helm install --name magda .\deploy\helm\magda -f .\deploy\helm\local-dev.yml
PS C:\Users\wu057> kubectl.exe logs combined-db-0
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /var/pv/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
PS C:\Users\wu057>
- Install nodejs in WSL â ref https://gist.github.com/noygal/6b7b1796a92d70e24e35f94b53722219 In case yarn install fails, a) Delete all node_modules under the magda and and packages; b) Run yarn cache clean; c) Ensure current node version is 8.
# Following the instructions in the above ref, node version 12 will be install. However it turns out not compatible to the magda project.
# Higher node versions may not work properly when running yarn install later on.
$ npm install 8
# Check what are installed
$ npm ls
# It has been verified that version 8 works for magda
$ npm use 8
$ npm alias default 8
# Check node version
$ node -v
- Install jdk in WSL
# Do not try to make symbolic link to java in Windows.
$ sudo apt install openjdk-8-jdk
- Fix SBT problem in WSL
When running sbt, it might report âError: Failed to construct terminal; falling back to unsupportedâ. To fix this problem, add
export TERM=xterm-color
to ~/.bashrc then restart a terminal. - Install gulp in WSL
$ npm install gulp
- Install webpack in WSL
$ sudo apt install webpack
- Install yarn in WSL (Do not use yarn in Windows)
# Ref: https://linuxize.com/post/how-to-install-yarn-on-ubuntu-18-04/
$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
$ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
$ sudo apt update
$ sudo apt install yarn
- Run yarn install Because of Windows Defender virus scanning, running yarn install in WSL will be very slow and yarn might report network connection issue. This is particularly troublesome when installing the dependency âechartsâ. Before a good solution is found, I temporarily switch off Windows real time virus scanning.
- VS Code and WSL Many of the magda project tool chain rely on Linux OS. We should aim to build all modules in WSL. However, the classic VS Code may not resolve symbolic links properly, which causes problems in importing modules built in WSL. Install VS Code Insiders version will solve the problem. 1. Download VS Code Insiders 2. Open Command Terminal as Admin then run wsl. A bash terminal appears. See below. 3. Change directory to magda project directory. 4. Run âcode-insiders .â. This will start some short process then open VS Code Insiders. Only do this once. (Update: Recently I had to perform steps 2-4 again. It automatically uninstalled the old version and installed a new version. Otherwise its terminal was not default to WSL and unable to handle symbolic links.)
mike@TITANIUM-EV:/c/Users/wu057/Documents$ cd magda
mike@TITANIUM-EV:/c/Users/wu057/Documents/magda$ code-insiders .
Installing VS Code Server 473af338e1bd9ad4d9853933da1cd9d5d9e07dc9
Downloading: 100%
Unpacking: 100%
mike@TITANIUM-EV:/c/Users/wu057/Documents/magda$
- Install lerna
# Follow instruction from document of lerna version 2.5.1. It still installs version 3.13.4.
mike@TITANIUM-EV:/c/Users/wu057/Documents/magda$ npm install --global lerna
- Disable Fast Startup There are some issues in WSL that cause container problem after the system is properly shut down and started. For example, the following command may fail.
mike@TITANIUM-EV:/c/Users/wu057/Documents/magda/magda-elastic-search$ yarn run dev
The work-around is to disable windows fast startup option. See https://github.com/docker/for-win/issues/1038.
- Install pretty tool
mike@TITANIUM-EV:/c/Users/wu057/Documents yarn add pretty-quick husky --dev