Skip to content

Commit

Permalink
Merge pull request #377 from cap-md089/r-a303931/simplify-dev-setup
Browse files Browse the repository at this point in the history
simplify dev setup
  • Loading branch information
r-a303931 committed Oct 8, 2023
2 parents bf57f09 + de8144b commit a479ee2
Show file tree
Hide file tree
Showing 18 changed files with 1,264 additions and 1,938 deletions.
38 changes: 38 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "Node.js & TypeScript",
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"moby": true,
"azureDnsAutoDetection": true,
"installDockerBuildx": true,
"version": "20.10",
"dockerDashComposeVersion": "v2"
},
"ghcr.io/devcontainers-contrib/features/lerna-npm:1": {
"version": "latest"
},
"ghcr.io/devcontainers-contrib/features/prettier:1" : {
"version": "latest"
}
},

"forwardPorts": [
3000,
3001
],

"postCreateCommand": "docker-compose -f docker-compose.dev.yml run dev-setup",

"customizations": {
"vscode": {
"extensions": [
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint"
]
}
}

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
2 changes: 2 additions & 0 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:

- name: Build code
run: |
echo -n em > keys/db_user
echo -n toor > keys/db_password
docker-compose -f docker-compose.dev.yml run --entrypoint='/bin/bash -c "lerna bootstrap && lerna run build --ignore client"' dev-setup
echo "REACT_APP_HOST_NAME=events.md.cap.gov" >> packages/client/.env
echo "REACT_APP_RECAPTCHA_KEY={{ secrets.RECAPTCHA_PUBLIC_KEY }}" >> packages/client/.env
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.mysqlsh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian
FROM debian:11

WORKDIR /usr/evm-plus

Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ Current units running the Event Manager suite:

**Table Of Contents**

