项目作者: Cinojose

项目描述 :
A simple student enrollment api server
高级语言: Go
项目地址: git://github.com/Cinojose/StudentEnrollmentApi.git
创建时间: 2020-04-20T11:57:18Z
项目社区:https://github.com/Cinojose/StudentEnrollmentApi

开源协议:

下载


Build Status

Student Enrollment Api Server

A student enrollment api server using Go Swagger

Prerequisites

  • Running mysql database with a table created based on the sql/student.sql
  • Docker engine

How to run ?

  1. # Download source code
  2. git clone https://github.com/Cinojose/StudentEnrollmentApi.git
  3. #setup the env variables
  4. export DB_USER=<db-user>
  5. export DB_PASSWORD=<db-password>
  6. export DB_NAME=<database-name>
  7. export DB_HOST=<database-host-address>
  8. # build the docker image
  9. docker build -t studentenrollment .
  10. # Run the docker image
  11. docker run -it -p 8001:8001 --env DB_USER --env DB_PASSWORD --env DB_NAME --env DB_HOST studentenrollment studentenrollment
  12. # The app can be accessed via following URL upon successful run
  13. # http://localhost:8001/internal/apidocs

How to run tests ?

Start the APP server using the above instructions

  1. # set up the env variables
  2. export API_PORT=<aplication port>
  3. export API_HOST=<application-host>
  4. # Build and run docker
  5. docker build -t unitest -f DockerfileTest . && docker rm unitest && docker run -it --env API_HOST --env API_PORT--name unitest unitest

Generating server stub using swagger

  1. # Generate a server stub using the swagger yml
  2. cd github.com/StudentEntollmentApi
  3. alias swagger="docker run --rm -it -e GOPATH=$HOME/go:/go -v $HOME:$HOME -w $(pwd) quay.io/goswagger/swagger"
  4. # Update the swagger.yml with your new changes
  5. swagger generate server -f swagger.yaml -A StudentEnrollmentApi
  6. # Run the above docker commands to build the code

App Deployment

CICD diagram