Files
tweetdistributor/Dockerfile
sirrow fd14c07ae0 expand a preview card for YouTube links
A message containing a YouTube link now carries a preview card. Discord
and X build their own card from the URL in the text, so the work is on
the bluesky side: the new preview.go asks YouTube's oEmbed endpoint for
the title, channel and thumbnail and posts them as an
app.bsky.embed.external.

Links are found by pulling candidates out of the text and parsing them
with net/url rather than by matching a URL shaped regexp, so a host like
youtube.com.example.invalid is not mistaken for the real thing.

Bluesky allows one embed per post, so a message with both attachments
and a link keeps the attachments. A failed oEmbed lookup only costs the
card, not the post.

Downloading the thumbnail wants the attachment download path, so it is
split into fetch and downloadImage, and both now go through a client
with a timeout: the event loop is single threaded and a hung request
would stall every later message.

The Dockerfile built main.go by name, which stops working now that
package main spans two files; it builds the package instead.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-26 12:00:22 +09:00

18 lines
538 B
Docker

FROM golang:1.26-alpine AS build-env
RUN apk --no-cache add git make build-base
RUN git clone --depth 1 https://git.sirrow.work/sirrow/tweetdistributor.git
WORKDIR tweetdistributor
RUN mkdir -p /build
RUN go mod tidy
RUN go build -a -tags "netgo" -tags timetzdata -installsuffix netgo -ldflags="-s -w -extldflags \"-static\"" -o=/build/tweetdistributor .
FROM alpine:3.22
RUN apk --no-cache add ca-certificates
COPY --from=build-env /build/tweetdistributor /tweetdistributor
RUN chmod u+x /tweetdistributor
CMD ["/tweetdistributor"]