Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ guppy
# Environment Files
.env*

# Config Files
*.yaml
*.toml

# IDE's
*.idea/

Expand Down
52 changes: 41 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ============================================
# Build stage (shared)
# Build base stage
# ============================================
FROM golang:1.25.3-trixie AS build
FROM golang:1.26.1-trixie AS build-base

# Docker sets TARGETARCH automatically during multi-platform builds
ARG TARGETARCH
Expand All @@ -10,25 +10,39 @@ WORKDIR /go/src/guppy

COPY go.* .
RUN go mod download
COPY . .
COPY --parents cmd internal pkg Makefile main.go version.json ./

# ============================================
# Production build stage
# ============================================
FROM build-base AS build-prod

# Allow the Makefile to look up the git commit, at the expense of busting the
# cache whenever `.git` changes.
COPY --parents .git ./

# Production build - with symbol stripping
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} make guppy-prod
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} make guppy-prod

# ============================================
# Debug build stage
# ============================================
FROM build AS build-debug
FROM build-base AS build-debug

# Debug build - no optimizations, no inlining
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} make guppy-debug

# ============================================
# Debug tools
# ============================================
FROM golang:1.26.1-trixie AS build-debug-tools

ARG TARGETARCH

# Install delve debugger and randdir tool for target architecture
RUN GOARCH=${TARGETARCH} go install github.com/go-delve/delve/cmd/dlv@latest && \
GOARCH=${TARGETARCH} go install github.com/storacha/randdir@latest

# Debug build - no optimizations, no inlining
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} make guppy-debug

# ============================================
# Production image
# ============================================
Expand All @@ -39,7 +53,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*

COPY --from=build /go/src/guppy/guppy /usr/bin/guppy
COPY --from=build-prod /go/src/guppy/guppy /usr/bin/guppy

ENTRYPOINT ["/usr/bin/guppy"]

Expand Down Expand Up @@ -69,8 +83,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

# Delve debugger and randdir tool
COPY --from=build-debug /go/bin/dlv /usr/bin/dlv
COPY --from=build-debug /go/bin/randdir /usr/bin/randdir
COPY --from=build-debug-tools /go/bin/dlv /usr/bin/dlv
COPY --from=build-debug-tools /go/bin/randdir /usr/bin/randdir

# Debug binary (with symbols, no optimizations)
COPY --from=build-debug /go/src/guppy/guppy /usr/bin/guppy
Expand All @@ -87,3 +101,19 @@ RUN echo 'alias ll="ls -la"' >> /etc/bash.bashrc && \

SHELL ["/bin/bash", "-c"]
ENTRYPOINT ["/usr/bin/guppy"]

# ============================================
# Test image (without interactive tools)
# ============================================
FROM debian:bookworm-slim AS test

# Debug binary (with symbols, no optimizations)
COPY --from=build-debug /go/src/guppy/guppy /usr/bin/guppy

# Create data directories
RUN mkdir -p /root/.storacha/guppy /root/.config/guppy

WORKDIR /root

SHELL ["/bin/bash", "-c"]
ENTRYPOINT ["/usr/bin/guppy"]
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ DB_PATH ?= ~/.storacha/guppy/preparation.db
GOOSE := go tool goose

VERSION=$(shell awk -F'"' '/"version":/ {print $$4}' version.json)
COMMIT=$(shell git rev-parse --short HEAD)
COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE=$(shell date -u -Iseconds)
GOFLAGS=-ldflags="-X github.com/storacha/guppy/pkg/build.version=$(VERSION) -X github.com/storacha/guppy/pkg/build.Commit=$(COMMIT) -X github.com/storacha/guppy/pkg/build.Date=$(DATE) -X github.com/storacha/guppy/pkg/build.BuiltBy=make"
DOCKER?=$(shell which docker)
Expand Down Expand Up @@ -59,3 +59,7 @@ docker-prod: docker-setup

docker-dev: docker-setup
$(DOCKER) buildx build --platform linux/amd64,linux/arm64 --target dev -t guppy:dev .

test-upload:
@echo "Running upload test..."
./test/doupload
3 changes: 2 additions & 1 deletion test/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
doupload-dir
baduploads-dir
ipfs
mprocs.log
mprocs.log
smelt
14 changes: 14 additions & 0 deletions test/compose.smelt-override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file overrides the Smelt Compose configuration. Paths are relative to
# that file, not this one.

services:
upload:
environment:
- SPRUE_LOG_LEVEL=debug
volumes:
- ../upload-config:/etc/sprue:ro

networks:
storacha-network:
# Use an isolated network, not the normal Smelt network.
external: false
44 changes: 44 additions & 0 deletions test/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: guppy-test

include:
- path:
- ./smelt/compose.yml
- ./compose.smelt-override.yml

services:
guppy-doupload:
extends:
service: guppy
file: ./smelt/systems/guppy/compose.yml
build:
context: ..
dockerfile: Dockerfile
target: dev
image: guppy:dev
environment:
- IN_CONTAINER=true
entrypoint: ["/usr/local/bin/doupload"]
volumes:
- ./doupload:/usr/local/bin/doupload
depends_on:
email-clicker:
condition: service_started
piri-0:
condition: service_healthy
piri-1:
condition: service_healthy
piri-2:
condition: service_healthy

email-clicker:
image: docker:cli
environment:
- COMPOSE_PROJECT=guppy-test
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./email-clicker/click.sh:/usr/local/bin/click.sh:ro
entrypoint: ["/bin/sh", "/usr/local/bin/click.sh"]
depends_on:
- upload
networks:
- storacha-network
Loading
Loading