Replace Makefile with brewkit, replace .env file with config in docker-compose, add instructions in README
This commit is contained in:
@@ -1,2 +0,0 @@
|
|||||||
TELEGRAM_BOT_TOKEN=test
|
|
||||||
OWNER_CHAT_ID=123
|
|
||||||
+3
-2
@@ -1,2 +1,3 @@
|
|||||||
.idea/
|
.idea
|
||||||
.env
|
vendor
|
||||||
|
docker-compose.override.yml
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
all: build
|
|
||||||
|
|
||||||
.PHONY: build
|
|
||||||
build: modules
|
|
||||||
CGO_ENABLED=0 go build -o ./bin/anon3anon ./cmd/anon3anon
|
|
||||||
|
|
||||||
.PHONY: modules
|
|
||||||
modules:
|
|
||||||
go mod tidy
|
|
||||||
@@ -1,3 +1,52 @@
|
|||||||
# anon3anon
|
# anon3anon
|
||||||
|
|
||||||
Telegram bot for anonymous messages 🎭✨
|
Telegram bot for anonymous messages 🎭✨
|
||||||
|
|
||||||
|
## Building for local development
|
||||||
|
|
||||||
|
Prerequisites:
|
||||||
|
|
||||||
|
1. git
|
||||||
|
2. docker
|
||||||
|
|
||||||
|
Firstly, clone the repository:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
git clone git@github.com:nightnoryu/anon3anon.git
|
||||||
|
```
|
||||||
|
|
||||||
|
Then build the binary:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./bin/a3abrewkit build
|
||||||
|
```
|
||||||
|
|
||||||
|
This script will download a [brewkit](https://github.com/ispringtech/brewkit) binary and put it in the `bin` directory of the project.
|
||||||
|
|
||||||
|
After that, copy the `docker-compose.override.example.yml` to `docker-compose.override.yml` and set the environment variables:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
anon3anon:
|
||||||
|
environment:
|
||||||
|
TELEGRAM_BOT_TOKEN: 123:ABC # The token for your bot, obtained from t.me/BotFather
|
||||||
|
OWNER_CHAT_ID: 123 # ID of your chat with your bot
|
||||||
|
```
|
||||||
|
|
||||||
|
And you're set! Lastly, run the app:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./bin/a3acompose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
While making changes to the app, don't forget to restart the container:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker restart anon3anon
|
||||||
|
```
|
||||||
|
|
||||||
|
When you're finished working on the project, bring it down using this command:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./bin/a3acompose down
|
||||||
|
```
|
||||||
|
|||||||
+2
-1
@@ -1 +1,2 @@
|
|||||||
anon3anon
|
/anon3anon
|
||||||
|
/brewkit
|
||||||
|
|||||||
Executable
+21
@@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
|
||||||
|
WORK_DIR=$(dirname "$(dirname "$(readlink -f "$0")")")
|
||||||
|
|
||||||
|
BREWKIT_VERSION="v1.0.0"
|
||||||
|
BREWKIT_URL="https://github.com/ispringtech/brewkit/releases/download/$BREWKIT_VERSION/brewkit_amd64"
|
||||||
|
BREWKIT_BINARY="bin/brewkit"
|
||||||
|
|
||||||
|
pushd "$WORK_DIR" >/dev/null
|
||||||
|
|
||||||
|
if [[ ! -f "$BREWKIT_BINARY" ]]; then
|
||||||
|
echo "installing brewkit..."
|
||||||
|
wget -q -O "$BREWKIT_BINARY" "$BREWKIT_URL"
|
||||||
|
chmod +x "$BREWKIT_BINARY"
|
||||||
|
fi
|
||||||
|
|
||||||
|
"$WORK_DIR/$BREWKIT_BINARY" "$@"
|
||||||
|
|
||||||
|
popd >/dev/null
|
||||||
Executable
+12
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
|
||||||
|
WORK_DIR=$(dirname "$(dirname "$(readlink -f "$0")")")
|
||||||
|
PROJECT_NAME=$(basename "$WORK_DIR")
|
||||||
|
|
||||||
|
pushd "$WORK_DIR" >/dev/null
|
||||||
|
|
||||||
|
docker-compose -p "$PROJECT_NAME" "$@"
|
||||||
|
|
||||||
|
popd >/dev/null
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
local project = import 'brewkit/project.libsonnet';
|
||||||
|
|
||||||
|
local appIDs = [
|
||||||
|
"anon3anon",
|
||||||
|
];
|
||||||
|
|
||||||
|
project.project(appIDs)
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
gobuilder: "golang:1.22.5"
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
local images = import 'images.libsonnet';
|
||||||
|
|
||||||
|
local cache = std.native('cache');
|
||||||
|
local copy = std.native('copy');
|
||||||
|
local copyFrom = std.native('copyFrom');
|
||||||
|
|
||||||
|
local gosources = [
|
||||||
|
"go.mod",
|
||||||
|
"go.sum",
|
||||||
|
"cmd",
|
||||||
|
"pkg",
|
||||||
|
];
|
||||||
|
|
||||||
|
local gocache = [
|
||||||
|
cache("go-build", "/app/cache"),
|
||||||
|
cache("go-mod", "/go/pkg/mod"),
|
||||||
|
];
|
||||||
|
|
||||||
|
{
|
||||||
|
project(appIDs):: {
|
||||||
|
apiVersion: "brewkit/v1",
|
||||||
|
|
||||||
|
targets: {
|
||||||
|
all: ["modules", "build"],
|
||||||
|
} + {
|
||||||
|
modules: ["gotidy", "modulesvendor"],
|
||||||
|
|
||||||
|
gotidy: {
|
||||||
|
from: "gobase",
|
||||||
|
workdir: "/app",
|
||||||
|
cache: gocache,
|
||||||
|
ssh: {},
|
||||||
|
command: "go mod tidy",
|
||||||
|
output: {
|
||||||
|
artifact: "/app/go.*",
|
||||||
|
"local": ".",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
modulesvendor: {
|
||||||
|
from: "gotidy",
|
||||||
|
workdir: "/app",
|
||||||
|
cache: gocache,
|
||||||
|
command: "go mod vendor",
|
||||||
|
output: {
|
||||||
|
artifact: "/app/vendor",
|
||||||
|
"local": "vendor",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
build: [appID for appID in appIDs],
|
||||||
|
} + {
|
||||||
|
[appID]: {
|
||||||
|
from: "gobase",
|
||||||
|
workdir: "/app",
|
||||||
|
cache: gocache,
|
||||||
|
dependsOn: ["modules"],
|
||||||
|
command: "go build -trimpath -v -o ./bin/" + appID + " ./cmd/" + appID,
|
||||||
|
output: {
|
||||||
|
artifact: "/app/bin/" + appID,
|
||||||
|
"local": "./bin"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for appID in appIDs
|
||||||
|
} + {
|
||||||
|
gobase: {
|
||||||
|
from: images.gobuilder,
|
||||||
|
workdir: "/app",
|
||||||
|
env: {
|
||||||
|
GOCACHE: "/app/cache/go-build",
|
||||||
|
CGO_ENABLED: "0"
|
||||||
|
},
|
||||||
|
copy: copyFrom('gosources', '/app', '/app')
|
||||||
|
},
|
||||||
|
|
||||||
|
gosources: {
|
||||||
|
from: "scratch",
|
||||||
|
workdir: "/app",
|
||||||
|
copy: [copy(source, source) for source in gosources]
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
services:
|
||||||
|
anon3anon:
|
||||||
|
environment:
|
||||||
|
TELEGRAM_BOT_TOKEN: 123:ABC
|
||||||
|
OWNER_CHAT_ID: 123
|
||||||
@@ -6,4 +6,3 @@ services:
|
|||||||
dockerfile: docker/Dockerfile-local
|
dockerfile: docker/Dockerfile-local
|
||||||
volumes:
|
volumes:
|
||||||
- "./bin:/app/bin"
|
- "./bin:/app/bin"
|
||||||
env_file: .env
|
|
||||||
|
|||||||
Reference in New Issue
Block a user