mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-08-02 21:04:18 -07:00
dockerize front end (#558)
* initial docker * adds concurrency to be able to run yarn install * adds 0.0.0.0 to allow docker access * adds web service * adds env variables * updates root path * adds volumes * adds docker to readme * adds score server client docker * docker updates after convo * speeds up build and removes env vars * adds client as volume * updates to docker setup * checkpoint * updates the docker file * adds .env.* files * replaces serve with http-server for cors Co-authored-by: Jorge Escobar <jorge.e.escobar@omb.eop.gov>
This commit is contained in:
parent
fba3090d36
commit
89c23faf7a
11 changed files with 113 additions and 30 deletions
1
client/.dockerignore
Normal file
1
client/.dockerignore
Normal file
|
@ -0,0 +1 @@
|
||||||
|
node_modules
|
8
client/.env.development
Normal file
8
client/.env.development
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
GATSBY_DATA_ROOT_PATH=https://d3jqyw10j8e7p9.cloudfront.net
|
||||||
|
GATSBY_DATA_PIPELINE_SCORE_PATH=data-pipeline/data/score
|
||||||
|
GATSBY_SCORE_DOWNLOAD_FILE_PATH=downloadable/Screening+Tool+Data.zip
|
||||||
|
GATSBY_MAP_TILES_PATH=tiles
|
||||||
|
|
||||||
|
# These may be used in the future:
|
||||||
|
# WEB_APP_CDN_BASE_URL=https://d2zjid6n5ja2pt.cloudfront.net
|
||||||
|
# S3_BASE_URL=https://justice40-data.s3.amazonaws.com
|
8
client/.env.local
Normal file
8
client/.env.local
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
GATSBY_DATA_ROOT_PATH=http://localhost:5000/data/data-pipeline
|
||||||
|
GATSBY_DATA_PIPELINE_SCORE_PATH=data_pipeline/data/score
|
||||||
|
GATSBY_SCORE_DOWNLOAD_FILE_PATH=downloadable/Screening+Tool+Data.zip
|
||||||
|
GATSBY_MAP_TILES_PATH=tiles
|
||||||
|
|
||||||
|
# These may be used in the future:
|
||||||
|
# WEB_APP_CDN_BASE_URL=https://d2zjid6n5ja2pt.cloudfront.net
|
||||||
|
# S3_BASE_URL=https://justice40-data.s3.amazonaws.com
|
1
client/.gitignore
vendored
1
client/.gitignore
vendored
|
@ -5,3 +5,4 @@ public
|
||||||
cypress/screenshots/
|
cypress/screenshots/
|
||||||
cypress/videos/
|
cypress/videos/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.env.*
|
22
client/Dockerfile
Normal file
22
client/Dockerfile
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
FROM node:14
|
||||||
|
|
||||||
|
# Set working directory like 'cd' command, any subsequent instructions in this docker file, will start from
|
||||||
|
# this working directory
|
||||||
|
WORKDIR /client
|
||||||
|
|
||||||
|
# Copy the package.json and package_lock.json files from local to the docker image / container
|
||||||
|
COPY package*.json ./
|
||||||
|
|
||||||
|
# install all packages as a layer in the docker image / container
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
# copy all local files from the working directory to the docker image/container however we must use
|
||||||
|
# dockerignore to ignore node_modules so that the image can use what what was just installed from the above
|
||||||
|
# step.
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
ENV PORT=6000
|
||||||
|
|
||||||
|
EXPOSE 6000
|
||||||
|
|
||||||
|
CMD [ "npm", "start"]
|
|
@ -11,6 +11,7 @@ This README contains the following content:
|
||||||
|
|
||||||
## Installing and running the client site
|
## Installing and running the client site
|
||||||
|
|
||||||
|
### Via npm
|
||||||
1. Confirm you have the base required software installed. See [INSTALLATION](INSTALLATION.md) for more details.
|
1. Confirm you have the base required software installed. See [INSTALLATION](INSTALLATION.md) for more details.
|
||||||
1. Install yarn if you do not have it yet. Open your terminal and run `sudo npm install -global yarn`. This works on MacOS and Win10. To confirm it is installed, run `yarn -v`. A version number should be returned.
|
1. Install yarn if you do not have it yet. Open your terminal and run `sudo npm install -global yarn`. This works on MacOS and Win10. To confirm it is installed, run `yarn -v`. A version number should be returned.
|
||||||
1. Navigate to the base directory of this repository, and go to the `client` directory (`cd client`).
|
1. Navigate to the base directory of this repository, and go to the `client` directory (`cd client`).
|
||||||
|
@ -20,6 +21,17 @@ This README contains the following content:
|
||||||
|
|
||||||
_Note that while this app uses npm as the package manager, yarn is required to build the [uswds](https://github.com/uswds/uswds) library._
|
_Note that while this app uses npm as the package manager, yarn is required to build the [uswds](https://github.com/uswds/uswds) library._
|
||||||
|
|
||||||
|
### Via docker
|
||||||
|
- Launch VS code in the top level directory (above client)
|
||||||
|
- install the Microsoft docker VS code extension
|
||||||
|
- type `docker-compose up`
|
||||||
|
- Running this on MacBook Pro with a 2.6GHz 6-core i7 with 16 GB of memory can take upto 20 minutes to complete.
|
||||||
|
|
||||||
|
#### Troubleshooting docker
|
||||||
|
|
||||||
|
- If an error is thrown about [running out of space](https://medium.com/@wlarch/no-space-left-on-device-when-using-docker-compose-why-c4a2c783c6f6) on device see this for ways to reclaim space.
|
||||||
|
|
||||||
|
|
||||||
### Viewing data on the map
|
### Viewing data on the map
|
||||||
|
|
||||||
See [VIEW_MAP_DATA](./VIEW_MAP_DATA) for more details on this.
|
See [VIEW_MAP_DATA](./VIEW_MAP_DATA) for more details on this.
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
require('dotenv').config({
|
||||||
|
path: `.env.${process.env.DATA_SOURCE}`,
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
siteMetadata: {
|
siteMetadata: {
|
||||||
title: 'Justice40',
|
title: 'Justice40',
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
],
|
],
|
||||||
"license": "CC0-1.0",
|
"license": "CC0-1.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"develop": "gatsby develop",
|
"develop": "gatsby develop -H 0.0.0.0",
|
||||||
"start": "gatsby develop",
|
"start": "gatsby develop -H 0.0.0.0",
|
||||||
"build": "gatsby build --prefix-paths",
|
"build": "gatsby build --prefix-paths",
|
||||||
"serve": "gatsby serve",
|
"serve": "gatsby serve",
|
||||||
"clean": "gatsby clean",
|
"clean": "gatsby clean",
|
||||||
|
|
|
@ -2,22 +2,21 @@ import {LngLatBoundsLike} from 'maplibre-gl';
|
||||||
import {isMobile as isMobileReactDeviceDetect} from 'react-device-detect';
|
import {isMobile as isMobileReactDeviceDetect} from 'react-device-detect';
|
||||||
import {defineMessages} from 'react-intl';
|
import {defineMessages} from 'react-intl';
|
||||||
|
|
||||||
// URLS
|
export const DOWNLOAD_ZIP_URL = [
|
||||||
export const DOWNLOAD_ZIP_URL = 'https://justice40-data.s3.amazonaws.com/data-pipeline/data/score/downloadable/Screening+Tool+Data.zip';
|
process.env.GATSBY_DATA_ROOT_PATH,
|
||||||
|
process.env.GATSBY_DATA_PIPELINE_SCORE_PATH,
|
||||||
|
process.env.GATSBY_SCORE_DOWNLOAD_FILE_PATH,
|
||||||
|
].join('/');
|
||||||
|
|
||||||
// This is the URL for the origin S3 bucket:
|
|
||||||
// export const ORIGIN_BASE_URL = 'https://justice40-data.s3.amazonaws.com';
|
|
||||||
|
|
||||||
// This is the URL for the CDN that delivers the tile data
|
|
||||||
export const FEATURE_TILE_BASE_URL = 'https://d3jqyw10j8e7p9.cloudfront.net';
|
|
||||||
const FEATURE_TILE_PATH = 'data-pipeline/data/score/tiles';
|
|
||||||
|
|
||||||
// This is the URL for the CDN that delivers the application
|
|
||||||
// const APP_BASE_URL = 'https://d2zjid6n5ja2pt.cloudfront.net';
|
|
||||||
const XYZ_SUFFIX = '{z}/{x}/{y}.pbf';
|
const XYZ_SUFFIX = '{z}/{x}/{y}.pbf';
|
||||||
|
|
||||||
export const featureURLForTilesetName = (tilesetName :string ) : string => {
|
export const featureURLForTilesetName = (tilesetName :string ) : string => {
|
||||||
return `${FEATURE_TILE_BASE_URL}/${FEATURE_TILE_PATH}/${tilesetName}/${XYZ_SUFFIX}`;
|
return [
|
||||||
|
process.env.GATSBY_DATA_ROOT_PATH,
|
||||||
|
process.env.GATSBY_DATA_PIPELINE_SCORE_PATH,
|
||||||
|
process.env.GATSBY_MAP_TILES_PATH,
|
||||||
|
tilesetName,
|
||||||
|
XYZ_SUFFIX,
|
||||||
|
].join('/');
|
||||||
};
|
};
|
||||||
export const FEATURE_TILE_HIGH_ZOOM_URL = featureURLForTilesetName('high');
|
export const FEATURE_TILE_HIGH_ZOOM_URL = featureURLForTilesetName('high');
|
||||||
export const FEATURE_TILE_LOW_ZOOM_URL = featureURLForTilesetName('low');
|
export const FEATURE_TILE_LOW_ZOOM_URL = featureURLForTilesetName('low');
|
||||||
|
|
3
data/data-serve/Dockerfile
Normal file
3
data/data-serve/Dockerfile
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
FROM node:latest
|
||||||
|
RUN npm install -g http-server
|
||||||
|
CMD http-server ./ --cors
|
|
@ -1,5 +1,6 @@
|
||||||
version: "3.4"
|
version: "3.4"
|
||||||
services:
|
services:
|
||||||
|
# The j40_data_pipeline service runs the ETL pipeline to create the score
|
||||||
score:
|
score:
|
||||||
image: j40_data_pipeline
|
image: j40_data_pipeline
|
||||||
container_name: j40_data_pipeline_1
|
container_name: j40_data_pipeline_1
|
||||||
|
@ -13,3 +14,27 @@ services:
|
||||||
environment:
|
environment:
|
||||||
ENV_FOR_DYNACONF: development
|
ENV_FOR_DYNACONF: development
|
||||||
PYTHONUNBUFFERED: 1
|
PYTHONUNBUFFERED: 1
|
||||||
|
|
||||||
|
# The score_server serves the data-pipeline volume as a URL
|
||||||
|
j40_score_server:
|
||||||
|
image: j40_score_server
|
||||||
|
container_name: j40_score_server_1
|
||||||
|
build: data/data-serve/.
|
||||||
|
volumes:
|
||||||
|
- ./data/data-pipeline/data_pipeline/data/score:/data/data-pipeline/data_pipeline/data/score
|
||||||
|
ports:
|
||||||
|
- 5000:8080
|
||||||
|
|
||||||
|
#The j40_website service runs the web app / map / site
|
||||||
|
j40_website:
|
||||||
|
image: j40_website
|
||||||
|
container_name: j40_website_1
|
||||||
|
build: ./client
|
||||||
|
environment:
|
||||||
|
DATA_SOURCE: local
|
||||||
|
volumes:
|
||||||
|
- ./client/src:/client/src
|
||||||
|
ports:
|
||||||
|
- 8000:6000
|
||||||
|
depends_on:
|
||||||
|
- "j40_score_server"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue