GithubHelp home page GithubHelp logo

go-fastapi-fork's Introduction

Prerequisites:

Example Deployment Locally:

  1. clone the repo git clone https://github.com/geneontology/go-fastapi
  2. install requirements into a virtual environment poetry install
  3. start the API server make start
  4. run the tests make test

Note: tests will run with or without a functioning server locally.

Alternate development environment - Using Docker

  1. build the docker image
docker build -t geneontology/go-fastapi .
  1. run the docker image

-d tells docker to run the image in the background (the image includes a command to start the API), so this will run the image and start the API server but give the control of the terminal back to the local user.

-p tells docker to map the container port 8080 to the host port 8080. This way the user can access the API docker version of the running API from their local browser via: http://127.0.0.1:8080/docs

docker run -d -p 8080:8080 geneontology/go-fastapi

Deploying a change in the API code to docker image:

To remove images and containers: docker rm -vf $(docker ps -aq) (removes all local images) docker rmi -f $(docker images -aq) (removes all local containers)

Check the port mapping: docker port go-fastapi (see the port mapping)

  1. checkout and build the API code locally

This should result in a locally running API server on port 8081 (note the port difference from the docker version)

git clone https://github.com/geneontology/go-fastapi
cd go-fastapi
make dev

localhost:8081/docs will be available for testing the API locally if the commands above are successful.

  1. make a change to the API code
  2. test the API changes
make test
  1. rebuild the docker image with the changed code
docker build -t geneontology/go-fastapi .
  1. test the rebuilt docker image
docker run -i -t --name geneontology/go-fastapi -p 8080:8080 geneontology/go-fastapi bash
make start
make test

Pushing to Dockerhub

GitHub Actions will automatically build and push the docker image to Dockerhub when a new versioned tag is created. To do this manually, run the following commands, replacing [tag_name] with the tag or version number:

docker login
docker build -t geneontology/go-fastapi .
docker tag geneontology/go-fastapi:latest geneontology/go-fastapi:[tag_name]
docker push geneontology/go-fastapi:[tag_name]

go-fastapi-fork's People

Contributors

sierra-moxon avatar

Watchers

 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.