diff --git a/.env.example b/.env.example index 5aa8a8a..8b0207c 100644 --- a/.env.example +++ b/.env.example @@ -3,7 +3,6 @@ RELAY_URL="relay.utxo.one" RELAY_PORT=3355 RELAY_BIND_ADDRESS="0.0.0.0" # Can be set to a specific IP4 or IP6 address ("" for all interfaces) DB_ENGINE="badger" # badger, lmdb (lmdb works best with an nvme, otherwise you might have stability issues) -BLOSSOM_PATH="blossom/" ## Private Relay Settings PRIVATE_RELAY_NAME="utxo's private relay" @@ -77,7 +76,6 @@ INBOX_RELAY_CONNECTION_RATE_LIMITER_MAX_TOKENS=9 ## Import Settings IMPORT_START_DATE="2023-01-20" IMPORT_QUERY_INTERVAL_SECONDS=600 -IMPORT_SEED_RELAYS_FILE="relays_import.json" ## Backup Settings BACKUP_PROVIDER="none" # aws, gcp, none (or leave blank to disable) @@ -91,6 +89,3 @@ AWS_BUCKET_NAME="backups" ## GCP Backup Settings - REQUIRED IF BACKUP_PROVIDER="gcp" GCP_BUCKET_NAME="backups" - -## Blastr Settings -BLASTR_RELAYS_FILE="relays_blastr.json" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index f2910fe..9e7deb9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,33 @@ -# Use Golang image based on Debian Bookworm -FROM golang:bookworm +# Use Debian-based Golang image for building +FROM golang:bookworm AS builder + +# Install git and set working directory +RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/* -# Set the working directory within the container WORKDIR /app +# Setup cache directories +RUN go env -w GOCACHE=/go-cache +RUN go env -w GOMODCACHE=/gomod-cache + +# Clone the repository and build app ARG REPO_URL=https://github.com/bitvora/haven.git ARG VERSION +RUN git clone --branch ${VERSION} --single-branch ${REPO_URL} . +RUN --mount=type=cache,target=/gomod-cache --mount=type=cache,target=/go-cache \ + go build -ldflags="-w -s" -o main . -# Clone the repository -RUN git clone --branch ${VERSION} ${REPO_URL} . - -# Download dependencies -ENV GOPROXY=https://proxy.golang.org -RUN go mod download - -# Build the Go application -RUN go build -o main . +# Final Distroless image +FROM gcr.io/distroless/base -# Add environment variables for UID and GID -ARG DOCKER_UID=1000 -ARG DOCKER_GID=1000 +# Add non-root user specification +USER nonroot -# 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 +WORKDIR /app -# Switch to the new user -USER appuser +# Copy Go application +COPY --from=builder /app/main . -# Expose the port that the application will run on +# Expose port and set command EXPOSE 3355 - -# Set the command to run the executable CMD ["./main"] diff --git a/blossom/.gitignore b/blossom/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/blossom/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/docker-compose.tor.yml b/docker-compose.tor.yml index ec13934..02a2493 100644 --- a/docker-compose.tor.yml +++ b/docker-compose.tor.yml @@ -1,20 +1,17 @@ services: relay: container_name: haven-relay - build: - context: . - dockerfile: Dockerfile - args: - VERSION: v1.0.0 + image: holgerhatgarkeinenode/haven-docker:v1.0.0 env_file: - .env volumes: - "./db:/app/db" - "./templates:/app/templates" + - "./blossom:/app/blossom" - "./relays_import.json:/app/relays_import.json" - "./relays_blastr.json:/app/relays_blastr.json" ports: - - "3355:3355" + - "3355:${RELAY_PORT:-3355}" user: "${DOCKER_UID:-1000}:${DOCKER_GID:-1000}" restart: unless-stopped diff --git a/docker-compose.yml b/docker-compose.yml index 298a694..52918b7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,19 +1,16 @@ services: relay: container_name: haven-relay - build: - context: . - dockerfile: Dockerfile - args: - VERSION: v1.0.0 + image: holgerhatgarkeinenode/haven-docker:v1.0.0 env_file: - .env volumes: - "./db:/app/db" - "./templates:/app/templates" + - "./blossom:/app/blossom" - "./relays_import.json:/app/relays_import.json" - "./relays_blastr.json:/app/relays_blastr.json" ports: - - "3355:3355" + - "3355:${RELAY_PORT:-3355}" user: "${DOCKER_UID:-1000}:${DOCKER_GID:-1000}" restart: unless-stopped