Skip to content

Commit

Permalink
Merge pull request #997 from CityOfBoston/DIG-3918
Browse files Browse the repository at this point in the history
DIG-3918: Add Milestones to ISD permit tracker website
  • Loading branch information
phillipbentonkelly authored Feb 12, 2024
2 parents ddb614b + 760f179 commit b850ac3
Show file tree
Hide file tree
Showing 7 changed files with 204 additions and 17 deletions.
123 changes: 123 additions & 0 deletions services-js/permit-finder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# syntax=docker/dockerfile:1
FROM node:14.19.1-alpine as build_phase

# ARG S3_ENV_PATH='s3://cob-digital-apps-staging-config/permit-finder/test'

ENV WORKSPACE=permit-finder
ENV NODE_ENV development

WORKDIR /app

#ENV PYTHONUNBUFFERED=1
RUN apk add --no-cache git openssl \
&& apk add --update --no-cache python3 curl unzip \
&& ln -sf python3 /usr/bin/python \
&& python3 -m ensurepip \
&& pip3 install --no-cache --upgrade pip setuptools

# To prevent “Error: could not get uid/gid”
RUN npm config set unsafe-perm true

# Need to upgrade yarn to at least 1.6
RUN yarn global add yarn@^1.6.0

ADD . /app/

# This is the tar'd up collection of package.json files created by
# build-service-container.sh. Working with it and the lockfiles means we can
# cache the yarn install across builds when there are no dependency changes.
#ADD package-json.tar /app/
#ADD yarn.lock lerna.json .yarnrc /app/

RUN /app/scripts/generate-ssl-key.sh /app/services-js/$WORKSPACE

RUN yarn install

# This is the time consuming step +/-300secs
WORKDIR /app/services-js/$WORKSPACE
RUN yarn install --ignore-scripts

# syntax=docker/dockerfile:1
FROM node:14.19.1-alpine as deploy_phase

ENV WORKSPACE permit-finder
ENV NODE_ENV development
ENV USE_SSL true

COPY --from=build_phase /app /app

ENV PYTHONUNBUFFERED=1
RUN apk add --no-cache git openssl \
&& apk add --update --no-cache python3 curl unzip \
&& ln -sf python3 /usr/bin/python \
&& python3 -m ensurepip \
&& pip3 install --no-cache --upgrade pip setuptools \
&& cd /tmp \
&& curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip" \
&& unzip awscli-bundle.zip \
&& ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws \
&& rm awscli-bundle.zip \
&& rm -rf awscli-bundle

WORKDIR /app/services-js/${WORKSPACE}
RUN yarn run build

#ADD ./.aws /root/.aws
#RUN --mount=type=secret,id=aws,target=/root/.aws/credentials

RUN --mount=type=secret,id=aws,target=/root/.aws/credentials \
BUILD_ID=$(cat /app/services-js/permit-finder/build/.next/BUILD_ID) && \
aws s3 cp --recursive --acl public-read /app/services-js/permit-finder/build/.next/static/${BUILD_ID} s3://cob-digital-apps-staging-static/permit-finder/_next/static/${BUILD_ID}/ && \
aws s3 cp --recursive --acl public-read /app/services-js/permit-finder/build/.next/static/chunks s3://cob-digital-apps-staging-static/permit-finder/_next/static/chunks/ && \
aws s3 cp --recursive --acl public-read /app/services-js/permit-finder/build/.next/static/runtime s3://cob-digital-apps-staging-static/permit-finder/_next/static/runtime/ && \
aws s3 cp --recursive --acl public-read /app/services-js/permit-finder/build/.next/static/${BUILD_ID} s3://cob-digital-apps-prod-static/permit-finder/_next/static/${BUILD_ID}/ && \
aws s3 cp --recursive --acl public-read /app/services-js/permit-finder/build/.next/static/chunks s3://cob-digital-apps-prod-static/permit-finder/_next/static/chunks/ && \
aws s3 cp --recursive --acl public-read /app/services-js/permit-finder/build/.next/static/runtime s3://cob-digital-apps-prod-static/permit-finder/_next/static/runtime/ || \
echo "OOPS"

EXPOSE 3000

ENV NODE_ENV production

ENTRYPOINT ["/app/scripts/service-entrypoint.sh"]
CMD ["yarn", "start"]

