Code Monkey home page Code Monkey logo

io-developer-portal-frontend's Introduction

IO developer portal frontend

The repository contains the code implementing IO developer portal frontend.

Tools

Build the application

The application can potentially run anywhere, either directly on a bare-bone machine, or in a form of a Docker container. Every change to the code, triggers an automated image build on DockerHub.

Images are consumed by production deployments, where they're usually deployed on top of Kubernetes clusters. For more informations about IO production deployments and IO helm-charts, have a look at the io-infrastructure-post-config repository.

Test the application locally

The application can be built and tested locally, either directly on the developer machine (directly using development tools, such as yarn or parcel), or as a Docker-based image.

Test directly on the developer machine

The application can be directly tested on the developer machine, using yarn:

# Install dependencies
yarn install

# Export env variables from .env.io-developer-portal.development
export $(grep -v '^#' .env.io-developer-portal.development | xargs) && chmod +x env.sh && source env.sh

# Run the application on a local dev server
yarn parcel:serve

Then, point your browser to

Test with Docker

To test the application, run in the root folder:

docker-compose up

Then, point your browser to

To bring down the test environment:

docker-compose down

Sometimes, it may be needed to re-built the frontend image, which is instead cached by Docker, once built the first time. To overcome this behavior, run:

docker-compose up --build

Production deployments

At this point in time the application is served in two environments: Kubernetes (AKS), in form of Docker image, and on GitHub pages.

Configuration

The table below describes all the Environment variables needed by the application.

Variable name Description type
IO_DEVELOPER_PORTAL_PORT The port the service will listen on int
IO_DEVELOPER_PORTAL_BACKEND Full url of the backend application string
IO_DEVELOPER_PORTAL_APIM_BASE_URL Full url and path for the APIM string
IO_DEVELOPER_PORTAL_BASE_URL Base URL for the application string
IO_DEVELOPER_PORTAL_PUBLIC_PATH Public base url for the application string
IO_DEVELOPER_PORTAL_TITLE Application title string

Environment variables run-time injection

The frontend container needs to adapt to different environments, reading at run-time environment variables values. For example, the application needs to know the address of the backend application. This is a non trivial task, since Javascript code runs on the client machine of the user executing the application, which prevents the application from directly reading the environment variables from the container.

To overcome this limitation, an env.sh bash script inside the main folder is executed every time the frontend application container starts, then is subsequently deleted. The script reads the environment variables and produces an env-config.js file that is then automatically copied together with the rest of the files to be served by the webserver. The index.html file (in the main folder of this repository) links already to env-config.js, which is read every time the user opens the application in a browser.

IMPORTANT: The env.sh script reads and automatically injects in env-config.js all environment variables prefixed with IO_DEVELOPER_PORTAL, for example IO_DEVELOPER_PORTAL_PORT.

To read the variable values inside the frontend application, use window._env_.IO_DEVELOPER_PORTAL_YOUR_VAR.

Deploy on AKS

The AKS deployment is driven by a specific helm-chart. More informations are available in the IO infrastructure post config repository.

Deploy on GitHub pages

The deployment on GitHub pages is achieved pushing the artifacts created as consequence of the build to the gh-pages branch of this repository.

To publish on GitHub pages, run:

# Fill the env-config.js file with the variables needed by the application to work
export $(grep -v '^#' .env.io-developer-portal.development | xargs) && chmod +x env.sh && source env.sh

# Build the application
yarn build

# Deploy to GitHub pages
yarn deploy

io-developer-portal-frontend's People

Contributors

alexgpeppe avatar balanza avatar burnedmarshal avatar cloudify avatar dependabot-preview[bot] avatar dependabot[bot] avatar francescopersico avatar gesposito avatar giamma1295 avatar giskarda avatar giuseppedipinto avatar gunzip avatar infantesimone avatar iwoak avatar lofrance avatar lucaprete avatar pagopa-github-bot avatar pasqualedevita avatar raicastino avatar snyk-bot avatar stefanodoc avatar vito80ba avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.