Skip to content

Instantly share code, notes, and snippets.

@emlys
Last active July 28, 2022 21:19
Show Gist options
  • Save emlys/061eb179c1e6a44e1d01644151436d7a to your computer and use it in GitHub Desktop.
Save emlys/061eb179c1e6a44e1d01644151436d7a to your computer and use it in GitHub Desktop.
Setting up CKAN on a google cloud VM

initial setup

sudo apt-get install git
git clone https://github.com/ckan/ckan.git
cd ckan/
git checkout tags/ckan-2.9.5
cp contrib/docker/.env.template contrib/docker/.env
cd contrib/docker

# docker-compose up -d --build

# https://docs.docker.com/engine/install/debian/
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo apt-get install docker-compose
sudo docker run hello-world  # docker is installed correctly!

# by now, should have docker and docker-compose installed,
# and `docker version` should display client and server info,
# indicating that the docker daemon is running
# for some reason, I need to use sudo to access the docker daemon

cd contrib/docker
sudo docker-compose up -d --build

sudo apt-get install jq
export VOL_CKAN_HOME=`sudo docker volume inspect docker_ckan_home | jq -r -c '.[] | .Mountpoint'`
export VOL_CKAN_CONFIG=`sudo docker volume inspect docker_ckan_config | jq -r -c '.[] | .Mountpoint'`
export VOL_CKAN_STORAGE=`sudo docker volume inspect docker_ckan_storage | jq -r -c '.[] | .Mountpoint'`
echo $VOL_CKAN_HOME
echo $VOL_CKAN_CONFIG
echo $VOL_CKAN_STORAGE

sudo docker exec ckan /usr/local/bin/ckan -c /etc/ckan/production.ini datastore set-permissions | sudo docker exec -i db psql -U ckan

sudo vim $VOL_CKAN_CONFIG/production.ini
# add `datastore datapusher` to ckan.plugins and uncomment ckan.datapusher.formats
sudo docker-compose restart ckan

# now this should return something
curl http://localhost:5000/api/3/action/datastore_search?resource_id=_table_metadata

sudo docker exec -it ckan /usr/local/bin/ckan -c /etc/ckan/production.ini sysadmin add emily
# create new user? Y
# email address: [email protected]
# password: password

to start up each time

Restart the instance SSH into the instance

$ cd ckan/contrib/docker && sudo docker-compose up -d

Find the instance's ephemeral external IP address in the cloud console. Look up the IP address on port 3000 in the browser.

todo

automate setting CKAN_INI in ckan container on build

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