Files
next.orly.dev/cmd/benchmark/Dockerfile.next-orly
mleku 202d3171f9 Implement multi-platform build system with pure Go support
- Introduced a comprehensive build system that supports multiple platforms (Linux, macOS, Windows, Android) using pure Go builds (`CGO_ENABLED=0`).
- Updated all build and test scripts to ensure compatibility with the new purego approach, allowing for dynamic loading of `libsecp256k1` at runtime.
- Added detailed documentation on the build process, platform detection, and deployment options.
- Enhanced CI/CD workflows to automate builds for all supported platforms and include necessary libraries in releases.
- Updated `.gitignore` to exclude build output files.
- Created new documentation files for deployment and multi-platform build summaries.
2025-11-04 20:29:19 +00:00

99 lines
2.8 KiB
Docker

# Dockerfile for next.orly.dev relay
FROM ubuntu:22.04 as builder
# Set environment variables
ARG GOLANG_VERSION=1.22.5
# Update package list and install dependencies
RUN apt-get update && \
apt-get install -y wget ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Download Go binary
RUN wget https://go.dev/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz && \
rm -rf /usr/local/go && \
tar -C /usr/local -xzf go${GOLANG_VERSION}.linux-amd64.tar.gz && \
rm go${GOLANG_VERSION}.linux-amd64.tar.gz
# Set PATH environment variable
ENV PATH="/usr/local/go/bin:${PATH}"
# Verify installation
RUN go version
RUN apt update && \
apt -y install build-essential autoconf libtool git wget
RUN cd /tmp && \
rm -rf secp256k1 && \
git clone https://github.com/bitcoin-core/secp256k1.git && \
cd secp256k1 && \
git checkout v0.6.0 && \
git submodule init && \
git submodule update && \
./autogen.sh && \
./configure --enable-module-schnorrsig --enable-module-ecdh --prefix=/usr && \
make -j1 && \
make install
# Set working directory
WORKDIR /build
# Copy go modules
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the relay
RUN CGO_ENABLED=1 GOOS=linux go build -gcflags "all=-N -l" -o relay .
# Copy libsecp256k1.so if it exists in the repo
RUN if [ -f pkg/crypto/p8k/libsecp256k1.so ]; then \
cp pkg/crypto/p8k/libsecp256k1.so /build/; \
fi
# Create non-root user (uid 1000) for runtime in builder stage (used by analyzer)
RUN useradd -u 1000 -m -s /bin/bash appuser && \
chown -R 1000:1000 /build
# Switch to uid 1000 for any subsequent runtime use of this stage
USER 1000:1000
# Final stage
FROM ubuntu:22.04
# Install runtime dependencies
RUN apt-get update && apt-get install -y ca-certificates curl libsecp256k1-0 libsecp256k1-dev && rm -rf /var/lib/apt/lists/* && \
ln -sf /usr/lib/x86_64-linux-gnu/libsecp256k1.so.0 /usr/lib/x86_64-linux-gnu/libsecp256k1.so.5
WORKDIR /app
# Copy binary from builder
COPY --from=builder /build/relay /app/relay
# Copy libsecp256k1.so if it was built with the binary
COPY --from=builder /build/libsecp256k1.so /app/libsecp256k1.so 2>/dev/null || true
# Create runtime user and writable directories
RUN useradd -u 1000 -m -s /bin/bash appuser && \
mkdir -p /data /profiles /app && \
chown -R 1000:1000 /data /profiles /app
# Expose port
EXPOSE 8080
# Set environment variables
ENV ORLY_DATA_DIR=/data
ENV ORLY_LISTEN=0.0.0.0
ENV ORLY_PORT=8080
ENV ORLY_LOG_LEVEL=off
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD bash -lc "code=\$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:8080 || echo 000); echo \$code | grep -E '^(101|200|400|404|426)$' >/dev/null || exit 1"
# Drop privileges: run as uid 1000
USER 1000:1000
# Run the relay
CMD ["/app/relay"]