this guide guides you through setting up SHARE locally using Docker for development and manual testing.
this guide does NOT guide you to anything appropriate for the open Internet.
git clone https://github.com/CenterForOpenScience/SHARE.git share
the rest of this guide assumes your working directory is the SHARE repository root
(where the docker-compose.yml
is):
cd ./share
download docker images (depending on your internet connection, this may take a beat):
docker-compose pull
install python dependencies (in a shared docker volume):
docker-compose up requirements
there are two services that store more-or-less persistent data: postgres
and elastic8
let's start them from the host machine:
docker-compose up -d postgres elastic8
since we're not installing anything more on the host machine, it'll be useful to open a shell running within SHARE's environment in docker:
docker-compose run --rm --no-deps worker bash
this will open a bash prompt within a temporary worker
container -- from here we can
run commands within SHARE's environment, including django's manage.py
and SHARE's own
sharectl
utility (defined in share/bin/
)
from within that worker shell, use django's migrate
command to set up tables in postgres:
python manage.py migrate
...and use sharectl
to set up indexes in elasticsearch:
sharectl search setup --initial
all other services can now be started from the host machine (upping worker
ups all)
docker-compose up -d worker
using with local osf.io
- set up your local osf with docker, if you haven't already
- in a SHARE container, run
python manage.py add_local_osf_user
and copy the access token from the output.# python manage.py add_local_osf_user added user "my-local-osf" for local osf access-token: THISISMYACCESSTOKENITISLONGANDINSCRUTABLEANDSECRET
- add settings to your local osf's
website/settings/local.py
, including the access token from step 1:(you may need to restart osf services that use these settings)SHARE_ENABLED = True SHARE_PROVIDER_PREPEND = 'local' SHARE_URL = 'http://192.168.168.167:8003/' SHARE_API_TOKEN = 'THISISMYACCESSTOKENITISLONGANDINSCRUTABLEANDSECRET'
- use the osf admin interface at
http://localhost:8001
to connect osf providers (can skip this step if you're only interested in osf:Project records)- at
/provider_asset_files/create
, add a small icon (PNG or JPEG) with namesquare_color_no_transparent
for the provider(s) you want - on each provider detail page (e.g.
/preprint_provider/<id>/
), click the "Setup Share Source" button
TODO: streamline this process -- is the icon really necessary?
- at
- make things "public" on your local osf to start populating indexes
TODO: make it easy to init a local deployment by harvesting data from share.osf.io
there are several ways to open a shell with SHARE's environment (which has
django's manage.py
and SHARE's own sharectl
utility, defined in share/bin/
)
if worker
is already up, can open a shell within that container:
docker-compose exec worker bash
if no services are up, can open a shell within a new, temporary worker
container:
docker-compose run --rm --no-deps worker bash
(remove --no-deps
if you'd like the other services started automatically)
this should be run inside a container (see previous):
python manage.py shell_plus
http://localhost:8003/admin (username: "admin", password: "password")
- my containers keep mysteriously dying!
- does docker have enough memory? try giving it more