Skip to content

Commit

Permalink
Merge pull request #93 from Smithsonian/develop
Browse files Browse the repository at this point in the history
v0.5.0
  • Loading branch information
jahjedtieson authored Feb 27, 2021
2 parents 3e242af + be5a3a7 commit c354e89
Show file tree
Hide file tree
Showing 280 changed files with 26,124 additions and 5,774 deletions.
22 changes: 19 additions & 3 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
# NODE
NODE_ENV=

# DB
MYSQL_ROOT_PASSWORD=
DATABASE_URL=
PACKRAT_CLIENT_PORT=
PACKRAT_SERVER_PORT=
PACKRAT_DB_PORT=

# CLIENT
PACKRAT_CLIENT_PORT=
REACT_APP_SERVER_ENDPOINT=

# SERVER
PACKRAT_SERVER_PORT=
DATABASE_URL=
CLIENT_ENDPOINT=
SESSION_SECRET=
EDAN_AUTH_KEY=
EDAN_SERVER=
EDAN_APPID=
OCFL_STORAGE_ROOT=
OCFL_STAGING_ROOT=

# SOLR
PACKRAT_SOLR_PORT=
PACKRAT_SOLR_HOST=





19 changes: 14 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ jobs:
- name: Setup node version
uses: actions/setup-node@v1
with:
node-version: 12
node-version: 12.18.4

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Install E2E dependencies
run: cd e2e && yarn install --frozen-lockfile && cd ..

- name: Check for lint errors
run: yarn lint

Expand Down Expand Up @@ -61,12 +64,16 @@ jobs:
- name: Setup node version
uses: actions/setup-node@v1
with:
node-version: 12
node-version: 12.18.4

# Install dependencies in CI mode
- name: Install dependencies
run: yarn install --frozen-lockfile

# Install E2E dependencies in CI mode
- name: Install E2E dependencies
run: cd e2e && yarn install --frozen-lockfile && cd ..

# Run tests using test DB
- name: Run Tests
run: yarn test
Expand All @@ -85,6 +92,8 @@ jobs:
PACKRAT_DB_PORT: 3306
MYSQL_ROOT_PASSWORD: packrat
REACT_APP_SERVER_ENDPOINT: http://packrat-server
PACKRAT_SOLR_PORT: 8983
PACKRAT_SOLR_HOST: packrat-solr

steps:
- name: Checkout code
Expand All @@ -97,14 +106,14 @@ jobs:
# Runs commands pre-build
# Ideally .env will be created from secrets ${{ secrets.DEV/PROD_ENV }} > .env
- name: Prepare build
run: touch .env
run: touch .env.dev && touch env.prod

- name: Build Dev images
run: docker-compose -f docker-compose.dev.yml build
run: docker-compose --env-file .env.dev -f docker-compose.dev.yml build
if: contains(github.ref, 'develop')

- name: Build Prod images
run: docker-compose -f docker-compose.prod.yml build
run: docker-compose --env-file .env.prod -f docker-compose.prod.yml build
if: contains(github.ref, 'master')

# Prepares tag for docker images
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ typings/
# dotenv environment variables file
.env
.env.test
.env.*

# parcel-bundler cache (https://parceljs.org/)
.cache
Expand Down
102 changes: 86 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
# dpo-packrat
Data Repository and Workflow Management for 3D data captures, models, and scenes

## Instructions:
## Setup instructions (Development):

*`.env` is required and it follows `.env.template`*
*Note: `.env.dev` is required and it follows `.env.template`*

### Development:

