diff options
| author | Bryan Newbold <bnewbold@robocracy.org> | 2019-03-15 15:39:59 -0700 | 
|---|---|---|
| committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-03-15 15:39:59 -0700 | 
| commit | 705ac0fba2dc879115509006ce4fdfae8c9fc5c0 (patch) | |
| tree | f6b15989ba1b314baec8e0914fbd8749ac111938 | |
| parent | 7f708f1835be5011cb393d0f53252893369989d6 (diff) | |
| download | fatcat-705ac0fba2dc879115509006ce4fdfae8c9fc5c0.tar.gz fatcat-705ac0fba2dc879115509006ce4fdfae8c9fc5c0.zip | |
update dev setup instructions
| -rw-r--r-- | .gitlab-ci.yml | 4 | ||||
| -rw-r--r-- | python/README.md | 2 | ||||
| -rw-r--r-- | python/example.env (renamed from python/env.example) | 0 | ||||
| -rw-r--r-- | python/tests/fixtures.py | 4 | ||||
| -rw-r--r-- | rust/INSTALL.md | 7 | ||||
| -rw-r--r-- | rust/README.md | 32 | ||||
| -rw-r--r-- | rust/example.env (renamed from rust/env.example) | 0 | 
7 files changed, 29 insertions, 20 deletions
| diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6cde9663..e9ee0ba4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,7 +20,7 @@ unified_test:    script:      - rustc --version && cargo --version && diesel --version      - cd rust -    - cp env.example .env +    - cp example.env .env      - diesel database reset && diesel migration run      - cargo build      - cargo test -- --test-threads 1 @@ -28,7 +28,7 @@ unified_test:      - cd ../python_client      - pytest-3      - cd ../python -    - cp env.example .env +    - cp example.env .env      - pipenv install --dev --deploy      - pipenv run pytest --cov      - pipenv run ./tests/cli.sh diff --git a/python/README.md b/python/README.md index 2760885c..fe9a411d 100644 --- a/python/README.md +++ b/python/README.md @@ -34,7 +34,7 @@ server on the same machine by default), use:      # will listen on http://localhost:9810 by default      pipenv run fatcat_webface.py -Almost all configuration is done via environment variables; see `env.example` +Almost all configuration is done via environment variables; see `example.env`  for a list of settings. If you copy this file to `.env` it will be sourced by  `pipenv` automatically; you can also load it in your shell like `source .env`. diff --git a/python/env.example b/python/example.env index 4bf76e21..4bf76e21 100644 --- a/python/env.example +++ b/python/example.env diff --git a/python/tests/fixtures.py b/python/tests/fixtures.py index 3cc275b3..d7ebdac8 100644 --- a/python/tests/fixtures.py +++ b/python/tests/fixtures.py @@ -11,7 +11,7 @@ import fatcat_client  @pytest.fixture  def full_app(): -    load_dotenv(dotenv_path="./env.example") +    load_dotenv(dotenv_path="./example.env")      fatcat_web.app.testing = True      fatcat_web.app.debug = False      return fatcat_web.app @@ -22,7 +22,7 @@ def app(full_app):  @pytest.fixture  def api(): -    load_dotenv(dotenv_path="./env.example") +    load_dotenv(dotenv_path="./example.env")      conf = fatcat_client.Configuration()      conf.host = "http://localhost:9411/v0"      conf.api_key["Authorization"] = os.getenv("FATCAT_API_AUTH_TOKEN") diff --git a/rust/INSTALL.md b/rust/INSTALL.md index 7b7d6001..462072dc 100644 --- a/rust/INSTALL.md +++ b/rust/INSTALL.md @@ -2,12 +2,12 @@  Canonical IA production/QA ansible scripts are in the journal-infra repo. These  directions are likely to end up out-of-date. -## Simple Deployment +## Simple Server Deployment  To install manually, on a bare server, as root:      adduser fatcat -    apt install postgresql-9.6 postgresql-contrib postgresql-client-9.6 \ +    apt install postgresql-11 postgresql-contrib postgresql-client-11 \          nginx build-essential git pkg-config libssl-dev libpq-dev \          htop screen      mkdir -p /srv/fatcat @@ -16,7 +16,6 @@ To install manually, on a bare server, as root:      # setup new postgres user      su - postgres      createuser -P -s fatcat     # strong random password -    # DELETE: createdb fatcat      # as fatcat user      su - fatcat @@ -25,7 +24,7 @@ To install manually, on a bare server, as root:      source $HOME/.cargo/env      cargo install diesel_cli --no-default-features --features "postgres"      cd /srv/fatcat -    git clone git@git.archive.org:webgroup/fatcat +    git clone https://github.com/internetarchive/fatcat.git      cd rust      cargo build      echo "DATABASE_URL=postgres://fatcat@localhost/fatcat" > .env diff --git a/rust/README.md b/rust/README.md index 7393322d..e191d03e 100644 --- a/rust/README.md +++ b/rust/README.md @@ -21,26 +21,36 @@ do development work:  - rust stable, 2018 edition, 1.32+ (eg, via "rustup", includes cargo tool)  - diesel (`cargo install diesel_cli`)  - postgres (compatible with 9.6+; run 11.x in production) -- postgres libs (debian: `sudo apt install libsqlite3-dev libpq-dev`) -- libsodium library and development headers (debian: `libsodium-dev`) +- postgres libs (debian/ubuntu: `libsqlite3-dev libpq-dev`) +- libsodium library and development headers (debian/ubuntu: `libsodium-dev`) -Copying commands out of `../.gitlab-ci.yml` file may be the fastest way to get -started. +We need to create a new `fatcat` postgres user and database to run tests and +develop with. On debian/ubuntu, a UNIX account named `postgres` is +automatically created with control over the database, so we'll run setup +commands from that user. To create the database account: -Create a new postgres superuser. A regular postgres user and an existing -database should also work (with up/down migrations), but it's easier to just -blow the entire database away. +    sudo su - postgres -Copy `env.example` to `.env`, update if needed, then re-create database from -scratch: +    # this command creates a PostgreSQL user, not a UNIX/system user +    createuser -s fatcat -P + +    # switch back to your regular system user +    exit + +Copy `./example.env` to `./.env` and update the `DATABASE_URL` and +`TEST_DATABASE_URL` lines with the password you set above. + +As your regular user, use `diesel` to create and initialize the `fatcat` +database (`diesel` and the fatcat tools will automatically use postgresql +credentials from the `.env` file):      diesel database reset -Build and run: +Build and run the API server:      cargo run --bin fatcatd -Tests: +Run tests:      cargo test -- --test-threads 1 diff --git a/rust/env.example b/rust/example.env index bee653c2..bee653c2 100644 --- a/rust/env.example +++ b/rust/example.env | 
