Skip to content

Commit

Permalink
cgra-bear-8-10-0 - Init
Browse files Browse the repository at this point in the history
  • Loading branch information
BugsBunny338 committed Nov 29, 2022
1 parent e7977fd commit 0dc8ac3
Show file tree
Hide file tree
Showing 82 changed files with 22,730 additions and 0 deletions.
1 change: 1 addition & 0 deletions cgra-bear-8-10-0/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions cgra-bear-8-10-0/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP_PREFLIGHT_CHECK=true
25 changes: 25 additions & 0 deletions cgra-bear-8-10-0/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

.gdcatalogrc
1 change: 1 addition & 0 deletions cgra-bear-8-10-0/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.13.0
5 changes: 5 additions & 0 deletions cgra-bear-8-10-0/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 110,
"tabWidth": 4,
"trailingComma": "all"
}
15 changes: 15 additions & 0 deletions cgra-bear-8-10-0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM nginx:1.19-alpine

# the port nginx will listen on
# you can either change it here, or by using --env PORT=1234 when running the container
ENV PORT=8080

COPY ./docker/nginx.conf.template /etc/nginx/templates/default.conf.template
COPY ./build/ /usr/share/nginx/html

# Uncomment the lines below if you are setting up HTTPS for localhost
#
# COPY ./docker/localhost.crt /etc/ssl/certs/localhost.crt
# COPY ./docker/localhost.key /etc/ssl/private/localhost.key

CMD ["nginx", "-g", "daemon off;"]
64 changes: 64 additions & 0 deletions cgra-bear-8-10-0/HOWTO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br>
You will also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.<br>
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.<br>
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.<br>
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting

### Analyzing the Bundle Size

This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size

### Making a Progressive Web App

This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app

### Advanced Configuration

This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration

### `npm run build` fails to minify

This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
112 changes: 112 additions & 0 deletions cgra-bear-8-10-0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
## GoodData.UI Accelerator Toolkit Application

