Test project to build simple RESTful service based on OpenApi definitions defined in /api
directory.
- Configuration with Viper
- Add support for flags (cobra?)
- Version tags / Build info
- Containerization
- OpenApi code generation
- REST server using echo.Echo
- Middleware for REST endpoints
- Picking structured logging library
- Dummy Frontend SPA
- Single Binary deployment with embedded SPA
- Persistence storage
- SearchStore capabilities
Directory | Description |
---|---|
./.iac |
"infrastructure as code" |
./api |
OpenAPI, gRPC contracts |
./bin/<arch> |
Build output directory, grouped by architecture (eg: darwin, linux) |
./cmd |
application main |
./config |
application specific configuration |
./internal |
project private libraries |
./pkg |
project libraries |
./scripts |
Shell scripts used in dev environment (env setup, automation etc) |
./ui |
frontend as Single Page Application |
Minimum
- Go 1.14+
- Go Modules
Recommended
- Git (SCM)
- Docker (containerization)
- Unix based system (for scripts execution)
- Javascript with React (for UI component development)
- yarn (frontend package manager)
- developer tools binaries installed on host
gomodroot=$(go list -m)
buildTime=$(date -u '+%Y-%m-%d %H:%M:%S %Z') && \
docker build \
--build-arg VERSION=$(git describe --tags --always --dirty) \
--build-arg GIT_COMMIT=$(git rev-list -1 HEAD) \
--build-arg BUILD_TIME=$buildTime \
--build-arg GO_MOD_ROOT=$gomodroot \
-t macpla/webapp .
docker run -p 8080:8080 --rm macpla/webapp
- build ui component (React App)
./scripts/build-ui.sh
- build backend with embedded SPA.
./scripts/build-local.sh
optional steps
- clean
pack2
generated files
./scripts/build-local.sh clean
- openApi spec generation
./scripts/openapi-gen.sh
http://localhost:8080/
-- React landing Page
http://localhost:8080/api/v1/demoapp/.well-known/alive?full=1
-- backend health-check
deepmap/oapi-codegen - OpenAPI 3 client and server boilerplate generator for GO
mikefarah/yq - cli YAML preprocessor
openapi-generator-cli - all purpose node based OpenAPI generator used to generate frontend client
gobuffalo/packr/v2 - static files to Go embedding processor