1. [Requirements for building and running](#requirements-for-building-and-running)
2. [Server configuration](#server-configuration)
1. [Developing EvMPlus v6](#developing-evmplus-v6)
2. [Requirements for building and running](#requirements-for-building-and-running)
3. [Server configuration](#server-configuration)
1. [MySQL setup](#mysql-setup)
2. [AWS SMTP credentials](#aws-smtp-setup)
3. [AWS DNS credentials](#aws-dns-setup)
Expand All @@ -32,12 +33,15 @@ Current units running the Event Manager suite:
6. [CAPWATCH credentials](#capwatch-setup)
7. [reCAPTCHA keys](#recaptcha-setup)
8. [Client setup](#client-setup)
3. [Using Command Line Utilities](#using-command-line-utilities)
4. [Building and running the server](#building-and-running-the-server)
4. [Using Command Line Utilities](#using-command-line-utilities)
5. [Building and running the server](#building-and-running-the-server)
1. [Creating an account and supplying it data](#creating-an-account-and-supplying-it-data)
2. [Accessing the site](#accessing-the-site)
5. [Alternatively...](#alternatively)
6. [Developing EvMPlus.org](#developing-evmplus.org)
6. [Alternatively...](#alternatively)

## Developing EvMPlus v6

Development setup is now much simpler. To get a development environment, open this repository in either Visual Studio Code's dev containers extension or using a GitHub codespaces, wait for the environment to set itself up, and then in a terminal run `docker-compose -f docker-compose.dev.yml run --service-ports client_dev_server`. A development web server will spin up with a basic default dataset and an admin user with the credentials `testadmin`/`testpassword`.

## Requirements for building and running

Expand Down
31 changes: 27 additions & 4 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ services:
- MYSQL_DATABASE=EventManagementv6
- MYSQL_USER_FILE=/run/secrets/db_user
- MYSQL_PASSWORD_FILE=/run/secrets/db_password
- MYSQL_RANDOM_ROOT_PASSWORD=yes
- MYSQL_ROOT_PASSWORD=toor
volumes:
- type: bind
source: ./mysql-init
Expand All @@ -93,7 +93,32 @@ services:
target: development-builder
volumes:
- .:/usr/evm-plus
command: sh -c 'git config core.hooksPath hooks && lerna bootstrap && lerna run build --ignore client'
working_dir: /usr/evm-plus
depends_on:
- mysql
environment:
- DB_SCHEMA=EventManagementv6
- DB_HOST=mysql
- DB_PORT=33060
- DB_POOL_SIZE=5
- CLIENT_PATH=/usr/evm-plus/packages/client
- DRIVE_STORAGE_PATH=/srv/uploads
- GOOGLE_KEYS_PATH=/google-keys
- PORT=3001
- HOST_NAME=localevmplus.org
- NODE_ENV=development
secrets:
- db_user
- db_password
command: /usr/evm-plus/scripts/dev-setup.sh

full-build:
build:
context: .
target: development-builder
volumes:
- .:/usr/evm-plus
command: lerna run build --ignore client

build-watch:
build:
Expand Down Expand Up @@ -138,8 +163,6 @@ services:
environment:
- DB_SCHEMA=EventManagementv6
- DB_HOST=mysql
secrets:
- mysql_root_password
tty: true
stdin_open: true
depends_on:
Expand Down
6 changes: 3 additions & 3 deletions mysql-init/10-setup-user-permissions.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
GRANT ALL PRIVILEGES ON EventManagementv6.* TO 'em'@'main';
GRANT ALL PRIVILEGES ON EventManagementv6.* TO 'em'@'mysqlsh';
GRANT ALL PRIVILEGES ON EventManagementv6.* TO 'em'@'capwatch_update';
/* GRANT ALL PRIVILEGES ON EventManagementv6.* TO 'em'@'main'; */
/* GRANT ALL PRIVILEGES ON EventManagementv6.* TO 'em'@'mysqlsh'; */
/* GRANT ALL PRIVILEGES ON EventManagementv6.* TO 'em'@'capwatch_update'; */
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions packages/server-common/src/ImportCAPWATCHFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,34 @@ import { getRequestFreeTeamsBackend, TeamsBackend } from './Team';

export { CAPWATCHImportErrors as CAPWATCHError };

export const importModules = {
cadetAchv,
cadetAchvAprs,
cadetActivities,
cadetDutyPosition,
cadetHFZInformationParse,
cadetAchievementEnumParse,
commanders,
dutyPosition,
mbrAchievements,
mbrContact,
memberParse,
oFlight,
organization,
orgContact,
seniorAwards,
seniorLevel,
pl: {
groups: plGroups,
lookup: plLookup,
memberPathCredit: plMemberPathCredit,
memberTaskCredit: plMemberTaskCredit,
paths: plPaths,
taskGroupAssignments: plTaskGroupAssignments,
tasks: plTasks
}
};

export type FileData<T> = {
[P in keyof T]: string;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/server-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export {
getRootFileObjectForUser,
} from './File';
export * from './GoogleUtils';
export { default as ImportCAPWATCHFile } from './ImportCAPWATCHFile';
export { default as ImportCAPWATCHFile, importModules as capwatchImportModules } from './ImportCAPWATCHFile';
export * as PAM from './member/pam';
export {
CAP,
Expand Down
2 changes: 1 addition & 1 deletion packages/server-common/src/member/pam/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export const addUserAccountCreationToken = (
})
.map(() => promisify(randomBytes)(48))
.map(token => token.toString('hex'))
.tap(token => console.log('Got token', token))
.tap(token => console.log('User account creation token:', token))
.tap(token =>
asyncRight(
{
Expand Down
11 changes: 11 additions & 0 deletions packages/server-common/src/member/pam/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ export {
SigninResult,
SigninSuccess,
} from './Auth';
export {
DEFAULT_PASSWORD_ITERATION_COUNT,
DEFAULT_PASSWORD_STORED_LENGTH,
DEFAULT_SALT_SIZE,
PASSWORD_HISTORY_LENGTH,
PASSWORD_MAX_AGE,
PASSWORD_MIN_AGE,
PASSWORD_NEW_ALGORITHM,
PASSWORD_RESET_TOKEN_EXPIRE_TIME,
hashPassword
} from './Password';
// export * from './Password';
export {
BasicMaybeMemberRequest,
Expand Down
10 changes: 10 additions & 0 deletions packages/server-jest-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,16 @@ export const addPresetRecords = (schema: Schema) => async (map: PresetRecords):
await Promise.all(promises);
};

export const setPresetRecordsSchema = (records: PresetRecords) => async (schema: Schema): Promise<void> => {
await Promise.all(
COLLECTIONS_USED.map(name =>
schema.getCollection(name).remove('true').execute(),
),
);

await addPresetRecords(schema)(records);
};

/**
* Adds all of the records specified by the PresetRecords map, where each field
* represents a table and the array values are added to that table
Expand Down
4 changes: 2 additions & 2 deletions packages/server-jest-config/test-data/CAPWATCH_Test_Data.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"Profession": "REL",
"EducationLevel": "0",
"Citizen": "US Citizen",
"ORGID": 9001,
"ORGID": 916,
"Wing": "VW",
"Unit": "1",
"Rank": "Lt Col",
Expand Down Expand Up @@ -42,7 +42,7 @@
"Profession": "Maintenance Management Systems",
"EducationLevel": "12",
"Citizen": "US Citizen",
"ORGID": 9001,
"ORGID": 916,
"Wing": "VW",
"Unit": "1",
"Rank": "Lt Col",
Expand Down
1 change: 1 addition & 0 deletions packages/util-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"author": "Andrew Rioux",
"license": "GPL-2.0",
"dependencies": {
"@faker-js/faker": "^8.1.0",
"@mysql/xdevapi": "8.0.19",
"auto-client-api": "^1.3.23",
"common-lib": "^1.28.0",
Expand Down
Loading

0 comments on commit a479ee2

Please sign in to comment.