Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/anhcaooo/electric-notifications

Web server that responsible for handling push notifications between clients
https://github.com/anhcaooo/electric-notifications

fcm-push-notification github-actions golang mongodb user

Last synced: about 1 month ago
JSON representation

Web server that responsible for handling push notifications between clients

Awesome Lists containing this project

README

        

# electric-notifications

A service that responsible for sending notifications to clients

## Development Setup
### Prerequisite
- Make sure you have Go installed on your machine. If not, you can install from [Golang official page](https://go.dev/doc/install)
- Make sure you set up the environment variables by specifying it in the `config/config.yml`

### Getting started
1. Fetch all dependencies listed in the `go.mod` file and remove unused dependencies from repository
```bash
go mod tidy
```

2. Take total control over the code
```bash
go mod vendor
```
This command will give you total control of all libraries which are used in this repo. Even if the owner of some libraries change, archive or remove the code, you still have the code running there. Learn more: [understand "go mod vendor"](https://stackoverflow.com/questions/76705408/understanding-go-mod-vendor)

3. Run the application
```bash
go run cmd/main.go
```

### Build Docker image
```bash
# Build image locally
# Option 1
docker build --tag : .

# Option 2
docker build -t : .

# Option 3
# this command by default will build image with tag version 'latest'.
# this is an enhancement when before the image is built, all unit tests will be executed
make docker
```

### Run Docker image locally
```bash
docker run --name -d :
```
Terms explanation:

`--name`: specify the name of image while running container

`-d`: detached mode

**Notes**: if you are running several containers in same machine, in order to make images can accessible between each other. You can consider to use Docker Network
```bash
# create docker network
docker network create

# include docker network while run image
docker run --name -d --network :
```

### Tag and push image to Docker hub
**Note**: firstly need to log in Docker (only in case you have not logged in)

```bash
docker login -u "" -p "" docker.io
```

#### Step 1
```bash
# Tag image
docker tag : /:
```

#### Step 2
```bash
# Push image to Docker hub
docker push /:
```