This project was bootstrapped with [GoodData.UI Accelerator Toolkit](https://sdk.gooddata.com/gooddata-ui/docs/create_new_application.html).

- To start the application on your workstation run the `npm run start` command.
- To create a production build run the `npm run build` command.

This project uses the [Create React App](https://github.com/facebook/create-react-app) (CRA) scripts and infrastructure, you
can find the original documentation for CRA in [HOWTO.md](./HOWTO.md).

### Getting started

Before you can create visualizations for data in your workspace, you need to export its Logical Data Model (LDM). You can
then use the exported LDM entities to define the visualizations.

The export is simple: run the `npm run refresh-md` command.

- This command will use information from [constants.js](./src/constants.js). It will connect to GoodData servers running
on the host specified in the `backend` property and [export](https://sdk.gooddata.com/gooddata-ui/docs/export_catalog.html) MD for the `workspace` of your choice.
- If your configuration does not specify `workspace`, the script will prompt you to choose one of the workspaces available in the `backend`.

Once done, you will find that the [src/md/full.js](src/md/full.js) file will be populated with attribute and measure definitions
matching the MD defined in your workspace. You can then use these generated definitions as inputs to the different
[visualization components](https://sdk.gooddata.com/gooddata-ui/docs/start_with_visual_components.html) available in GoodData.UI SDK.

**Note: Before running this script, please make sure `backend` is defined in `constants.js` file.**

**Hint: To avoid constantly typing in credentials, you can create `.gdcatalogrc` file where you define your `username` and `password`.**

### Deployment

There are two ways to deploy your application.

1. If your domain does not have CORS set up and you want to get up and running fast, you can use the pre-configured Docker image included with the app.
2. If the Docker way is not suitable for you, you can build and deploy the app manually (keep in mind that you will have to setup CORS on your GoodData domain so that it allows access from your application).

#### Using the built-in Docker support

The application comes with a simple Dockerfile. This image is a pre-configured nginx instance that both serves the application files and acts as a reverse proxy for your GoodData domain. In this deployment, your GoodData domain does not need any CORS setup because the application will only communicate with its origin server.
To use it, run these commands in your terminal:

```bash
# build production version of your application
npm run build
# build the docker image
docker build -t your-tag .
# run the docker image
docker run \
--rm \
--publish 3000:8080 \
--name your-name \
--env BACKEND_HOST="secure.gooddata.com" \
--env BACKEND_URL="https://secure.gooddata.com" \
your-tag:latest
```

The meaning of the `docker run` parameters is:

- `--publish 3000:8080` – expose the nginx running on port 8080 by default (you can change that if needed by adding `--env PORT=5000`, just make sure you update the `--publish` value accordingly), to port 3000 on your machine.
- `--name your-name` – assign a name to the container run.
- `--env BACKEND_HOST="secure.gooddata.com"` and `--env BACKEND_URL="https://secure.gooddata.com"` – set the host/URL where the GoodData analytical backend is running respectively. You need to change these values if you host GoodData on a different domain.

**IMPORTANT**: The Docker image is not setup with SSL certificates and thus by default offers no support for HTTPS. Read on to learn more.

##### HTTPS on localhost

If you intend to use the Docker image on localhost and you need support for HTTPS, then you can use self-signed certificates.

First generate the certificate and private key and store them in the `docker` directory.

```bash
cd docker
openssl req -x509 -out localhost.crt -keyout localhost.key \
-newkey rsa:2048 -nodes -sha256 \
-subj '/CN=localhost' -extensions EXT -config <( \
printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
```

Then edit the [Dockerfile](./Dockerfile) and [docker/nginx.conf.template](./docker/nginx.conf.template) and uncomment the marked-up lines.

##### HTTPS in production

If you plan on hosting your application on platforms such as Heroku that solve the HTTPS transport and do the SSL termination
for you, then you do not have to set up anything - this image is good to go.

**IMPORTANT**: If your hosting does not provide SSL termination then we strongly recommend to not use this image as is. Your data or other
sensitive information will be at serious risk.

If you already own certificates issued by a trusted CA, then you can reconfigure the nginx to use them. The process is similar to
how you set up HTTPS on localhost.

If you do not own certificates but have your own domain then you can use the [Let's Encrypt](https://letsencrypt.org/) Certificate Authority. We recommend
that you switch the base image in the [Dockerfile](./Dockerfile) and use the [nginx-certbot](https://hub.docker.com/r/jonasal/nginx-certbot); this will
automate the certificate acquisition and renewal process for you.

#### Building and deploying manually

To deploy the application without the use of the provided Dockerfile, you can run

```bash
npm run build
```

which will create a `build` folder with all the build outputs that can you can then host anyway you want. Built like this, the application will assume that the GoodData Analytical Backend is hosted on the same host as the application itself.

In case you want to host the application on a host other than the one you use to host the GoodData Analytical Backend, you should build the application like this

```bash
npm run build-with-explicit-hostname
```

Built like this, the application will connect to the GoodData Analytical Backend hosted at the host specified in `src/constants.js` in `backend` field.
74 changes: 74 additions & 0 deletions cgra-bear-8-10-0/docker/nginx.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_types image/jpeg image/bmp image/svg+xml text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon;

client_max_body_size 10M;

log_format json escape=json '{'
'"timestamp": "$time_iso8601", '
'"remoteAddress": "$remote_addr", '
'"method": "$request_method", '
'"url": "$request_uri", '
'"httpVersion": "$server_protocol", '
'"statusCode": "$status", '
'"body_bytes_sent":"$body_bytes_sent",'
'"requestTime": "$request_time", '
'"upstreamTime": "$upstream_response_time", '
'"userAgent": "$http_user_agent", '
'"referer": "$http_referer", '
'"requestSize": "$request_length", '
'"responseSize": "$bytes_sent"'
'}';

map $sent_http_content_type $expires {
default off;
text/html -1;
application/json -1;
text/css max;
application/javascript max;
}

server {
#
# Comment this out if you are setting up HTTPS for localhost
#
listen ${PORT};

#
# Uncomment the lines below if you are setting up HTTPS for localhost
#
# listen ${PORT} ssl;
#
# server_name localhost;
# ssl_certificate /etc/ssl/certs/localhost.crt;
# ssl_certificate_key /etc/ssl/private/localhost.key;
#

root /usr/share/nginx/html;
index index.html;
access_log /var/log/nginx/access.log json;

expires $expires;

location / {
try_files $uri $uri/ /index.html;
}

location ^~ /gdc {
proxy_pass ${BACKEND_URL};
proxy_set_header x-forwarded-host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host ${BACKEND_HOST};
proxy_set_header Referer ${BACKEND_URL};
proxy_set_header Origin "";
proxy_cookie_domain ${BACKEND_HOST} $host;
proxy_ssl_server_name on;
}

location ~* \.(?:css|js)$ {
add_header Cache-Control "public";
}

}
4 changes: 4 additions & 0 deletions cgra-bear-8-10-0/jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const enzyme = require("enzyme");
const Adapter = require("@wojtekmaj/enzyme-adapter-react-17");

enzyme.configure({ adapter: new Adapter() });
7 changes: 7 additions & 0 deletions cgra-bear-8-10-0/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"checkJs": true,
"jsx": "react"
},
"exclude": ["node_modules"]
}
Loading

0 comments on commit 0dc8ac3

Please sign in to comment.