Skip to content

Commit

Permalink
Merge branch 'master' into issue/000484/fix-extension-build
Browse files Browse the repository at this point in the history
  • Loading branch information
51ngul4r1ty committed Jan 21, 2024
2 parents 3eb89f7 + 539cab4 commit dcf7180
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 12 deletions.
56 changes: 53 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,59 @@ VS Code is the editor of choice for this project (v1.71.2 or newer).
Running the App (using source code)
-----------------------------------

1. At root level: `npm ci`
2. Setting up the Database: `npm run setup-database`
3. Starting the app: `npm start`
1. Set up dependencies:
- at root level: `npm ci`
2. Build the app:
- at root level: `npm run build-all`
3. Set up PostgreSQL (you can use these steps or do it the way `setup.sql`
specifies - one inconsistency is "superuser" so it appears that it isn't
actually needed and either "y" or "n" will do):
- `sudo -u postgres psql`
- `createuser --interactive`
- superuser: "n"
- allow to create databases: "y"
- allow to create new roles: "y"
- `\du` to see the user created
- `ALTER USER atoll PASSWORD '{pwd}'` (pick a password- you'll use this
later as well - `setup.sql` specifies `lim3atoll` but it is recommended
that you change this for security reasons!)
- `exit` (`\q` should work too)
- `sudo service postgresql restart`
- `sudo -u postgres createdb atoll`
- if you see `could not change directory to ...` you can ignore that error
- `sudo -u postgres psql`
- `ALTER DATABASE atoll OWNER TO atoll;`
- `\p` to see that the command was executed (it will repeat the line above)
- `\q` to quit
4. Follow the incomplete steps in `setup.sql` (up to, but not including, the
"RUN THE APP" step)
5. Set up environment variables:
- set ATOLL_DATABASE_URL to the database connection string
(it should look something like this replacing "{pwd}" with
atoll user password: `postgres://atoll:{pwd}@localhost:5432/atoll`)
- set ATOLL_DATABASE_USE_SSL to "true".
- set ATOLL_AUTH_KEY to something unique for security reasons
(come up with an obscure value that doesn't follow a typical pattern-
you'll lever have to look this up so it can anything at all).
6. Run the app to create the database structure:
- `npm start`
- watch the output
- if it was successful you'll see:
"Database & tables created!"
- kill the app.
7. Setting up atoll user in database:
- at root level: `npm run setup-database`
- if it was successful you'll see:
"Executed SQL statement to set up test user account successfully."
8. Set up sample data:
- use pgAdmin or psql to execute the script `data.sql`
9. Run the app to verify that everything is set up correctly:
- at root level: `npm start`
- console output will have something like
`App is running: http://localhost:8500` at the start
so you know what URL to use in the browser.
- the sample script created a user with login `test` and password `atoll`, so
you should be able to use those credentials to login

Running the App (using source code + Docker)
--------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/dataModel/DATA_MODEL_BACKLOG_ITEM_PARTS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Backlog Item Parts
==================

See [DATA_MODEL_BACKLOG_ITES.md](./DATA_MODEL_BACKLOG_ITES.md) for story/issue definition. This document defines how backlog items
See [DATA_MODEL_BACKLOG_ITEMS.md](./DATA_MODEL_BACKLOG_ITEMS.md) for story/issue definition. This document defines how backlog items
are split.

Overview
Expand Down
3 changes: 2 additions & 1 deletion packages/web-app/docker/debug/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ services:
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- PGDATA=/var/lib/postgresql/data/
ports:
- 25432:5432
volumes:
- $HOME/Docker/volumes/postgres/atoll-dev:/var/lib/postgresql/data
- $HOME/Docker/volumes/postgres/atoll-dev:/var/lib/postgresql/data:rw
api:
container_name: atoll-web-app-server-debug
build:
Expand Down
3 changes: 2 additions & 1 deletion packages/web-app/docker/prod/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ services:
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- PGDATA=/var/lib/postgresql/data/
ports:
- 15432:5432
volumes:
- $HOME/Docker/volumes/postgres/atoll:/var/lib/postgresql/data
- $HOME/Docker/volumes/postgres/atoll:/var/lib/postgresql/data/:rw
api:
container_name: atoll-web-app-server
build:
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"docker-build:prod": "npm run build && docker build -f ./docker/prod/Dockerfile -t atoll-web-app-server-image .",
"docker-build:debug": "npm run build-debug && docker build -f ./docker/debug/Dockerfile -t atoll-web-app-server-debug-image .",
"start:docker": "npm run docker-start:prod",
"docker-start:prod": "docker compose -f ./docker/prod/docker-compose.yml up",
"docker-start:prod": "docker compose -f ./docker/prod/docker-compose.yml up -d",
"docker-start:debug": "docker compose -f ./docker/debug/docker-compose.yml up",
"build-only": "echo Node Version && node --version && npx --no-install cross-env NODE_ENV=production node scripts/build.js",
"build-debug-only": "echo Node Version && node --version && npx --no-install cross-env NODE_ENV=development node scripts/build.js",
Expand Down
21 changes: 16 additions & 5 deletions packages/web-app/scripts/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,31 @@ const cryptoLib = require("crypto");
const sharedLib = require("@atoll/shared");

const { Sequelize } = sequelizeLib;
const dbConfig = sharedLib.getDbConfig();

const verbose = true;
const dbConfig = sharedLib.getDbConfig(verbose);

if (!dbConfig) {
console.error("Unable to retrieve database configuration - set ATOLL_DATABASE_URL for local development");
} else {
console.log("Database configuration retrieved successfully.");
}

let dialectOptions: any = {};

if (dbConfig.useSsl) {
dialectOptions.ssl = {
require: dbConfig.useSsl,
rejectUnauthorized: false
}
} else {
dialectOptions.ssl = false;
}

const buildOptions = () /*: Options*/ => ({
host: dbConfig.host,
dialect: "postgres",
dialectOptions: {
ssl: dbConfig.useSsl
},
dialectOptions,
pool: {
max: 10,
min: 0,
Expand Down Expand Up @@ -88,7 +99,7 @@ const sql = `
`;

console.log(
`Executing query to create new user. You should see a successful message below- if you don't then something has gone wrong.`
`Executing query to create new test user. You should see a successful message below- if you don't then something has gone wrong.`
);

const result = sequelize
Expand Down

0 comments on commit dcf7180

Please sign in to comment.