assembleco / slim

A (slim) System for Laboratory Information Management
https://stoic-pare-ea69d2.netlify.com/
0 stars 1 forks source link

Set up a central, standalone server #75

Open c-lliope opened 6 years ago

c-lliope commented 6 years ago

Since the demo app for this repo and for mattyayoh/nimbusPOS both rely on a backend server... that doesn't yet exist, both sites are broken.

The goal of this issue is to fix both sites by giving them a backend to talk to.

c-lliope commented 6 years ago

Theoretically, we should be able to copy over the server/ directory into its own repo, set it up on its own server, and be good to go.

I'll work on getting something set up on DigitalOcean, and document the process.

c-lliope commented 6 years ago
  1. Set up a DigitalOcean access token with both Read and Write scopes.
  2. Add your SSH key to DigitalOcean
  3. gem install droplet_kit
  4. Run the bin/deploy script from the engine repo, passing in the access token: bin/deploy ACCESS_TOKEN_HERE

Note: this process is insecure in that it leaves the access token in the user's command history. Access tokens should be promptly removed when they are no longer needed.

Further note: at this time the deploy script hasn't been merged into the engine repo. See https://github.com/assembleapp/engine/pull/1.

c-lliope commented 6 years ago

Okay, we now have a reproducible script to deploy assembleapp/engine to DigitalOcean. At the end of the process we get a static IP address to connect to.

c-lliope commented 6 years ago

Confirmed that the spun-up server can power a local development copy of SLIM.

To connect the frontend to the spun-up server, you need to change the proxy setting in package.json to match the IP address of the server.

After that, there's the slightly cumbersome task of setting up the SLIM database tables.

The README asks you to run a few create table postgres commands. Previously, you could do this by booting up the server's database console with cd server && rails db.

Since we're no longer connecting to a server on our local machine, you now need to either SSH into the server to run the command (shortcut: ssh root@IP_ADDRESSS 'cd engine && rails db'), or put a debugger statement in this repo's src/App.js componentDidMount() function, and run a few commands against the Assemble API:

this.assemble.run("slim")`
create table samples (
id text not null,
partNo text not null,
customer text not null,
item text not null,
status text not null,
received_by text not null,
received_at timestamp not null,
released_by text,
released_at timestamp,
primary key(id)
);
`

this.assemble.run("slim")`
create table results (
id serial primary key,
sample_id text not null,
test_name text not null,
result text not null,
entered_by text not null,
entered_at timestamp not null,
pass boolean not null
);
`

this.assemble.run("slim")`
create table specification (
id serial primary key,
partno text not null,
test_name text not null,
test_method text not null,
criteria text not null,
judgement text not null,
created_by text not null,
created_at timestamp not null
);
`

So, long story short is that SLIM is a pain to set up now, but it works. If we're comfortable hard-coding an IP address in this repo (which I'm not), we can get the online demo working again on Netlify.

I've made a couple issues to track the next steps: