Repository navigation
Expand file tree
/
Copy pathDockerfile.dev
More file actions
80 lines (64 loc) · 2.38 KB
/
Copy pathDockerfile.dev
File metadata and controls
80 lines (64 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Development/Debug Dockerfile for guppy
# Build: docker build -f Dockerfile.dev -t guppy:dev .
# Run: docker run -p 2345:2345 guppy:dev [args...]
# Connect debugger to localhost:2345
FROM --platform=$BUILDPLATFORM golang:1.25-bookworm AS build
ARG TARGETARCH
ARG TARGETOS=linux
ARG VERSION=dev
ARG COMMIT=unknown
ARG DATE=unknown
ARG BUILT_BY=docker-dev
WORKDIR /src
# Install delve debugger and randdir tool for the target architecture.
# When cross-compiling, `go install` drops binaries under
# $GOPATH/bin/${GOOS}_${GOARCH}/; when native, under $GOPATH/bin/.
# Normalize both cases by copying into a stable /tools path.
RUN GOARCH=${TARGETARCH} go install github.com/go-delve/delve/cmd/dlv@latest && \
GOARCH=${TARGETARCH} go install github.com/storacha/randdir@latest && \
mkdir -p /tools && \
find /go/bin -maxdepth 2 -type f -name dlv -exec cp {} /tools/dlv \; && \
find /go/bin -maxdepth 2 -type f -name randdir -exec cp {} /tools/randdir \;
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Debug build — no optimizations, no inlining, full symbols
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build \
-gcflags="all=-N -l" \
-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=${BUILT_BY}" \
-o /app .
FROM debian:bookworm-slim AS dev
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
# Shell experience
bash-completion \
less \
vim-tiny \
# Process debugging
procps \
htop \
strace \
# Network debugging
iputils-ping \
dnsutils \
net-tools \
tcpdump \
# Data tools
jq \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build /app /usr/bin/guppy
COPY --from=build /tools/dlv /usr/bin/dlv
COPY --from=build /tools/randdir /usr/bin/randdir
# Create data directories
RUN mkdir -p /root/.storacha/guppy /root/.config/guppy
WORKDIR /root
ENV TERM=xterm-256color
RUN echo 'alias ll="ls -la"' >> /etc/bash.bashrc && \
echo 'PS1="\[\e[32m\][guppy-dev]\[\e[m\] \w# "' >> /etc/bash.bashrc
SHELL ["/bin/bash", "-c"]
EXPOSE 2345
ENTRYPOINT ["dlv", "exec", "/usr/bin/guppy", "--headless", "--listen=:2345", "--api-version=2", "--accept-multiclient", "--"]