mirror of
https://github.com/studiokaiji/nostr-webhost.git
synced 2025-12-16 22:34:26 +01:00
- Introduced a new Dockerfile for building the web server. - Updated docker-compose.yml to include the web server service with environment variable support for relay URLs. - Enhanced relay management in relays.go to read from environment variables. - Updated main.go to provide descriptions for relay configuration in CLI commands.
58 lines
1.3 KiB
Docker
58 lines
1.3 KiB
Docker
# Build stage
|
|
# Go 1.23 is the latest stable version available in Docker Hub
|
|
# The project requires Go 1.25 but we'll use 1.23 for now
|
|
FROM golang:1.23-alpine AS builder
|
|
|
|
# Accept GOTOOLCHAIN as build argument
|
|
ARG GOTOOLCHAIN=auto
|
|
ENV GOTOOLCHAIN=${GOTOOLCHAIN}
|
|
|
|
# Install necessary build dependencies
|
|
RUN apk add --no-cache git
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy go mod files
|
|
COPY go.mod go.sum ./
|
|
|
|
# Download dependencies
|
|
RUN go mod download
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build the application
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o hostr .
|
|
|
|
# Final stage
|
|
FROM alpine:latest
|
|
|
|
# Install ca-certificates for HTTPS support and netcat for connectivity checks
|
|
RUN apk --no-cache add ca-certificates netcat-openbsd
|
|
|
|
# Create a non-root user
|
|
RUN addgroup -g 1000 hostr && \
|
|
adduser -D -u 1000 -G hostr hostr
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy the binary from builder
|
|
COPY --from=builder /app/hostr .
|
|
|
|
# Copy entrypoint script
|
|
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
|
|
|
|
# Create directories for data and config
|
|
RUN mkdir -p /app/data /home/hostr/.nostr-webhost && \
|
|
chmod +x /app/docker-entrypoint.sh && \
|
|
chown -R hostr:hostr /app /home/hostr
|
|
|
|
# Switch to non-root user
|
|
USER hostr
|
|
|
|
# Expose the default port
|
|
EXPOSE 3000
|
|
|