###################################
# NOTES:
# To use this file:
# [a] clone the digital repo
# [b] from a terminal, in the permit-finder folder, run
# DOCKER_BUILDKIT=1 docker build --pull --cache-from local-test/permit-finder:latest -f ./Dockerfile -t local-test/permit-finder:latest --secret id=aws,src=$HOME/.aws/credentials --platform linux/amd64 ../..
# -> this will create an image tagged local-test/permit-finder:latest on the local machine
# [c] from a terminal, in the permit-finder folder, run
# docker compose up --no-build -d permit-finder
# -> this will create a container which should start on your local machine, with your cloned repo mounted into
# so that your changes are immediately effective in the browser.
# -> you should be able to see the webapp at https://127.0.0.1:3000/group-mgmt ..etc
# [d] In a terminal app, open a session in the container by running:
# docker exec -it permit-finder /bin/sh
# -> This has effectively ssh'd you into the container as the defaul (root) user.
# [e] In the container session, you can start the yarn watcher
# yarn dev
# -> this will watch the /app folder (which is a mounted copy from your local computer) and recompile as changes
# are made. Thus, you can code and test simultaneously (slight delay as the rebuilds occur)
# WHEN YOU ARE READY TO DEPLOY TO STAGE:
# [1] Check your code into github
# [2] Close down any shells into the container and stop the container:
# docker stop permit-finder
# [2.5] Re-login into ECR with this command --> aws ecr get-login-password --region us-east-1 --profile=cityofboston | docker login --username AWS --password-stdin 251803681989.dkr.ecr.us-east-1.amazonaws.com
# [3] Rebuild the container and apps by running:
# DOCKER_BUILDKIT=1 docker build --pull --cache-from local-test/permit-finder:latest -f ./Dockerfile -t 251803681989.dkr.ecr.us-east-1.amazonaws.com/cob-digital-apps-staging/permit-finder:deploy-new-stage --secret id=aws,src=$HOME/.aws/credentials --platform linux/amd64 ../..
# -> this is essentially the same command as in [b] above, just uses a different tag and ensures the /app folder
# is physically there and not mounted (using the docker-compose command in [c] above mounts the repo over
# whatever was added into the the image's /app folder during the docker build command)
# [4] Push the image to AWS by running
# docker push 251803681989.dkr.ecr.us-east-1.amazonaws.com/cob-digital-apps-staging/permit-finder:deploy-new-stage
# -> the deploy should start once the image is transferred/uploaded
#
# WHEN YOU ARE READY TO DEPLOY TO PROD:
# [1] Tag the image you pushed to stage with a production tag:
# docker tag 251803681989.dkr.ecr.us-east-1.amazonaws.com/cob-digital-apps-staging/permit-finder:deploy-new-stage-test 251803681989.dkr.ecr.us-east-1.amazonaws.com/cob-digital-apps-prod/permit-finder:deploy-new-prod
# [2] Push the image to AWS by running
# docker push 251803681989.dkr.ecr.us-east-1.amazonaws.com/cob-digital-apps-prod/permit-finder:deploy-new-prod
# -> the deploy should start once the image is transferred/uploaded
26 changes: 26 additions & 0 deletions services-js/permit-finder/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '3'
services:
permit-finder:
image: local-test/permit-finder:latest
container_name: permit-finder
ports:
- 3001:3001
# - ${COMPOSE_PORTS}
working_dir: /app/services-js/permit-finder
extra_hosts:
- group-mgmt-test.digital-staging.boston.gov:172.17.0.3
# - ${EXTRA_HOSTS}
volumes:
- ~/.aws:/root/.aws
environment:
AWS_S3_CONFIG_URL: s3://cob-digital-apps-staging-config/permit-finder
DEPLOY_VARIANT: test
AWS_DEFAULT_REGION: us-east-1
AWS_REGION: us-east-1
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
NODE_VERSION: 14.19.1
YARN_VERSION: 1.22.17
WORKSPACE: permit-finder
NODE_ENV: production
USE_SSL: true
network_mode: bridge
2 changes: 2 additions & 0 deletions services-js/permit-finder/fixtures/MilestoneExport.csv
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
"X49106288","PlanningZoning","2012-10-19 14:12:44.877000","2019-05-17 16:03:07.027000","3457551","JON R ACEVEDO"
"X49106288","Refusal","2012-10-19 14:12:44.877000","2019-05-17 16:03:07.027000","3457551","JON R ACEVEDO"

