Skip to content

Commit

Permalink
Merge pull request #13 from Terisback/master
Browse files Browse the repository at this point in the history
Docker build file and CD workflow
  • Loading branch information
JackBekket authored Oct 21, 2022
2 parents 49b6d54 + 655f81d commit 841bd04
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
*.secret
*.env

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
45 changes: 45 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build and push

on:
push:
branches:
- 'master'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
-
name: Build and push
uses: docker/build-push-action@v3
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM golang:1.17-alpine AS build_base

RUN apk add --no-cache alpine-sdk

# Set the Current Working Directory inside the container
WORKDIR /app

# We want to populate the module cache based on the go.{mod,sum} files.
COPY go.mod .
COPY go.sum .

RUN go mod download

COPY . .

RUN go build -o /out/bot .

FROM alpine:latest

WORKDIR /app

RUN apk add ca-certificates
COPY --from=build_base /out/bot ./bot

EXPOSE 8080
CMD ["/app/bot"]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ Blockchain part is generated from IKY repo, see it for more details about contra
3. User go to webapp page, make transaction, submitting it's tgid
4. Bot get event about it from blockchain
5. Bot verifies registration

## Deploy with Docker

1. Copy `.envExample` into `.env` and fill it with your values
2. Run with `docker-compose up -d`
3. Done
11 changes: 11 additions & 0 deletions docker-compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3.9"

services:
bot:
container_name: verifier-bot
image: verifier-bot
build:
dockerfile: Dockerfile
restart: always
volumes:
- ".env:/app/.env"
16 changes: 16 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3.9"

services:
bot:
container_name: verifier-bot
image: ghcr.io/0xsolidarnost/verifier-bot:master
restart: always
volumes:
- ".env:/app/.env"

watchtower:
image: containrrr/watchtower
command: --interval 300 --include-stopped --include-restarting --cleanup
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ~/.docker/config.json:/config.json

0 comments on commit 841bd04

Please sign in to comment.