mirror of
https://github.com/aljazceru/haven.git
synced 2025-12-18 14:24:18 +01:00
feat: Add Docker support and update README
This commit introduces Docker support to the project. It includes Dockerfile, docker-compose.yml, and docker-compose.tor.yml for running the application in a Docker container and setting up a Tor hidden service. It also updates the README to include instructions for using Docker. Additionally, it makes adjustments to .env.example and .gitignore files for better Docker compatibility.
This commit is contained in:
@@ -45,3 +45,7 @@ AWS_BUCKET_NAME="utxo-relay-backups"
|
||||
|
||||
## Blastr Settings
|
||||
BLASTR_RELAYS="relay.damus.io,nos.lol,relay.nostr.band,relay.snort.social,nostr.land,nostr.mom,relay.nos.social,relay.primal.net,relay.nostr.bg,no.str.cr,nostr21.com,nostrue.com,relay.siamstr.com,wot.utxo.one,nostrelites.org,wot.nostr.party,wot.sovbit.host,wot.girino.org,relay.lnau.net,wot.siamstr.com,wot.sudocarlos.com,relay.otherstuff.fyi,relay.lexingtonbitcoin.org,wot.azzamo.net,wot.swarmstr.com,zap.watch,satsage.xyz,wons.calva.dev"
|
||||
|
||||
## OPTIONAL: Docker UID and GID - should be the same as the user running the docker container
|
||||
DOCKER_UID=1000
|
||||
DOCKER_GID=1000
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1 @@
|
||||
.env
|
||||
db/
|
||||
haven
|
||||
37
Dockerfile
Normal file
37
Dockerfile
Normal file
@@ -0,0 +1,37 @@
|
||||
# Use Golang image based on Debian Bookworm
|
||||
FROM golang:bookworm
|
||||
|
||||
# Set the working directory within the container
|
||||
WORKDIR /app
|
||||
|
||||
# Copy go.mod and go.sum files
|
||||
COPY go.mod go.sum ./
|
||||
|
||||
# Download dependencies
|
||||
RUN go mod download
|
||||
|
||||
# Copy the rest of the application source code
|
||||
COPY . .
|
||||
|
||||
# Build the Go application
|
||||
RUN go build -o main .
|
||||
|
||||
# Add environment variables for UID and GID
|
||||
ARG DOCKER_UID=1000
|
||||
ARG DOCKER_GID=1000
|
||||
|
||||
# Create a new group and user
|
||||
RUN groupadd -g ${DOCKER_GID} appgroup && \
|
||||
useradd -u ${DOCKER_UID} -g appgroup -m appuser
|
||||
|
||||
# Change ownership of the working directory
|
||||
RUN chown -R appuser:appgroup /app
|
||||
|
||||
# Switch to the new user
|
||||
USER appuser
|
||||
|
||||
# Expose the port that the application will run on
|
||||
EXPOSE 3334
|
||||
|
||||
# Set the command to run the executable
|
||||
CMD ["./main"]
|
||||
50
README.md
50
README.md
@@ -170,6 +170,56 @@ Once everything is set up, the relay will be running on `localhost:3355` with th
|
||||
- `localhost:3355/chat`
|
||||
- `localhost:3355/inbox`
|
||||
|
||||
## Start the Project with Docker Compose
|
||||
|
||||
To start the project using Docker Compose, follow these steps:
|
||||
|
||||
1. Ensure Docker and Docker Compose are installed on your system.
|
||||
2. Navigate to the project directory.
|
||||
3. Ensure the `.env` file is present in the project directory and has the necessary environment variables set.
|
||||
4. You can also change the paths of the `db` folder and `haven` folder in the `docker-compose.yml` file.
|
||||
|
||||
```yaml
|
||||
volumes:
|
||||
- "./db:/app/db" # only change the left side before the colon
|
||||
- "./haven:/app/haven" # only change the left side before the colon
|
||||
```
|
||||
|
||||
5. Run the following command:
|
||||
|
||||
```sh
|
||||
# in foreground
|
||||
docker compose up --build
|
||||
# in background
|
||||
docker compose up --build -d
|
||||
```
|
||||
|
||||
6. For updating the relay, run the following command:
|
||||
|
||||
```sh
|
||||
git pull
|
||||
docker compose build --no-cache
|
||||
# in foreground
|
||||
docker compose up
|
||||
# in background
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
This will build the Docker image and start the `haven-relay` service as defined in the `docker-compose.yml` file. The application will be accessible on port 3335.
|
||||
|
||||
### Hidden Service with Tor and Docker (optional)
|
||||
|
||||
Same as the step 6, but with the following command:
|
||||
|
||||
```sh
|
||||
# in foreground
|
||||
docker compose -f docker-compose.tor.yml up --build
|
||||
# in background
|
||||
docker compose -f docker-compose.tor.yml up --build -d
|
||||
```
|
||||
|
||||
You can find the onion address here: `tor/data/haven/hostname`
|
||||
|
||||
## Cloud Backups
|
||||
|
||||
The relay automatically backs up your database to a cloud provider of your choice.
|
||||
|
||||
2
db/.gitignore
vendored
Normal file
2
db/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
25
docker-compose.tor.yml
Normal file
25
docker-compose.tor.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
services:
|
||||
relay:
|
||||
container_name: haven-relay
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- "./db:/app/db"
|
||||
- "./haven:/app/haven"
|
||||
ports:
|
||||
- "3335"
|
||||
user: "${DOCKER_UID:-1000}:${DOCKER_GID:-1000}"
|
||||
|
||||
tor:
|
||||
image: lncm/tor:0.4.7.9@sha256:86c2fe9d9099e6376798979110b8b9a3ee5d8adec27289ac4a5ee892514ffe92
|
||||
container_name: haven-tor
|
||||
depends_on:
|
||||
- relay
|
||||
volumes:
|
||||
- ./tor/torrc:/etc/tor/torrc
|
||||
- ./tor/data:/var/lib/tor
|
||||
restart: on-failure
|
||||
stop_grace_period: 10m30s
|
||||
14
docker-compose.yml
Normal file
14
docker-compose.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
services:
|
||||
relay:
|
||||
container_name: haven-relay
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- "./db:/app/db"
|
||||
- "./haven:/app/haven"
|
||||
ports:
|
||||
- "3335:3335"
|
||||
user: "${DOCKER_UID:-1000}:${DOCKER_GID:-1000}"
|
||||
2
haven/.gitignore
vendored
Normal file
2
haven/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
2
tor/data/.gitignore
vendored
Normal file
2
tor/data/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
Reference in New Issue
Block a user