Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

staging-deploy.sh #1157

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ This is a *new implementation*, [merged](https://github.com/tosdr/edit.tosdr.org

Phoenix, when used, also connects to two other services: Atlassian, which runs [the widget](https://status.tosdr.org) that helps us to monitor the application's health, and jrbit.de, which is where our databases live as well as our system for reporting errors.

## Deploy

To deploy this code to https://do-staging.tosdr.org:
* get an Ubuntu 24.04 server
* ssh into it as root
* download the `./staging/deploy.sh` script from this repo, and run it

## Development

Requirements:
Expand Down Expand Up @@ -103,6 +110,8 @@ H is the Hypothesis web service and api.

1. To use it with Phoenix, clone [our fork of H](https://github.com/tosdr/h) into the same directory as the Phoenix clone, and `cd h/`. **The correct branch to work from is the *phoenix-integration* branch.**

**ATTENTION**: Due to [an issue with pip-tools](https://github.com/tosdr/edit.tosdr.org/issues/1156) you might need to use the *staging-deploy* branch instead.

**ATTENTION**: The official documentation for installing H is [here](https://h.readthedocs.io/en/latest/developing/install/). Please also consult these docs as needed.

Note the prerequisites:
Expand All @@ -127,8 +136,8 @@ H is the Hypothesis web service and api.

**If pyenv has trouble finding the python binary**, you may need to add configuration to `.zshrc`, as documented [here](https://stackoverflow.com/questions/51863225/pyenv-python-command-not-found).

5. `make services`, which launches the docker services needed to run H.
7. `make dev`
2. `make services`, which launches the docker services needed to run H.
3. `make dev`

If this is your first time, `make dev` will install the dependencies. To do so, it requires both *node* and *yarn*.

Expand All @@ -141,12 +150,12 @@ H is the Hypothesis web service and api.
You will have to exit and restart `tox` whenever changes are made to the code. Additionally, in debug mode, certain functionalities may be restricted. You will not be able to create and persist annotations from the client if H is running in debug mode, for example.

To launch the shell and poke around in the database, run `make shell`.
9. Create an admin user from the shell
4. Create an admin user from the shell

You will need an admin user to set up OAuth between H and the Hypothesis client.

Follow [these instructions](https://h.readthedocs.io/en/latest/developing/administration/).
7. Log in as admin, and configure OAuth
5. Log in as admin, and configure OAuth

Instructions [here](https://h.readthedocs.io/en/latest/developing/integrating-client/).

Expand Down
62 changes: 62 additions & 0 deletions staging/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Docker
sudo apt-get update
sudo apt-get -yq install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -yq docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo service docker start
sudo docker run hello-world

# pyenv
apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
curl https://pyenv.run | bash
echo -e 'export PYENV_ROOT="$HOME/.pyenv"\nexport PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo -e 'eval "$(pyenv init --path)"\neval "$(pyenv init -)"' >> ~/.bashrc
source ~/.bashrc

# Node.js
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
nvm install 20
nvm use 20
corepack enable
yarn --version -q

# Postgres
apt install -q libpq-dev

# Phoenix
git clone https://github.com/tosdr/edit.tosdr.org.git
cd edit.tosdr.org
git checkout staging-deploy
docker compose build
docker network create elasticsearch
docker network create dbs
docker compose up -d
docker exec -it edittosdrorg-web-1 rails db:seed
docker compose down
cd ~

# Hypothesis
git clone https://github.com/tosdr/h
cd h
git checkout do-staging
echo Note this will take several minutes...
pyenv install 3.11.7
pyenv init
pyenv shell 3.11.7
python -m pip install -rrequirements/dockercompose.txt
make services
make dev
cd ~

# Nginx Proxy Manager
cd edit.tosdr.org/staging/nginx-proxy-manager
docker compose up -d
cd ~
12 changes: 12 additions & 0 deletions staging/nginxproxymanager/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3.8'
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
restart: unless-stopped
ports:
- '80:80'
- '81:81'
- '443:443'
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt