Git Product home page Git Product logo

commonspace's Introduction

Running the Administrator Frontend and API Server Locally on Kubernetes

Kubernetes is an open source project designed to automate the deployent, scaling, and management of cloud based applications. Commons uses kubernetes to run in the cloud. Various cloud services provide support for running and monitoring applications in a kubernetes environment. In order to test out and debug issues related to prodution environments developers should run commons using minikube, which allows developers to run kubernetes environments on a single machine. Follow the appropriate install instructions for your machine. Once installed you can use the following command line instructions to run Commons in a cloud-like environment. Note before running the application in kubernetes, [we will need access to an appropriate postgres instance] (## Connecting to postgres from minikube)

minikube start
eval $(minikube docker-env)
packer build -var version=$(git rev-parse --short=8 HEAD) -var container_image_name=swl-eng/commons-nginx deployment/commons_nginx.json
packer build -var version=$(git rev-parse --short=8 HEAD) -var container_image_name=swl-eng/commons-server deployment/commons_server.json
kubectl patch --local -o yaml -p \ '
              {
                "spec": {
                   "template": {
                        "spec": {
                          "containers": [
                                {
                                    "name": "commons-nginx",
                                    "image": "swl-eng/commons-nginx:'$(git rev-parse --short=8 HEAD)'"
                                },
                                {
                                    "name": "commons-server",
                                    "image": "swl-eng/commons-server:'$(git rev-parse --short=8 HEAD)'"
                                }
                            ]
                        }
                    }
                  }
              }' -f deployment/commons-development-template.yml > deployment/commons-development.yml
kubectl create secret generic commons-config --from-file=.env=config/development.env
kubectl apply -f deployment/development-postgres-endpoint.yml
kubectl apply -f deployment/commons-development.yml
kubectl apply -f deployment/commons_server_service.yml
kubectl apply -f deployment/commons_nginx_service.yml
kubectl apply -f deployment/commons_ingress.yml
cd deployment/ && ./develop.sh
kubectl delete -f deployment/development-postgres-endpoint.yml
kubectl delete -f deployment/commons-development.yml
kubectl delete -f deployment/commons_server_service.yml
kubectl delete -f deployment/commons_nginx_service.yml
kubectl delete -f deployment/commons_ingress.yml

N.B. Two Things: Dont forget to add your secrets to kubernetes correctly, otherwise you get silent errors Don't forget to turn off your minikube when you're all done, you probably could have guessed:

minikube stop

Frontend and Expo

Installation

Install postgres linux

sudo apt-get install libpq-dev
brew install postgres
cd expo_project
yarn

Running

expo-cli start

Admin App

There are really basic html forms that allow a user to interact and experiment with firestore. It's a simple static website, with javascript form index.js, and html in index.html. Use your favorite http server from the root directory.

python -m http.server

Firebase Functions

Deployment

Connect your ci system.

SQL

Local Development -- Backend

Install Packer

cd deployment
packer build postgres.json
docker run -p 5431:5431 swl-eng/commons-postgres:$(../.version) postgres -p 5431
psql -f deployment/init.sql

Integration testing

The gcp cloud functions interact with Postgreql. If you're a reasonable human being you want to check the simple stuff really quickly without deploying everyting to the cloud. In the spirit of this, load the sql into a docker container running postgres and test the functions that interact with postgres.

First link the .env file:

ln -s config/development.env .env

Start a new environment, currently must be done for each run of a set of test :(

cd deployment && ./develop.sh

In order to run test, the jest binary must be available to the execution environment.

yarn run test

GCP development

Follow the instructions to connect to Cloud SQL

cloud_sql_proxy -instances=<INSTANCE_CONNECTION_NAME>=tcp:5432 -credential_file=<PATH_TO_KEY_FILE>
Deploying SQL changes

Once the cloud sql proxy is running.

psql "host=127.0.0.1 sslmode=disable dbname=postgres user=postgres" -f deployment/reset.sql
psql "host=127.0.0.1 sslmode=disable dbname=postgres user=postgres" -f deployment/init.sql

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.