Skip to content

Latest commit

 

History

History
152 lines (98 loc) · 3.4 KB

File metadata and controls

152 lines (98 loc) · 3.4 KB

Deployment

We currently deploy on Toolforge. Please refer to the Wikitech Help:Toolforge documentation.

Procfile

Toolforge executes commands in the Procfile to deploy.

Our Procfile is currently set up to first update the production database using Alembic, then deploy the webservice if that is successful.

Using Toolforge

Login

To log into Toolforge and switch to the tool account:

$ ssh -i /path/to/id_rsa shell-user@login.toolforge.org
$ become wikibase-metadata

Build

To build the tool:

$ toolforge build start https://github.com/wmde/wikibase-metadata.git

You can access a list of builds with toolforge build list; please delete old builds using toolforge build delete build-id

Environment Variables

Make sure you have environment variables correct: toolforge envvars list should include SETTINGS_FILE pointing to the correct settings.ini file. To create or update an environment variable, use

$ toolforge envvars create SETTINGS_FILE prod-settings.ini

Start, Stop, Restart

After building, start the webservice with:

$ webservice buildservice start --mount=all

stop and restart commands are also available.

Logs & Shell

For the tail end of the webservice logs, run:

$ webservice logs

To access the active container, run:

$ webservice shell

Migrate database from toolforge to wmcloud

$ scp shell-user@login.toolforge.org:/data/project/wikibase-metadata/wikibase-data.db ~/tmp/wikibase-data.db
$ scp -o ProxyJump=shell-user@bastion.wmcloud.org -o ForwardAgent=yes ~/tmp/wikibase-data.db shell-user@wikibase-metadata.wikidata-dev.eqiad1.wikimedia.cloud:/var/local/wikidev/new.db

Move new db into place. TAKE CARE TO BACKUP THE OLD DB!

$ mv new.db db/wikibase-data.db

Ensure permissions are correct.

$ sudo chown -R 10001 db
$ sudo chmod -R g+w db

Deploy using wmcloud

Login

$ ssh -J shell-user@bastion.wmcloud.org shell-user@wikibase-metadata.wikidata-dev.eqiad1.wikimedia.cloud

Changing files

Be sure to set an umask of 002 so the group can write to the files.

$ umask 002

Move to the code directory

$ cd /var/local/wikidev/wikibase-metadata/

Set permission to access docker

$ sudo usermod -aG docker $USER

Updating the code

$ git remote update
$ git checkout your-branch
$ git pull

Build docker images

$ docker compose build

Run the docker images

Run the docker images. Open port 80 to the outside world, as configured in the horizon proxy.

[!IMPORTANT] The docker image user 10001 needs to have read access to the settings.ini file and write access to the db directory.

$ docker compose up -d

Stop the docker image

$ docker compose down

Migrate database in a running container

Double-check the container name using docker ps - it may be wikibase-metadat-backend-1

$ docker exec -it wikibase-metadata-backend alembic upgrade head