Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TGR-50: Remediation update #2155

Merged
merged 40 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
ee246db
first commit of updating to node 20 and successfully installing packa…
EdwinGuzman Jul 26, 2024
4fdc166
minor update to fix logger
EdwinGuzman Jul 26, 2024
7d0dac0
working app
EdwinGuzman Jul 29, 2024
85c850a
Updating dockerfile, adding GA, and removing travis
EdwinGuzman Aug 12, 2024
6b96740
changelog update and removing EB from repo
EdwinGuzman Aug 12, 2024
4d89487
Updating ref to ECR for docker image
EdwinGuzman Aug 13, 2024
14122ed
forgot force for npm i
EdwinGuzman Aug 13, 2024
71d9f13
Ignore tests for now since they're broken
EdwinGuzman Aug 13, 2024
8e1b621
no local .env copy
EdwinGuzman Aug 13, 2024
a8c028a
hmm deps?
EdwinGuzman Aug 13, 2024
f69fd31
all in deps but will organize later
EdwinGuzman Aug 13, 2024
f2faa89
new qa ecs names
EdwinGuzman Aug 20, 2024
461624b
fixing visually hidden styling issue onhold request page
EdwinGuzman Aug 27, 2024
748dcdd
Updating ecs cluster and service names
EdwinGuzman Aug 27, 2024
87d4d1d
Updating based on feedback
EdwinGuzman Sep 6, 2024
59d8889
Some env var defaults
EdwinGuzman Sep 9, 2024
d139073
separating train into it's own ci
EdwinGuzman Sep 9, 2024
6bba52d
typo in service name for discovery-ui-edd
EdwinGuzman Sep 9, 2024
19eb44e
Updates based on feedback
EdwinGuzman Sep 10, 2024
b65b21a
readme git branches update
EdwinGuzman Sep 11, 2024
83e90d9
Testing deploy branch name
EdwinGuzman Sep 12, 2024
2d3aa17
fixing prod name, pushing to prod
EdwinGuzman Sep 12, 2024
8da7d20
typo
EdwinGuzman Sep 12, 2024
c9a5060
Hard coding rp enabled links for now
EdwinGuzman Sep 12, 2024
07275b6
forgot to update qa
EdwinGuzman Sep 12, 2024
a9f85d9
Updating SHEP links
EdwinGuzman Sep 13, 2024
9f79eea
Updating SHEP links
EdwinGuzman Sep 13, 2024
3af2d60
fixing dslink issue
EdwinGuzman Sep 18, 2024
b937ee8
cleaning up npm scripts and updating branch targets for GHA deployment
EdwinGuzman Sep 19, 2024
b2c9395
Debugging and setting more env vars
EdwinGuzman Sep 20, 2024
b8fc88e
Not reading from redux store was the issue
EdwinGuzman Sep 20, 2024
3e1d27c
simple log
EdwinGuzman Sep 25, 2024
f7ec4f3
Replace react link with dslink on hold request page
dgcohen Oct 28, 2024
9cb6286
Remove link import
dgcohen Oct 28, 2024
a0c4bc5
Fix failing test
dgcohen Oct 28, 2024
88eb06c
Merge pull request #2163 from NYPL/SCC-4324/make-bib-link-on-hold-pag…
dgcohen Oct 29, 2024
72fc70b
Add fix to fix use of discovery.nypl.org in redirect_uri
nonword Nov 6, 2024
bface0c
Merge branch 'TGR-50/remediation-update' into NOREF-disallow-internal…
nonword Nov 7, 2024
c967489
Change CD to deploy production from namesake branch
nonword Nov 7, 2024
b29a083
Merge pull request #2165 from NYPL/NOREF-disallow-internal-hostname
nonword Nov 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .ebextensions/00_change_npm_permissions.config

This file was deleted.

15 changes: 0 additions & 15 deletions .ebextensions/00_nypl_provisioning.config

This file was deleted.

6 changes: 0 additions & 6 deletions .ebextensions/01_loadbalancer-terminatehttps.config

This file was deleted.

14 changes: 0 additions & 14 deletions .ebextensions/02_cloudwatch_agent_config.config

This file was deleted.

5 changes: 0 additions & 5 deletions .ebextensions/03_enable_log_streaming.config

