Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v1

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15

- name: Build
working-directory: docker/go
run: go build -v ./...

- name: Test
working-directory: docker/go
run: go test -v ./...
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
.env
docker/go/cmd
docker/go/pkg
docker/go/go.mod
cmd/bot/bot
cmd/bot/bot
41 changes: 29 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Workout reminder bot

![build](https://github.com/nextuponstream/workoutReminderBot/actions/workflows/main.yml/badge.svg)

# How to use the bot
## How to use the bot

<img src="./assets/stay_hydrated.jpg" width="40%" />

## Bot commands
### Bot commands

... you can issue as a telegram user:
| Command | description |
|---|----|
Expand All @@ -19,13 +23,22 @@
|`/cancel [<routines>]`| cancel all reminders or for all mentionned routines |

**🔴 IMPORTANT 🔴**: Set your `/timezone` so all other commands can work correctly for you!!!
# Setup
## BotFather
### Register bot

## Setup

### Build

### BotFather

#### Register bot

Go on telegram, start a chat with BotFather and create a new bot via `/newBot`. Set up a bot name and the bot user name.
### Command hints

#### Command hints

With BotFather, set commands with `/setCommands` and paste:
```

```txt
help - instructions on bot usage
timezone - 🔴 set your timezone for all commands to work correctly (default is CET)
exercise - create exercise for activity and optionnaly indicate its reps, sets, length, duration and notes (e.g. /exercise <activity name> <r, s, l, d or n value>)
Expand All @@ -37,11 +50,15 @@ routine - create a routine made of workouts (e.g. /routine gitStrong)
remindme - sends a reminder to maintain the routine (e.g. /remindme gitStrong 16 21 tu we th fr sa)
cancel - cancel all reminders or for all mentionned routines (e.g. /cancel OR /cancel gitStrong)
```
## Environnement file

### Environnement file

Create your own environnement file `.env` by following the example file `example.env`.
## Start

### Start

```bash
git clone git@github.com:nextuponstream/workoutReminderBot.git
cd workoutReminderBot/scripts
sh runBot.sh
```
cd workoutReminderBot
docker-compose up -d
```
36 changes: 16 additions & 20 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
version: '3.9'
networks:
web:
version: "3.9"

services:
services:
mdb:
build: ./docker/mongo
image: nextuponstream/wrb_mongo
image: mongo:3.6.22
container_name: ${CONTAINER_NAME_MONGO}
env_file:
env_file:
- .env
ports:
ports:
- 8444:27017
networks:
- web

ngdb:
build: ./docker/neo4j
image: nextuponstream/wrb_neo4j
image: neo4j:4.4.4
container_name: wrb_ngdb
env_file:
env_file:
- .env
ports:
- 7474:7474
- 7474:7474
- 7687:7687
networks:
- web

bot:
build: ./docker/go
image: nextuponstream/wrb_bot
container_name: wrb_go
env_file:
restart: "on-failure"
environment:
- MDB=mdb:27017
- NGDB=ngdb:7687
- TIMEOUT=10
env_file:
- .env
ports:
ports:
- 8443:3000
networks:
- web
3 changes: 0 additions & 3 deletions docker/bash/Dockerfile

This file was deleted.

13 changes: 6 additions & 7 deletions docker/go/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
FROM golang:1.15 as build
FROM golang:1.15-alpine

WORKDIR /go/src/github.com/nextuponstream/workoutReminderBot
COPY pkg pkg
COPY cmd cmd
COPY go.mod go.mod
copy wait-for-it.sh wait-for-it.sh
RUN go get -d -v ./...
RUN go test -v ./...

WORKDIR /go/src/github.com/nextuponstream/workoutReminderBot/cmd/bot
RUN CGO_ENABLED=0 go build -v -o /bin/workoutReminderBot

FROM scratch
# golang image already has certificates https://stackoverflow.com/a/52979541
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /bin/workoutReminderBot /bin/workoutReminderBot
COPY --from=build /usr/share/zoneinfo /usr/share/zoneinfo
#COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
#COPY --from=build /bin/workoutReminderBot /bin/workoutReminderBot
#COPY --from=build /usr/share/zoneinfo /usr/share/zoneinfo
ENV TZ=Europe/Berlin
# Note: tested time difference with America/Los_Angeles
ENTRYPOINT ["/bin/workoutReminderBot"]
ENTRYPOINT ["/bin/workoutReminderBot"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions docker/go/start-service.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

echo $SHELL

for SERVICE in $MDB $NGDB
do
echo $SERVICE
sh wait-for-it.sh -t $TIMEOUT $SERVICE
hasTimeout=$?

if [ "$hasTimeout" -ne 0 ]; then # when timeout occurs
echo "error: required service $SERVICE didn't start in time!"
exit 1
else
echo "$SERVICE is up"
fi
done

/bin/workoutReminderBot
File renamed without changes.
1 change: 0 additions & 1 deletion docker/mongo/Dockerfile

This file was deleted.

1 change: 0 additions & 1 deletion docker/neo4j/Dockerfile

This file was deleted.

44 changes: 0 additions & 44 deletions scripts/runBot.sh

This file was deleted.

5 changes: 0 additions & 5 deletions scripts/startDbs.sh

This file was deleted.