Giter Site home page Giter Site logo

coffeeserver's Introduction

Coffee Server

Find Coffee with Friends

Mac Dev Sandbox

Installation

  1. Install and run Postgres. PostgresApp does a great job.
  2. Clone this repo
  3. Set up the enivronment variables found in env_example.
    • Be sure to remember the admin email and password for step 5
    • You can set runtime environment variables by editting Xcode’s project scheme.
      • Product > Scheme > Edit Scheme. Then go to Run > Arguments > Environment Variables
  4. Build and run
  5. Explore the API using RapidAPI for Mac. Open the CoffeeServer.paw file to find various routes. Many routes are admin protected. You’ll need your login info from step 3

On the first run, the super user will be created. You’ll need the super user account to do most create update and delete actions.

Production Deployment

Prerequisites

  1. Some type of constantly internet connected server-like host
  2. ssh into your host server
  3. Install git. Documentation
  4. Install Docker. Documentation
  5. Clone this repo into a reasonable directory. Ex: /home/

Configure and Boot the Service Fleet

The entire service fleet (app, database, and Caddy proxy) are configured with the docker-compose file.

From the outside in:

A request to your service will first reach Caddy which knows that your server name — say, CoffeeCoffee.world — exists and should proxy the request to the app. The app is a Vapor server written in Swift 5.7. It connects to the database which is Postres to save and fetch data.

  1. Configure the Caddyfile.
    • Copy the example file cp Caddyfile-example Caddyfile
    • Open Caddyfile in your text editor and change the example.com domain name to whichever domain you’re using. Note that this doesn’t include the url scheme — just the stuff after ://.
  2. Configure the .env file
    • Copy the example file cp env_example .env
    • Open .env in your text editor and add your values for each value
  3. Boot the service
    • If this is the first run then you’ll need to build the app image: docker compose up --build -d
      • If the build fails for any reason, you can build on your local machine and push to docker hub. Your dev sandbox is also likely a great deal faster than a typical web host.
    • In standard operation docker compose up -d
  4. Run any migrations
    • If this is the first run then you must run the database migrations: docker compose run migrate
    • There is no effect to run migrations that have already been run
    • The only time you won’t need to run migrations is if you’re certain that the data models haven’t changed

Confirm Service Readiness

At this point the service fleet should be running and connected to the database.

  1. Assert that the appropriate docker containers are running.
    • docker ps should have three running containers. coffee-server:latest, caddy:XXXX, and postgres:XXXX
  2. Assert /healthcheck is OK. From inside your ssh session on the server…
    • curl "http://127.0.0.1:8080/healthcheck" should have output similiar to: OK. Database Check: Event count = 0
  3. Assert the service is reachable at your domain. Close your server ssh session and try…
    • curl "http://EXAMPLE.COM/healthcheck" should be OK.
  4. Finally, assert that Let’s Encrypt Caddy server is working.
    • curl "https://EXAMPLE.COM/healthcheck" should also be OK.

At this point, using a web browser and opening your URL should see the “Coffee”.

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.