From 42e03a2ca74ea43bccb2b8d0b486a592fa143f28 Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Mon, 3 Nov 2025 04:37:25 +0000 Subject: [PATCH] update to build appropriately --- .devcontainer/devcontainer.json | 22 ++++++++++++++++++++++ Dockerfile | 22 ++++++++++++++-------- 2 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..23ff077 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,22 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/debian +{ + "name": "Debian", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/base:bullseye", + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": {} + } + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/Dockerfile b/Dockerfile index 706860f..6f837fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,25 +2,31 @@ FROM golang:alpine AS lib_builder WORKDIR /foundry -RUN apk add git make linux-headers cmake g++ +# install build deps (use build-base to get gcc/g++) +RUN apk add --no-cache git build-base linux-headers cmake RUN git clone https://github.com/jgarff/rpi_ws281x.git \ - && cd rpi_ws281x \ + && cd rpi_ws281x \ && mkdir build \ - && cd build \ + && cd build \ && cmake -D BUILD_SHARED=OFF -D BUILD_TEST=OFF .. \ - && cmake --build . \ - && make install + && cmake --build . --target install # Stage 1 : Build a go image with the rpi_ws281x C library and the go wrapper + FROM golang:alpine COPY --from=lib_builder /usr/local/lib/libws2811.a /usr/local/lib/ COPY --from=lib_builder /usr/local/include/ws2811 /usr/local/include/ws2811 -RUN apk add git make linux-headers cmake g++ + +# enable cgo and install build deps for the Go build +ENV CGO_ENABLED=1 +RUN apk add --no-cache git build-base linux-headers cmake + WORKDIR /go/src/github.com/rpi-ws281x/rpi-ws281x-go COPY . . -RUN GO111MODULE=off go get -d -v ./... -RUN GO111MODULE=off go build -v ./... +# Build in GOPATH mode (this repo has no go.mod). +ENV GO111MODULE=off +RUN go build -v ./... WORKDIR /go