Giter VIP home page Giter VIP logo

fantastic-dollop's Introduction

Web Component

This is a web skeleton with a basic user login functionality.

Setup (Non-Docker)

Consult the README.md in the API and UI subdirectories.

Setup (Docker)

Note that the docker setup is configured for development by default. Traffic is served over unencrypted http. Production setups should, at a minimum, use encrypted https.

Docker Prerequisites

The docker and docker-compose commands must be available. If you're using older versions than specified, it might still work, it's just untested.

Run

Make sure you're in the web component's root directory (where this README is located) and run:

docker-compose up

A default admin user is available with:

  • Username: admin
  • Password: admin

The default docker-compose up command will start the containers in the foreground, showing all log output directly. To exit, press Ctrl-c or whatever key combo your OS uses to send SIGINT.

Changes to the source files should be automatically reloaded on the running containers. In practice, frontend CSS sometimes don't go through properly, so you might need to manually refresh the page to see the changes. Some python errors, particularly syntax problems, can kill the reloader. In such cases, you can restart just the API container with:

docker-compose restart api

On the API side, two automatically generated interactive documention is available at:

Note the different port used, 5001 instead of 5000. This is the actual port that the API is running on. A reverse proxy is used to redirect traffic from http://localhost:5000/api to http://localhost:5001/. This was necessary in order to avoid CORS errors in the browser.

The reverse proxy status page is at: http://localhost:5002/

A web frontend to the Postgres database is available at:

  • http://localhost:5003/, powered by Adminer, login information:
    • System: PostgreSQL
    • Server: api_db
    • Username: api_db
    • Password: api_db
    • Database: api_db
Execute Commands

To run arbitary commands, just replace <COMMAND> with what you wish to run:

docker-compose exec <SERVICENAME> <COMMAND>

Check docker-compose.yml for the service names you should use in place of <SERVICENAME>.

Example:

  • To get shell access in the UI container, just execute bash

      docker-compose exec ui bash
    
Hard Reset

WARNING: This will remove all data and containers!

docker-compose down -v
Running in the Background

If you wish to run this in the background, without the live log output, add the -d option:

docker-compose up -d

To stop running:

docker-compose stop

To access the logs in this mode, run:

docker-compose logs <SERVICENAME>

Examples:

  • API

      docker-compose logs api
    
  • API's Database (Postgre)

      docker-compose logs api_db
    

Updating dependencies

API

First, follow the API README.md instructions for adding/updating dependencies.

If the app is currently running, shut it down. Rebuild the API docker image so it has the new dependencies using:

docker-compose build api

Then start it back up again.

Common Problems

  • API calls are not going through (being redirected to the UI).

    You may need to add a / at the end of your API URL. http://localhost:5000/api/users/ will go to the API. http://localhost:5000/api/users will get redirected to http://localhost:5000/users/.

  • CORS issue due to API and UI running separately.

    The docker-compose dev environment is using the Traefik reverse proxy to make it look like API requests are going to the same server as the UI. If this doesn't work for you or you need something simpler, you can specify allowed origins on the API side manually using this tutorial.

fantastic-dollop's People

Contributors

ionparticle avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

qazzquimby

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.