This file was deleted.

3 changes: 0 additions & 3 deletions .ebextensions/enhanced-health.config

This file was deleted.

5 changes: 0 additions & 5 deletions .ebextensions/node-settings.config

This file was deleted.

6 changes: 5 additions & 1 deletion .env-sample
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ BASE_URL=/research/research-catalog
REDIRECT_FROM_BASE_URL=/research/collections/shared-collection-catalog
WEBPAC_BASE_URL=https://[fqdn]/
LOGIN_BASE_URL=https://[fqdn]/
LOGIN_URL=https://[fqdn]/
CIRCULATING_CATALOG=https://[fqdn]/
OPEN_LOCATIONS=315,300
SHEP_BIBS_LIMIT=25
TZ=America/New_York
LAUNCH_EMBED_URL=https://[fqdn]/
NYPL_HEADER_URL=https://ds-header.nypl.org
SIERRA_UPGRADE_AUG_2023=true
REVERSE_PROXY_ENABLED=false
REVERSE_PROXY_ENABLED=false
DRB_API_BASE_URL=https://[fqdn]/
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"impliedStrict": true,
"jsx": true
},
"ecmaVersion": 2019,
"sourceType": "module",
"project": "./tsconfig.json"
},
Expand Down
97 changes: 97 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Run tests and deploy to QA and Production on `nypl-digital-dev` account

name: CI

on: push

jobs:
test:
name: Test
runs-on: ubuntu-latest
env:
CI: true
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
- name: Cache and install node modules
uses: bahmutov/npm-install@v1
with:
install-command: npm install --ignore-script
- name: Test
run: npm run test
publish_qa:
needs: test
# TODO: update this to `qa` branch
if: github.ref == 'refs/heads/TGR-50/remediation-update'
charmingduchess marked this conversation as resolved.
Show resolved Hide resolved
name: Publish image to ECR and update ECS stack
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::946183545209:role/GithubActionsDeployerRole
aws-region: us-east-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: nypl-discovery-ui
EdwinGuzman marked this conversation as resolved.
Show resolved Hide resolved
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:qa-latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:qa-latest

- name: Force ECS Update
# Deploy to both the production and train clusters
run: |
aws ecs update-service --cluster nypl-discovery-qa-tf --service nypl-discovery-qa-tf --force-new-deployment
aws ecs update-service --cluster nypl-discovery-train-tf --service nypl-discovery-train-tf --force-new-deployment
publish_production:
needs: test
if: github.ref == 'refs/heads/tgr-production'
name: Publish image to ECR and update ECS stack
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::946183545209:role/GithubActionsDeployerRole
aws-region: us-east-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: nypl-discovery-ui
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:production-latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:production-latest

