Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/slashpai/voter-app
A simple voter app
https://github.com/slashpai/voter-app
Last synced: 9 days ago
JSON representation
A simple voter app
- Host: GitHub
- URL: https://github.com/slashpai/voter-app
- Owner: slashpai
- License: apache-2.0
- Created: 2021-07-04T05:56:48.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-07T11:42:29.000Z (over 3 years ago)
- Last Synced: 2024-06-21T01:44:02.960Z (5 months ago)
- Language: HTML
- Size: 129 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# voter-app
[![build](https://github.com/slashpai/voter-app/workflows/build/badge.svg)](https://github.com/slashpai/voter-app/actions?query=workflow%3Abuild)
[![go lint](https://github.com/slashpai/voter-app/workflows/go-lint/badge.svg)](https://github.com/slashpai/voter-app/actions?query=workflow%3Ago-lint)
[![markdown links](https://github.com/slashpai/voter-app/workflows/md-links/badge.svg)](https://github.com/slashpai/voter-app/actions?query=workflow%3Amd-links)This is a simplified version of [example-voting-app](https://github.com/dockersamples/example-voting-app) written in go.
This app lets you vote any number of times. This is not an example for properly architected app but created to show how containers can be utilized for multi-tier applications.## Architecture
![voter_app](docs/voter_app_arch.png)
## Pre-requisite
Redis running in system as standalone or as container. Set environment variables accordingly while running app as standalone or as a container.
```go
docker run -d -p 6379:6379 --name redis_voter redis:alpine
```## Build locally
From the location of clonned repo
```
make build-local
```Set environment variables, update the values accordingly as per your redis setup
```bash
export VOTER_REDIS_ADDR="localhost:6379"
export VOTER_REDIS_DB=0
export VOTER_REDIS_PASSWORD=""
``````go
./voter-app
```## Build docker image
```go
DATE=$(date +"%Y%m%d")
docker build . -t voter-app:$DATE
```### Run as container
Example shown below with both redis and voter app running as container. Note `--link` option where redis container address specified.
```go
docker run -p 8080:8080 --env VOTER_REDIS_ADDR="redis_voter:6379" --link redis_voter --env VOTER_REDIS_PASSWORD="" --env VOTER_REDIS_DB=0 voter-app:$DATE
```Go to [http://localhost:8080](http://localhost:8080) to access the application
## Using docker-compose
This will build the image and setup the voter-app stack with come command.
```
docker-compose up
```Go to [http://localhost:8090](http://localhost:8090) to access the application
## Contributing
* Fork the project on GitHub
* Clone the project
* Add changes (and tests if applicable)
* Commit and push
* Create a pull request## TODO
* Add tests
## License
[Apache License](LICENSE)