GithubHelp home page GithubHelp logo

vitals9367 / berth-reservations-admin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from city-of-helsinki/berth-reservations-admin

0.0 0.0 0.0 8.47 MB

Staff interface for handling berth applications and registry

License: MIT License

Shell 0.04% JavaScript 0.52% TypeScript 96.25% HTML 0.11% Dockerfile 0.14% SCSS 2.94%

berth-reservations-admin's Introduction

Berth Reservation Admin

CI status Browser Tests status Codecov Dependency Status devDependencies Status GitHub license

Staff interface for Venepaikka.

Environments:


Requirements

  • Node 12.x
  • Yarn
  • Git
  • Docker and docker-compose
  • Recommended editor for this project is Visual Studio Code

Common setup

Clone the repo and install the dependencies.

git clone https://github.com/City-of-Helsinki/berth-reservations-admin.git
cd berth-reservations-admin

yarn

After cloning this repository, create a new .env.development.local file from the provided .env file to be able to change environment variables such as REACT_APP_API_URL.

cp .env .env.development.local

Development environment setup

React development environment

To start the development server, run the following

yarn start

Open http://localhost:3000 and take a look around.

Testing

To run tests, run:

yarn test

Dockerized development environment

  1. Check that Docker and Docker CLI are installed, and port 3000 is free and not occupied by a running server.

  2. Make sure you have env variables in .env.development.local, otherwise extend it from the example by:

    cp .env .env.development.local
  3. Start building Docker image and start container:

    docker-compose up
  4. Open http://localhost:3000.

Dockerized production environment

  1. Check that Docker and Docker CLI are installed, port 80 is free and not occupied by a running server.

  2. Build Docker image with:

    docker build -t berth-reservation-admin .
  3. Start Docker container with:

    docker container run -p 80:80 -d berth-reservation-admin
  4. Open http://localhost.

Useful Docker commands

  • To rebuild the Docker images:

    docker-compose up --force-recreate --build
  • To enter inside Docker container environment:

    docker-compose exec app sh
  • Remove Docker container if needed:

    docker rm -f berth-reservation-admin
  • Remove Docker image:

    docker rmi berth-reservations-admin_app
  • Running commands inside the Docker environment (tests for example): (Make sure Docker container is running) $ docker-compose run app YOUR_COMMAND_HERE

    • Encounter node-sass issue ? Try going inside the Docker container environment and running npm rebuild node-sass

Setting up development environment locally with docker

These instruction apply when you want to locally run all the required services. You will also need to configure values in your .env.development.local to point to your locally running instances.

Set tunnistamo hostname

Add the following line to your hosts file (/etc/hosts on mac and linux):

127.0.0.1 tunnistamo-backend

Create a new OAuth app on GitHub

Go to https://github.com/settings/developers/ and add a new app with the following settings:

Save. You'll need the created Client ID and Client Secret for configuring tunnistamo in the next step.

Install local tunnistamo

Clone https://github.com/City-of-Helsinki/tunnistamo/.

Follow the instructions for setting up tunnistamo locally. Before running docker-compose up set the following settings in tunnistamo roots docker-compose.env.yaml:

  • SOCIAL_AUTH_GITHUB_KEY: Client ID from the GitHub OAuth app
  • SOCIAL_AUTH_GITHUB_SECRET: Client Secret from the GitHub OAuth app

To get silent renew to work locally you also need to set:

  • ALLOW_CROSS_SITE_SESSION_COOKIE=True

After you've got tunnistamo running locally, access the tunnistamo docker container:

docker-compose exec django bash

and execute the following four commands inside your docker container:

./manage.py add_oidc_client -n berths-admin-ui -t "id_token token" -u "http://localhost:3000/callback" "http://localhost:3000/silent-callback.html" -i https://api.hel.fi/auth/berths-admin-ui -m github -s dev
./manage.py add_oidc_client -n berths-api -t "code" -u http://localhost:8081/return -i https://api.hel.fi/auth/berths -m github -s dev -c
./manage.py add_oidc_api -n berths -d https://api.hel.fi/auth -s email,profile -c https://api.hel.fi/auth/berths
./manage.py add_oidc_api_scope -an berths -c https://api.hel.fi/auth/berths -n "Venepaikka" -d"Lorem ipsum"
./manage.py add_oidc_client_to_api_scope -asi https://api.hel.fi/auth/berths -c https://api.hel.fi/auth/berths-admin-ui
./manage.py add_oidc_client_to_api_scope -asi https://api.hel.fi/auth/helsinkiprofile -c https://api.hel.fi/auth/berths-admin-ui

Also add http://localhost:3000/ to Post Logout Redirect URIs of berths-admin-ui client on Tunnistamo Django admin http://tunnistamo-backend:8000/admin/oidc_provider/client/

Set up open-city-profile backend

Clone https://github.com/City-of-Helsinki/open-city-profile/ and follow the instructions in the repository for setting up the project locally.

Client ID's of services using the open-city-profile should be configured in the Django Admin (http://localhost:8080/admin/):

Set up berth-reservations backends

Clone and set the following services as instructed:

Set up admin permissions

Before you can access the berth-reservations-admin site, your Tunnistamo user needs to be set up with permissions.

Permissions that need to be added:

Deployment

Staging deployment

Staging deployment is handled by CI/CD pipeline for new commits on develop branch.

Browser tests

Browser tests are written in TypeScript with TestCafe framework and they are run against test environment in CI as GitHub Actions Cron Job (daily) with Chrome (headless mode).

How to run locally

Set test user login credentials

  • Open .env.development.local and set BROWSER_TESTS_UID and BROWSER_TESTS_PWD
  • TBD: Link to values

Running against test environment

  • yarn browser-test

Running against local environment

  • yarn browser-test:local

CI setup

GitHub Actions runs the yarn browser-test:ci script.

berth-reservations-admin's People

Contributors

a-rmz avatar ahie avatar antti-mikael avatar charn avatar dependabot[bot] avatar haavikko avatar hi-fi avatar igordavydsson avatar jokinen avatar joonvena avatar kristianjokela avatar melniiv avatar nikomakela avatar nizar-rahme avatar ruriky avatar santtul avatar sartonon avatar tatuarvela avatar terovirtanen avatar tuomas777 avatar vitals9367 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.