Files
bsky-social-app/Dockerfile.embedr
T
2026-08-19 17:32:31 +03:00

90 lines
1.9 KiB
Docker

#
# Stage 1: build the embed bundle with pnpm.
#
# Uses the official pnpm image. Node is auto-downloaded by pnpm using the
# `devEngines.runtime` field in package.json (onFail: "download").
#
FROM ghcr.io/pnpm/pnpm:11 AS web-build
WORKDIR /app/bskyembed
ENV DEBIAN_FRONTEND=noninteractive
#
# pnpm config
#
ENV CI=1
# use the pnpm version specified in package.json
ENV pnpm_config_pm_on_fail=download
COPY bskyembed ./
COPY bskyweb /app/bskyweb
COPY scripts/post-embed-build.js /app/scripts/post-embed-build.js
#
# Generate the embed bundle. NOTE: this will change
#
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
pnpm install --frozen-lockfile --ignore-scripts && \
pnpm build && \
pnpm build-snippet && \
node_modules/.bin/node ../scripts/post-embed-build.js
#
# Stage 2: build the embedr Go binary, embedding the assets from stage 1.
#
FROM golang:1.26-bookworm AS go-build
WORKDIR /usr/src/social-app
ENV GODEBUG="netdns=go"
ENV GOOS="linux"
ARG TARGETARCH
ENV GOARCH=${TARGETARCH:-amd64}
ENV CGO_ENABLED=1
ENV GOEXPERIMENT="loopvar"
COPY --from=web-build /app/bskyweb ./bskyweb
# hack around issue with empty directory and go:embed
RUN touch \
bskyweb/static/js/empty.txt \
bskyweb/static/css/empty.txt \
bskyweb/static/media/empty.txt
RUN cd bskyweb/ && \
go mod download && \
go mod verify
RUN cd bskyweb/ && \
go build \
-v \
-trimpath \
-tags timetzdata \
-o /embedr \
./cmd/embedr
#
# Stage 3: runtime image.
#
FROM debian:bookworm-slim
ENV GODEBUG=netdns=go
ENV TZ=Etc/UTC
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install --yes \
dumb-init \
ca-certificates
ENTRYPOINT ["dumb-init", "--"]
WORKDIR /embedr
COPY --from=go-build /embedr /usr/bin/embedr
CMD ["/usr/bin/embedr"]
LABEL org.opencontainers.image.source=https://github.com/bluesky-social/social-app
LABEL org.opencontainers.image.description="embed.bsky.app Web App"
LABEL org.opencontainers.image.licenses=MIT