docker release and test workflow

This commit is contained in:
github-tijlxyz 2024-02-23 15:20:17 +01:00
parent b6ebdb9e5b
commit 7e6a3f00cb
No known key found for this signature in database
GPG Key ID: 2EB6AC84AFE26CD6
6 changed files with 78 additions and 4 deletions

7
.dockerignore Normal file
View File

@ -0,0 +1,7 @@
README.md
LICENSE
.git/
db/
users.json
khatru-invite

22
.github/workflows/go.yml vendored Normal file
View File

@ -0,0 +1,22 @@
name: Test Build
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Build
run: go build -v ./...

View File

@ -8,7 +8,9 @@ permissions:
contents: write
jobs:
releases-matrix:
name: Build and release binary
runs-on: ubuntu-latest
strategy:
matrix:
@ -28,3 +30,32 @@ jobs:
md5sum: false
sha256sum: false
compress_assets: false
release-docker:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: tijlxyz/khatru-pyramid
- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

11
Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM golang:1.21 AS builder
WORKDIR /app
COPY . .
RUN go build -o khatru-invite .
FROM ubuntu:latest
COPY --from=builder /app/khatru-invite /app/
ENV DATABASE_PATH="/app/db"
ENV USERDATA_PATH="/app/users.json"
CMD ["/app/khatru-invite"]

View File

@ -2,6 +2,8 @@
A relay based on [Khatru](https://github.com/fiatjaf/khatru) with a invite hierarchy feature.
some notes before running:
1. configure the relay settings in `.env`
2. manually add someone to the `users.json` file, like this: `{"07adfda9c5adc80881bb2a5220f6e3181e0c043b90fa115c4f183464022968e6":""}`
### Deploy with docker
1. create and manually add a pubkey to users.json: `touch users.json && echo '{"your nostr hex pubkey":""}' > users.json`
2. deploy with docker: `docker run -p 3334:3334 -v ./users.json:/app/users.json -v ./db:/app/db -e DOMAIN=yourdomain.example.com -e RELAY_NAME="your relay name" -e RELAY_PUBKEY="your nostr hex pubkey" tijlxyz/khatru-pyramid:latest`

View File

@ -28,7 +28,7 @@ type Settings struct {
RelayContact string `envconfig:"RELAY_CONTACT"`
RelayIcon string `envconfig:"RELAY_ICON"`
DatabasePath string `envconfig:"DATABASE_PATH" default:"./db"`
UserdataPath string `envconfig:"USERDATA_PATH" default:"./users.json"`
UserdataPath string `envconfig:"USERDATA_PATH" default:"./users.json"`
MaxInvitesPerPerson int `envconfig:"MAX_INVITES_PER_PERSON" default:"3"`
}
@ -42,6 +42,7 @@ var (
)
func main() {
err := envconfig.Process("", &s)
if err != nil {
log.Fatal().Err(err).Msg("couldn't process envconfig")