Original file line number Diff line number Diff line change
Expand Up @@ -250,5 +250,26 @@
"Description": "",
"ExpectedDuration": "",
"ContactInstructions": ""
},
{
"Milestones": "MoreInfo",
"DisplayStatus": "Intake & Payment",
"Description": "More information is needed to complete permit and plan intake. Please log in to the permitting portal (https://onlinepermitsandlicenses.boston.gov/isdpermits/) to view comments from the reviewer and update your application. ",
"ExpectedDuration": "Please get back to us soon so we can complete intake.",
"ContactInstructions": "Call 617-635-5300 and ask for ISD Counter 2."
},
{
"Milestones": "PZ MoreInfo",
"DisplayStatus": "Project Review",
"Description": "More information is needed to complete the plan review. Please log in to the permitting portal (https://onlinepermitsandlicenses.boston.gov/isdpermits/) to view comments from your assigned plans examiner and provide the requested items. ",
"ExpectedDuration": "Please get back to us soon so we can complete plan review.",
"ContactInstructions": "Call 617-635-5300 and ask for ISD Counter 2."
},
{
"Milestones": "Refusal",
"DisplayStatus": "Project Review",
"Description": "Your project requires special consideration because it conflicts with your area’s zoning codes. Please log in to the permitting portal (https://onlinepermitsandlicenses.boston.gov/isdpermits/) to view the refusal letter from the plans examiner. You can revise and resubmit plans or submit an appeal to proceed. To learn more about the Zoning Board of Appeals process, please visit https://www.boston.gov/departments/inspectional-services/zoning-board-appeal.",
"ExpectedDuration": "Please take action to proceed.",
"ContactInstructions": "Call 617-635-5300 and ask for ISD Counter 2."
}
]
9 changes: 8 additions & 1 deletion services-js/permit-finder/src/pages/permit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,14 @@ export default class PermitPage extends React.Component<Props, State> {
</div>

{latestStep && latestStep.description && (
<p className="t--s500 lh--300">{latestStep.description}</p>
<p
className="t--s500 lh--300"
dangerouslySetInnerHTML={{
__html: Autolinker.link(latestStep.description, {
className: 'autolinked',
}),
}}
/>
)}

<ul
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ describe('lookupPermit', () => {
"MilestoneStartDate": "2012-10-19 14:12:44.877000",
"PermitNumber": "X49106288",
},
Object {
"AverageDurationOfMilestone": "3457551",
"CityContactName": "JON R ACEVEDO",
"MilestoneEndDate": "2019-05-17 16:03:07.027000",
"MilestoneName": "Refusal",
"MilestoneStartDate": "2012-10-19 14:12:44.877000",
"PermitNumber": "X49106288",
},
],
"reviews": Array [
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ Array [
</i>
<br />

1–2 Business Days
Please get back to us soon so we can complete intake.
</div>
<div
className="css-1rr4qq7"
Expand All @@ -813,7 +813,7 @@ Array [
</i>
<br />

20 Business Days
Please take action to proceed.
</div>
<div
className="css-1rr4qq7"
Expand Down Expand Up @@ -1290,7 +1290,7 @@ Array [
</i>
<br />

1–2 Business Days
Please get back to us soon so we can complete intake.
</div>
<div
className="css-1rr4qq7"
Expand All @@ -1317,7 +1317,7 @@ Array [
</i>
<br />

20 Business Days
Please take action to proceed.
</div>
<div
className="css-1rr4qq7"
Expand Down Expand Up @@ -1815,7 +1815,7 @@ Array [
</i>
<br />

1–2 Business Days
Please get back to us soon so we can complete intake.
</div>
<div
className="css-1rr4qq7"
Expand Down Expand Up @@ -1848,7 +1848,7 @@ Array [
</i>
<br />

20 Business Days
Please take action to proceed.
</div>
<div
className="css-1rr4qq7"
Expand Down Expand Up @@ -2348,7 +2348,7 @@ Array [
</i>
<br />

1–2 Business Days
Please get back to us soon so we can complete intake.
</div>
<div
className="css-1rr4qq7"
Expand All @@ -2375,7 +2375,7 @@ Array [
</i>
<br />

20 Business Days
Please take action to proceed.
</div>
<div
className="css-1rr4qq7"
Expand Down Expand Up @@ -2867,7 +2867,7 @@ Array [
</i>
<br />

1–2 Business Days
Please get back to us soon so we can complete intake.
</div>
<div
className="css-1rr4qq7"
Expand Down Expand Up @@ -2900,7 +2900,7 @@ Array [
</i>
<br />

20 Business Days
Please take action to proceed.
</div>
<div
className="css-1rr4qq7"
Expand Down Expand Up @@ -3400,7 +3400,7 @@ Array [
</i>
<br />

1–2 Business Days
Please get back to us soon so we can complete intake.
</div>
<div
className="css-1rr4qq7"
Expand All @@ -3427,7 +3427,7 @@ Array [
</i>
<br />

20 Business Days
Please take action to proceed.
</div>
<div
className="css-1rr4qq7"
Expand Down Expand Up @@ -3919,7 +3919,7 @@ Array [
</i>
<br />

1–2 Business Days
Please get back to us soon so we can complete intake.
</div>
<div
className="css-1rr4qq7"
Expand All @@ -3946,7 +3946,7 @@ Array [
</i>
<br />

20 Business Days
Please take action to proceed.
</div>
<div
className="css-1rr4qq7"
Expand Down Expand Up @@ -4462,7 +4462,7 @@ Array [
</i>
<br />

1–2 Business Days
Please get back to us soon so we can complete intake.
</div>
<div
className="css-1rr4qq7"
Expand All @@ -4489,7 +4489,7 @@ Array [
</i>
<br />

20 Business Days
Please take action to proceed.
</div>
<div
className="css-1rr4qq7"
Expand Down

0 comments on commit b850ac3

Please sign in to comment.