mirror of
https://github.com/bitvora/wot-relay.git
synced 2025-05-25 03:22:02 +00:00
feat: update Dockerfile, docker-compose and README for better Docker usage
This commit updates the Dockerfile to use a more docker-friendly approach. Instead of cloning the repository inside the Dockerfile, it now copies the files from the host. It also sets some fixed environment variables and uses a .env file for the rest. The docker-compose.yml file now uses an .env file for more convenient environment variable management. It also maps volumes to the host, allowing you to change the paths of the `db` folder and `templates` folder. The README.md has been updated with new instructions reflecting these changes. It now includes instructions for running the Docker container in the foreground or background, and for updating the relay.
This commit is contained in:
parent
060fd68c85
commit
ca8dde54f1
@ -4,3 +4,4 @@ RELAY_DESCRIPTION="Only notes in utxo WoT"
|
|||||||
RELAY_URL="wss://wot.utxo.one"
|
RELAY_URL="wss://wot.utxo.one"
|
||||||
DB_PATH="db"
|
DB_PATH="db"
|
||||||
INDEX_PATH="templates/index.html"
|
INDEX_PATH="templates/index.html"
|
||||||
|
STATIC_PATH="templates/static"
|
||||||
|
22
Dockerfile
22
Dockerfile
@ -4,18 +4,22 @@ FROM golang:bookworm
|
|||||||
# Set the working directory within the container
|
# Set the working directory within the container
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Clone the repository
|
# Copy go.mod and go.sum files
|
||||||
RUN git clone https://github.com/bitvora/wot-relay .
|
COPY go.mod go.sum ./
|
||||||
|
|
||||||
# Download Go module dependencies
|
# Download dependencies
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
# Write the .env file
|
# Copy the rest of the application source code
|
||||||
RUN touch .env && \
|
COPY . .
|
||||||
echo "RELAY_NAME=${RELAY_NAME}" >> .env && \
|
|
||||||
echo "RELAY_PUBKEY=${RELAY_PUBKEY}" >> .env && \
|
# Set fixed environment variables
|
||||||
echo "RELAY_DESCRIPTION=${RELAY_DESCRIPTION}" >> .env && \
|
ENV DB_PATH="db"
|
||||||
echo "DB_PATH=${DB_PATH}" >> .env
|
ENV INDEX_PATH="templates/index.html"
|
||||||
|
ENV STATIC_PATH="templates/static"
|
||||||
|
|
||||||
|
# touch a .env (https://github.com/bitvora/wot-relay/pull/4)
|
||||||
|
RUN touch .env
|
||||||
|
|
||||||
# Build the Go application
|
# Build the Go application
|
||||||
RUN go build -o main .
|
RUN go build -o main .
|
||||||
|
30
README.md
30
README.md
@ -97,25 +97,37 @@ To start the project using Docker Compose, follow these steps:
|
|||||||
|
|
||||||
1. Ensure Docker and Docker Compose are installed on your system.
|
1. Ensure Docker and Docker Compose are installed on your system.
|
||||||
2. Navigate to the project directory.
|
2. Navigate to the project directory.
|
||||||
3. Edit the `docker-compose.yml` file to update the environment variables as needed:
|
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 `templates` folder in the `docker-compose.yml` file.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
environment:
|
volumes:
|
||||||
RELAY_NAME: "utxo WoT relay"
|
- "./db:/app/db" # only change the left side before the colon
|
||||||
RELAY_PUBKEY: "YOURPUBKEY"
|
- "./templates/index.html:/app/templates/index.html" # only change the left side before the colon
|
||||||
RELAY_DESCRIPTION: "Only notes in utxo WoT"
|
- "./templates/static:/app/templates/static" # only change the left side before the colon
|
||||||
DB_PATH: "./db"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Run the following command:
|
5. Run the following command:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker-compose up --build
|
# 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 `wot-relay` service as defined in the `docker-compose.yml` file. The application will be accessible on port 3334.
|
This will build the Docker image and start the `wot-relay` service as defined in the `docker-compose.yml` file. The application will be accessible on port 3334.
|
||||||
|
|
||||||
|
|
||||||
### 7. Access the relay
|
### 7. Access the relay
|
||||||
|
|
||||||
Once everything is set up, the relay will be running on `localhost:3334`.
|
Once everything is set up, the relay will be running on `localhost:3334`.
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
services:
|
services:
|
||||||
wot-relay:
|
wot-relay:
|
||||||
|
container_name: wot-relay
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
environment:
|
env_file:
|
||||||
RELAY_NAME: "utxo WoT relay"
|
- .env
|
||||||
RELAY_PUBKEY: "e2ccf7cf20403f3f2a4a55b328f0de3be38558a7d5f33632fdaaefc726c1c8eb"
|
|
||||||
RELAY_DESCRIPTION: "Only notes in utxo WoT"
|
|
||||||
DB_PATH: "./db"
|
|
||||||
volumes:
|
volumes:
|
||||||
- "./db:/app/db"
|
- "./db:/app/db" # only change the left side before the colon
|
||||||
|
- "./templates/index.html:/app/templates/index.html" # only change the left side before the colon
|
||||||
|
- "./templates/static:/app/templates/static" # only change the left side before the colon
|
||||||
ports:
|
ports:
|
||||||
- "3334:3334"
|
- "3334:3334"
|
Loading…
x
Reference in New Issue
Block a user