Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions apps/bluesky-pds/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
FROM docker.io/library/alpine:3.21 AS pds-build

ARG VERSION=0.4.74

RUN apk add --no-cache \
bash \
ca-certificates \
curl \
git \
unzip \
nodejs \
npm

RUN npm install -g pnpm

# Download and extract the PDS archive
WORKDIR /app
RUN curl -fsSL -o pds.zip "https://github.com/bluesky-social/pds/archive/refs/tags/v${VERSION}.zip" && \
unzip pds.zip && \
mv pds-${VERSION}/service/** . && \
mv pds-${VERSION}/pdsadmin.sh . && \
rm -rf pds.zip pds-${VERSION}

RUN pnpm install --prod=true --frozen-lockfile

FROM docker.io/library/alpine:3.21

RUN apk add --no-cache \
catatonit \
ca-certificates \
curl \
gnupg \
jq \
openssl \
sqlite \
util-linux

WORKDIR /app
COPY --from=pds-build /app /app

EXPOSE 3000

ENV PUID=1000
ENV PGID=1000

ENV PDS_DATADIR="/pds"

RUN addgroup -g ${PGID} pds && \
adduser -h ${PDS_DATADIR} -u ${PUID} -G pds -D pds && \
mkdir -p ${PDS_DATADIR} && \
chown -R pds:pds ${PDS_DATADIR}

COPY apps/bluesky-pds/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/usr/bin/catatonit", "--", "/entrypoint.sh"]
7 changes: 7 additions & 0 deletions apps/bluesky-pds/ci/goss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/goss-org/goss/master/docs/schema.yaml
file:
/entrypoint.sh:
exists: true
/app/pdsadmin.sh:
exists: true
20 changes: 20 additions & 0 deletions apps/bluesky-pds/ci/latest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

# Fetch the tags from the GitHub repository and sort by commit date
TAGS=$(curl -sX GET "https://api.github.com/repos/bluesky-social/pds/tags" | jq -r '.[] | .name + " " + .commit.sha' | while read -r tag sha; do
echo "Tag: $tag, SHA: $sha"
date=$(curl -sX GET "https://api.github.com/repos/bluesky-social/pds/commits/${sha}" | jq -r '.commit.committer.date')
echo "$date $tag"
done | sort -r | awk '{print $2}')

# Filter tags to only include valid semantic versioning tags
SEMVER_TAGS=$(echo "${TAGS}" | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$')

# Get the latest semver tag
LATEST_TAG=$(echo "${SEMVER_TAGS}" | head -n 1)

# Optionally remove the 'v' prefix
LATEST_TAG_NO_V=$(echo "${LATEST_TAG}" | sed 's/^v//')

# Output the latest tag
printf "%s" "${LATEST_TAG_NO_V}"
53 changes: 53 additions & 0 deletions apps/bluesky-pds/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

# Set environment variables
export PDS_PORT=3000
export NODE_ENV=production
export UV_USE_IO_URING=0
export LOG_ENABLED="true"
export PDS_BLOB_UPLOAD_LIMIT="52428800"
export PDS_DATADIR="/pds"
export PDS_DATA_DIRECTORY="/pds"
export PDS_BLOBSTORE_DISK_LOCATION="${PDS_DATADIR}/blocks"
export PDS_DID_PLC_URL="https://plc.directory"
export PDS_BSKY_APP_VIEW_URL="https://api.bsky.app"
export PDS_BSKY_APP_VIEW_DID="did:web:api.bsky.app"
export PDS_REPORT_SERVICE_URL="https://mod.bsky.app"
export PDS_REPORT_SERVICE_DID="did:plc:ar7c4by46qjdydhdevvrndac"
export PDS_CRAWLERS="https://bsky.network"

# Ensure the data directory exists and has the correct permissions
mkdir -p "${PDS_DATADIR}"
chown -R pds:pds "${PDS_DATADIR}"

main() {
if [[ -z "${PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX}" ]]; then
echo "PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX not specified"
exit 1
fi

# create the config if it does not exist
if [[ ! -f ${CONFIG_FILE} ]]; then
echo "PDS_JWT_SECRET=${PDS_JWT_SECRET}" >${CONFIG_FILE}
echo "PDS_ADMIN_PASSWORD=${PDS_ADMIN_PASSWORD}" >>${CONFIG_FILE}
echo "PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX=${PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX}" >>${CONFIG_FILE}
echo "PDS_HOSTNAME=${PDS_HOSTNAME}" >>${CONFIG_FILE}
echo "PDS_CRAWLERS=https://bsky.network" >>${CONFIG_FILE}
fi

cat <<STARTED_MESSAGE
========================================================================
Bluesky PDS Started
------------------------------------------------------------------------

HOSTNAME: ${HOSTNAME}
PUBLIC_IP: ${PUBLIC_IP}
PDS_HOSTNAME: ${PDS_HOSTNAME}

========================================================================
STARTED_MESSAGE

node --enable-source-maps index.js
}

main
9 changes: 9 additions & 0 deletions apps/bluesky-pds/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
app: bluesky-pds
semver: true
channels:
- name: stable
platforms: ["linux/amd64", "linux/arm64"]
stable: true
tests:
enabled: false