- name: Force ECS Update
run: |
aws ecs update-service --cluster nypl-discovery-production-tf --service nypl-discovery-production-tf --force-new-deployment
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ log/*.log
# Local env:
.env

# Elastic Beanstalk Files
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml

#Files with names of missing fields

# VS code Configuration Files
Expand Down
2 changes: 0 additions & 2 deletions .npmrc

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.17.0
20
58 changes: 0 additions & 58 deletions .travis.yml

This file was deleted.

31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
## CHANGE LOG

### 1.9.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this warrant a new major version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was debating that. I don't think so since the update is for the codebase and not any features. Do you think it should be a major bump?


Remediation Project Update

### Adds

- Adds `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` as example env vars needed in `.env-sample`. They are required for building Docker images.
- Adds `Dockerfile` and instructions on how to use it locally.
- Adds the following npm packages:
`sass`, `webpack-dev-middleware`

### Updates

- Updates `.nvmrc` to use Node 20.
- Updates the logger file.
- Updates npm scripts to be more conventional with `build` and `dev`.
- Updates how the webpack dev server is implemented.
- Updates how the `react-number-format` package is used in the `FieldsetDate` component.
- Updates implementation of the `focus-trap-react` package.
- Updates node's Buffer implementation for KMS package usage.
- Updates the following npm packages:
`@babel/preset-env`, `@babel/preset-react`, `@babel/preset-register`, `@nypl/nypl-core-objects`, `@nypl/nypl-data-api-client`, `@typescript-eslint/eslint-plugin`, `axios`, `babel-plugin-module-resolver`, `body-parser`, `chai`, `clean-webpack-plugin`, `compression`, `cookie-parser`, `cross-env`, `css-loader`, `doctoc`, `dotenv`, `ejs`, `enzyme-adapter-react-16`, `eslint`, `eslint-config-airbnb`, `eslint-config-prettier`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-prettier`, `eslint-plugin-react`, `eslint-plugin-react-hooks`, `express`, `file-loader`, `focus-trap-react`, `jsonwebtoken`, `mini-css-extract-plugin`, `mocha`, `mock-local-storage`, `nock`, `react`, `react-autosuggest`, `react-dom`, `react-number-format`, `react-redux`, `redux`, `redux-thunk`, `prettier`, `sass-loader`, `sinon`, `sinon-chai`, `style-loader`, `supertest`, `typescript`, `webpack`, `webpack-cli`, `winston`, `underscore`, `url-parse`, `validator`

### Removals

- Removes the `.ebextensions` folder since this repos should no longer deploy to ElasticBeanstalk.
- Removes the `.travis.yml` file to not use Travis CI.
- Removes the `Procfile` since this we don't use Heroku.
- Removes the following npm packages:
`@babel/core`, `@babel/polyfill`, `@nypl/dgx-header-component`, `@nypl/dgx-react-footer`, `@typescript-eslint/parser`, `node-sass`, `node-sass-glob-importer`, `react-router-scroll`, `webpack-bundle-analyzer`, `webpack-dev-server`, `webpack-merge`

### 1.8.2

### Updates
Expand Down
43 changes: 0 additions & 43 deletions DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Install:

- AWS CLI
- EB CLI

### Repo Branches

Expand Down Expand Up @@ -33,42 +32,6 @@ If we have a new feature to add, the suggested workflow is:

Once a feature branch has been approved and merged into development

### Elastic Beanstalk

There are two existing AWS accounts that we are deploying to for development and for qa/production.

Make sure you have the AWS CLI tool installed on your machine and make sure you have the correct credentials for the two accounts. Since we have two accounts, nypl-sandbox and nypl-digital-dev, make sure you create two profiles using the AWS CLI tool:

aws configure --profile nypl-digital-dev

Pass in the correct credentials and now we can start deploying.

### Configuration

Run `eb init` at the root of this repo with the following settings:

- Select region 'us-east-1'
- Select application 'discovery-ui'
- Select default environment 'discovery-ui-development'
- If asked about CodeCommit, select 'n'
- If asked if you want to set up SSH for your instances, select 'n'
- Now manually edit `.elasticbeanstalk/config.yml` to include the following `branch-defaults`:

```
branch-defaults:
dev-eb-deploy:
environment: discovery-ui-development
group_suffix: null
master:
environment: discovery-ui-production
group_suffix: null
qa:
environment: discovery-ui-qa
group_suffix: null
```

Note that `development` will always differ from `qa` in one respect: Apps deployed to `nypl-sandbox` require a different cert ARN than that for `nypl-digital-dev`. Accordingly, `development` will always have a slightly different `.ebextensions/01_loadbalancer-terminatehttps.config` from that of `qa`. Due to the order in which those differences were originally committed, merging `development` into `qa` should never disrupt that.

### Deployment

| | Development | QA | Production |
Expand Down Expand Up @@ -104,9 +67,3 @@ _(Note that updates to origin/master trigger a deploy to discovery-ui-production

- `git checkout master`, `git merge qa`, `git push origin master`
- Run `npm run deploy-production`

### Troubleshooting

#### Python error: "ERROR: TypeError :: cannot concatenate 'str' and 'NoneType' objects"

This may indicate your `.elasticbeanstalk/config.yml` is missing a value or two. Try running `eb init` to fill in missing values. See "Configuration" section above for best defaults.
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Build the environment.
FROM node:20-alpine as production

WORKDIR /app

ENV NODE_ENV=production
ENV TZ=America/New_York

# Install dependencies.
COPY package.json ./
COPY package-lock.json ./
RUN npm install --force

# Copy the app files.
COPY . .
COPY .env .env


# Build the app!
RUN npm run build

EXPOSE 3001

# CMD is the default command when running the docker container.
CMD npm start
Loading
Loading