-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* skeleton of embedr service, based on bskyweb * embedr container setup * builds on this branch * actual routes * fix embedr go:embed * tweak embedr dockerfile * progress on embedr * fix path params * tweaks to build process * try to get embedr dockerfile to install embed deps * build this branch * updates to match sam's output HTML * try to unbreak embedr dockerfile * small embedr tweak * docker hack * get embed.js copied over to embedr * don't x-frame-options for embed.bsky.app * bskyembed: remove a console.log * use html/template for golang snippet generation * simplify embedr API fetches * missing file * Rm console.log fully --------- Co-authored-by: Dan Abramov <[email protected]>
- Loading branch information
Showing
30 changed files
with
923 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: build-and-push-embedr-aws | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- bnewbold/embedr | ||
- bnewbold/embedr-rebase | ||
|
||
env: | ||
REGISTRY: ${{ secrets.AWS_ECR_REGISTRY_USEAST2_PACKAGES_REGISTRY }} | ||
USERNAME: ${{ secrets.AWS_ECR_REGISTRY_USEAST2_PACKAGES_USERNAME }} | ||
PASSWORD: ${{ secrets.AWS_ECR_REGISTRY_USEAST2_PACKAGES_PASSWORD }} | ||
IMAGE_NAME: embed | ||
|
||
jobs: | ||
embedr-container-aws: | ||
if: github.repository == 'bluesky-social/social-app' | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
id-token: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Docker buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Log into registry ${{ env.REGISTRY }} | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ env.USERNAME}} | ||
password: ${{ env.PASSWORD }} | ||
|
||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=sha,enable=true,priority=100,prefix=,suffix=,format=long | ||
- name: Build and push Docker image | ||
id: build-and-push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: ${{ github.event_name != 'pull_request' }} | ||
file: ./Dockerfile.embedr | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
FROM golang:1.21-bullseye AS build-env | ||
|
||
WORKDIR /usr/src/social-app | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Node | ||
ENV NODE_VERSION=18 | ||
ENV NVM_DIR=/usr/share/nvm | ||
|
||
# Go | ||
ENV GODEBUG="netdns=go" | ||
ENV GOOS="linux" | ||
ENV GOARCH="amd64" | ||
ENV CGO_ENABLED=1 | ||
ENV GOEXPERIMENT="loopvar" | ||
|
||
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 yarn && \ | ||
yarn && \ | ||
cd bskyembed && yarn install --frozen-lockfile && cd .. && \ | ||
yarn intl:build && \ | ||
yarn build-embed | ||
|
||
# DEBUG | ||
RUN find ./bskyweb/embedr-static && find ./bskyweb/embedr-templates && find ./bskyembed/dist | ||
|
||
# hack around issue with empty directory and go:embed | ||
RUN touch bskyweb/static/js/empty.txt | ||
|
||
# | ||
# Generate the embedr Go binary. | ||
# | ||
RUN cd bskyweb/ && \ | ||
go mod download && \ | ||
go mod verify | ||
|
||
RUN cd bskyweb/ && \ | ||
go build \ | ||
-v \ | ||
-trimpath \ | ||
-tags timetzdata \ | ||
-o /embedr \ | ||
./cmd/embedr | ||
|
||
FROM debian:bullseye-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=build-env /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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
## oEmbed | ||
|
||
<https://oembed.com/> | ||
|
||
* URL scheme: `https://bsky.app/profile/*/post/*` | ||
* API endpoint: `https://embed.bsky.app/oembed` | ||
|
||
Request params: | ||
|
||
- `url` (required): support both AT-URI and bsky.app URL | ||
- `maxwidth` (optional): [220..550], 325 is default | ||
- `maxheight` (not supported!) | ||
- `format` (optional): only `json` supported | ||
|
||
Response format: | ||
|
||
- `type` (required): "rich" | ||
- `version` (required): "1.0" | ||
- `author_name` (optional): display name | ||
- `author_url` (optional): profile URL | ||
- `provider_name` (optional): "Bluesky Social" | ||
- `provider_url` (optional): "https://bsky.app" | ||
- `cache_age` (optional, integer seconds): 86400 (24 hours) (?) | ||
- `width` (required): ? | ||
- `height` (required): ? | ||
|
||
Not used: | ||
|
||
- title (optional): A text title, describing the resource. | ||
- thumbnail_url (optional): A URL to a thumbnail image representing the resource. The thumbnail must respect any maxwidth and maxheight parameters. If this parameter is present, thumbnail_width and thumbnail_height must also be present. | ||
- thumbnail_width (optional): The width of the optional thumbnail. If this parameter is present, thumbnail_url and thumbnail_height must also be present. | ||
- thumbnail_height (optional): The height of the optional thumbnail. If this parameter is present, thumbnail_url and thumbnail_width must also be present. | ||
|
||
Only `json` is supported; `xml` is a 501. | ||
|
||
``` | ||
<link rel="alternate" type="application/json+oembed" href="https://embed.bsky.app/oembed?format=json&url=https://bsky.app/profile/bnewbold.net/post/abc123" /> | ||
``` | ||
|
||
|
||
## iframe URL | ||
|
||
`https://embed.bsky.app/embed/<did>/app.bsky.feed.post/<rkey>` | ||
`https://embed.bsky.app/static/embed.js` | ||
|
||
``` | ||
<blockquote class="bluesky-post" data-lang="en" data-align="center"> | ||
<p lang="en" dir="ltr">{{ post-text }}</p> | ||
— US Department of the Interior (@Interior) <a href="https://twitter.com/Interior/status/463440424141459456?ref_src=twsrc%5Etfw">May 5, 2014</a> | ||
</blockquote> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/bskyweb |
Oops, something went wrong.