set devEngines in bskyembed

This commit is contained in:
Samuel Newman
2026-05-28 18:30:50 +03:00
parent e41a6f3425
commit 50f5b1fd45
3 changed files with 383 additions and 33 deletions
+43 -33
View File
@@ -1,14 +1,45 @@
FROM golang:1.26-bookworm AS build-env
#
# 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 /usr/src/social-app
WORKDIR /app
ENV DEBIAN_FRONTEND=noninteractive
# Node
ENV NODE_VERSION=24.15.0
ENV NVM_DIR=/usr/share/nvm
#
# pnpm config
#
ENV CI=1
# use the pnpm version specified in package.json
ENV pnpm_config_pm_on_fail=download
COPY . .
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
# bskyembed is a separate (non-workspace) pnpm project, so install its deps too.
RUN --mount=type=cache,id=pnpm,target=/pnpm/store cd bskyembed && pnpm install --frozen-lockfile
RUN pnpm intl:build
RUN pnpm build-embed
#
# Stage 2: build the embedr Go binary, embedding the assets from stage 1.
#
# post-embed-build.js (run by `pnpm build-embed` above) writes the bundled
# assets/templates into bskyweb/embedr-static and bskyweb/embedr-templates,
# so copying the bskyweb/ tree from stage 1 is enough for go:embed to find
# everything.
#
FROM golang:1.26-bookworm AS go-build
WORKDIR /usr/src/social-app
# Go
ENV GODEBUG="netdns=go"
ENV GOOS="linux"
ARG TARGETARCH
@@ -16,40 +47,16 @@ ENV GOARCH=${TARGETARCH:-amd64}
ENV CGO_ENABLED=1
ENV GOEXPERIMENT="loopvar"
# CI environment for pnpm
ENV CI=true
COPY . .
#
# Generate the JavaScript webpack. NOTE: this will change
#
RUN mkdir --parents $NVM_DIR && \
wget \
--output-document=/tmp/nvm-install.sh \
https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh && \
bash /tmp/nvm-install.sh
RUN \. "$NVM_DIR/nvm.sh" && \
nvm install $NODE_VERSION && \
nvm use $NODE_VERSION && \
npm install --global pnpm@11.1.3 && \
pnpm install --frozen-lockfile && \
cd bskyembed && pnpm install --frozen-lockfile && cd .. && \
pnpm intl:build && \
pnpm build-embed
COPY --from=web-build /app/bskyweb ./bskyweb
# DEBUG
RUN find ./bskyweb/embedr-static && find ./bskyweb/embedr-templates && find ./bskyembed/dist
RUN find ./bskyweb/embedr-static && find ./bskyweb/embedr-templates
# hack around issue with empty directory and go:embed
RUN touch bskyweb/static/js/empty.txt
RUN touch bskyweb/static/css/empty.txt
RUN touch bskyweb/static/media/empty.txt
#
# Generate the embedr Go binary.
#
RUN cd bskyweb/ && \
go mod download && \
go mod verify
@@ -62,6 +69,9 @@ RUN cd bskyweb/ && \
-o /embedr \
./cmd/embedr
#
# Stage 3: runtime image.
#
FROM debian:bookworm-slim
ENV GODEBUG=netdns=go
@@ -75,7 +85,7 @@ RUN apt-get update && apt-get install --yes \
ENTRYPOINT ["dumb-init", "--"]
WORKDIR /embedr
COPY --from=build-env /embedr /usr/bin/embedr
COPY --from=go-build /embedr /usr/bin/embedr
CMD ["/usr/bin/embedr"]