1. Install the dependencies:
#### Prerequisites:
It is recommended to install [Volta](https://volta.sh/) which keeps node version in check. The versions can be specified in `package.json` and when switched to the directory of the project, volta automatically switches to the correct node version.

```
yarn
```
cd ~
curl https://get.volta.sh | bash
volta install node
volta install yarn
```
Now when you switch to the `dpo-packrat` repo, your node version would automatically pinned to the correct version by volta.


2. Build existing packages:
1. Install the dependencies:

```
yarn build
yarn
```

3. Build the docker images, if they're already available then this would just start them (if you're on a mac then make sure Docker for mac is running):
2. Build the docker images, if they're already available then this would just start them (if you're on a mac then make sure Docker for mac is running):

```
yarn dev
```

4. Now the docker containers should start in 10s-20s. The client should be reachable at `http://localhost:3000` and server should be reachable at `http://localhost:4000` or the ports you specified in `.env` following `.env.template`

5. If you want to follow debug logs for `client` or `server` container then just run `yarn log:client` or `yarn log:server`
3. Now the docker containers should start in 10s-20s. The client should be reachable at `http://localhost:3000` and server should be reachable at `http://localhost:4000` or the ports you specified in `.env.dev` following `.env.template`

6. If you're developing `common` package then make sure to use `yarn start:common` so that it's actively watched/compiled and made available to other packages it's imported at. The other packages should auto reload when changes are made to them.
4. If you want to follow debug logs for `client` or `server` container then just run `yarn log:client` or `yarn log:server`

7. If not using docker run each command in a separate terminal for the package you're developing:
5. If not using docker run each command in a separate terminal for the package you're developing:

**For client:**

Expand All @@ -45,8 +49,74 @@ yarn start:client
yarn start:server
```

**For common:**
# Alternative docker workflow:

```
yarn start:common
```
# Creates Devbox for packrat
yarn devbox:up
# Creates DB for devbox
yarn devbox:db
# Create and Connects db and devbox to the same network
yarn devbox:network
# Drops you into shell inside the image
yarn devbox:start
```

*Note: if you get permission denied during the execution make sure to give it permission using:*
```
chmod 777 ./scripts/devbox/*.sh
```

# Deployment instructions:
*Note: Make sure before you execute any script, you're root of the repository `dpo-packrat` and if you get permission denied for any script, make sure to do `chmod 777 path/to/script`. If you encounter any error then make sure to checkout Packrat server setup instruction on confluence*

## Docker images:
*Note: current supported environments are `dev` and `prod`*

1. Login into SI server

2. Pull the latest changes
```
git pull
```
*Note: repository is already cloned in `/home/<user>/dpo-packrat`*

3. Switch to the branch you want to deploy. To deploy for `dev` environment you should be on `develop` branch, for `prod` environment
```
git checkout master
```
*Note: `.env.dev` and `.env.prod` are already available*

4. Deploy using the `deploy.sh` script
```
./scripts/deploy.sh prod
```
If you get `permission denied for docker` then use
```
sudo chmod 777 /var/run/docker.sock
```
If you get `Error while loading shared libraries: libz.so.1` for `docker-compose` then do the following:
```
sudo mount /tmp -o remount,exec
```

5. Wait for the images to be build/updated, then use `cleanup.sh` script to cleanup any residual docker images are left (optional)

6. Make sure nginx is active using `sudo service nginx status --no-pager`

## Start databases (Production server only):

1. Start `dev` or `prod` databases using `scripts/initdb.sh` script
```
MYSQL_ROOT_PASSWORD=<your_mysql_password> ./scripts/initdb.sh dev
```
*Note: `MYSQL_ROOT_PASSWORD` be same what you mentioned in the `.env.dev` or `.env.prod` file for that particular environment. Mostly would be used for `dev` environment.*

## Update production nginx configuration (Production server only):

1. Make the changes to production nginx configuration is located at `scripts/proxy/nginx.conf`

2. Use `scripts/proxy/refresh.sh` script to restart/update nginx service
```
./scripts/proxy/refresh.sh
```
9 changes: 8 additions & 1 deletion client/config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Config Overrides
*
* This config is used for overriding default webpack config of CRA without
* ejecting.
*/
const { override, addExternalBabelPlugin } = require('customize-cra');
const { addReactRefresh } = require('customize-cra-react-refresh');

module.exports = override(addExternalBabelPlugin('react-activation/babel'));
module.exports = override(addExternalBabelPlugin('react-activation/babel'), addReactRefresh());
12 changes: 10 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"dependencies": {
"@apollo/client": "3.1.5",
"@date-io/date-fns": "1.3.13",
"@dpo-packrat/common": "0.4.0",
"@material-ui/core": "4.11.0",
"@material-ui/icons": "4.9.1",
"@material-ui/lab": "4.0.0-alpha.56",
Expand All @@ -41,7 +40,10 @@
"@types/react-router-dom": "5.1.5",
"@types/yup": "0.29.7",
"apollo-upload-client": "14.1.2",
"clsx": "1.1.1",
"customize-cra": "1.0.0",
"customize-cra-react-refresh": "1.1.0",
"env-cmd": "10.1.0",
"formik": "2.1.5",
"formik-material-ui": "3.0.0",
"framer-motion": "2.6.13",
Expand All @@ -56,6 +58,7 @@
"react-debounce-input": "3.2.2",
"react-dom": "16.13.1",
"react-dropzone": "11.1.0",
"react-helmet": "6.1.0",
"react-icons": "3.11.0",
"react-router": "5.2.0",
"react-router-dom": "5.2.0",
Expand All @@ -69,7 +72,8 @@
"scripts": {
"start": "react-app-rewired start",
"start:prod": "react-app-rewired start",
"build": "react-app-rewired build",
"build:dev": "yarn env-cmd -f ../.env.dev react-app-rewired build",
"build:prod": "yarn env-cmd -f ../.env.prod react-app-rewired build",
"test": "react-app-rewired test --watchAll=false --passWithNoTests",
"eject": "react-app-rewired eject",
"clean": "rm -rf node_modules/ build/",
Expand All @@ -86,5 +90,9 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"volta": {
"node": "12.18.4",
"yarn": "1.22.4"
}
}
Binary file modified client/public/favicon.ico
Binary file not shown.
Binary file modified client/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified client/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions client/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/**
* API (REST)
*
* This class is responsible for performing REST operations such
* as login and logout.
*/
enum API_ROUTES {
LOGIN = 'auth/login',
LOGOUT = 'auth/logout'
Expand Down
Binary file added client/src/assets/images/default-thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions client/src/components/controls/CheckboxField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* CheckboxField
*
* This component renders checkbox field used in ingestion and repository UI.
*/
import { Checkbox } from '@material-ui/core';
import React from 'react';
import { ViewableProps } from '../../types/repository';
import { getUpdatedCheckboxProps } from '../../utils/repository';
import { withDefaultValueBoolean } from '../../utils/shared';
import FieldType from '../shared/FieldType';

interface CheckboxFieldProps extends ViewableProps {
label: string;
name: string;
value: boolean | null;
onChange: ((event: React.ChangeEvent<HTMLInputElement>, checked: boolean) => void) | undefined;
required?: boolean;
}

function CheckboxField(props: CheckboxFieldProps): React.ReactElement {
const { label, name, value, onChange, required = false, viewMode = false, disabled = false, updated = false } = props;
const rowFieldProps = { alignItems: 'center', justifyContent: 'space-between', style: { borderRadius: 0 } };

return (
<FieldType
required={required}
label={label}
direction='row'
containerProps={rowFieldProps}
width={viewMode ? 'auto' : undefined}
>
<Checkbox
name={name}
disabled={disabled}
checked={withDefaultValueBoolean(value, false)}
onChange={onChange}
{...getUpdatedCheckboxProps(updated)}
/>
</FieldType>
);
}

export default CheckboxField;
Loading

0 comments on commit c354e89

Please sign in to comment.