Skip to content

Instantly share code, notes, and snippets.

@Dolu89
Last active October 25, 2021 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Dolu89/5d98cb929ef7d27c59bf01b14767cda2 to your computer and use it in GitHub Desktop.
Save Dolu89/5d98cb929ef7d27c59bf01b14767cda2 to your computer and use it in GitHub Desktop.
Nostr relay docker (WIP)
version: "3.8"
services:
relay:
build:
context: ./
dockerfile: Dockerfile
environment:
PORT: 2700
POSTGRESQL_DATABASE: postgres://nostr:nostr@postgres:5432/nostr?sslmode=disable
depends_on:
postgres:
condition: service_healthy
ports:
- 2700:2700
command: "./relay-full"
postgres:
image: postgres
restart: always
environment:
POSTGRES_DB: nostr
POSTGRES_USER: nostr
POSTGRES_PASSWORD: nostr
POSTGRES_HOST_AUTH_METHOD: trust # allow all connections without a password. This is *not* recommended for prod
ports:
- 5432:5432
healthcheck:
test: ["CMD-SHELL", "pg_isready -U nostr"] # database username here - nostr, should be changed if other user
interval: 10s
timeout: 5s
retries: 5
FROM golang:1.15.5
WORKDIR /go/src/app
COPY ./relay .
RUN go get -d -v ./...
RUN go install -v ./...
RUN go build -ldflags="-s -w" -tags full -o ./relay-full
@freeberty
Copy link

freeberty commented Oct 23, 2021

Hi , it makes sense to add postgres healthcheck, otherwise relay try to connect to not existing database when it loading.
https://gist.github.com/freeberty/db64c4a80330d6dda2d031d7b0a096ad

@Dolu89
Copy link
Author

Dolu89 commented Oct 25, 2021

Hi , it makes sense to add postgres healthcheck, otherwise relay try to connect to not existing database when it loading. https://gist.github.com/freeberty/db64c4a80330d6dda2d031d7b0a096ad

Thank you! I updated the gist with your modification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment