Skip to content
Closed
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
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Keep the Docker build context minimal. _site/ is the only thing the image
# actually needs (it's built on the CI runner before `docker build`).
.git
.github
node_modules
_tmp
.cache
.DS_Store
*.md
!README.md
.vscode
81 changes: 81 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: release

on:
pull_request:
push:
branches: [main]

# Only one push-to-ECR at a time per branch; queueing avoids racy tag pushes
# if two commits land back to back.
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Checkout/Install pusher/actions
uses: actions/checkout@v4
with:
repository: pusher/actions
token: ${{ secrets.PUSHER_CI_GITHUB_PRIVATE_TOKEN }}
path: .github/actions

- name: Define Common Env
id: common
uses: ./.github/actions/setup-common

- name: Set Env Vars
run: |
echo "VERSION=${{ steps.common.outputs.version }}" >> $GITHUB_ENV
echo "SHORT_SHA=${{ steps.common.outputs.short_sha }}" >> $GITHUB_ENV
echo "DATE=${{ steps.common.outputs.date }}" >> $GITHUB_ENV
echo "LONG_DATE=${{ steps.common.outputs.long_date }}" >> $GITHUB_ENV
echo "NAME=docs" >> $GITHUB_ENV

- uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build static site
env:
BUILD_ENV: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && 'production' || 'preview' }}
run: yarn build

- name: Update Algolia index
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
ALGOLIA_UPDATE_KEY: ${{ secrets.ALGOLIA_UPDATE_KEY }}
BUILD_ENV: production
run: yarn update:algolia

- name: Build Docker image
run: |
docker build -t ${NAME}:${VERSION} .
echo "[BUILT] ${NAME}:${VERSION}"

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.PUSHERINOS_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PUSHERINOS_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Push image to Amazon ECR
run: |
echo "${{ steps.login-ecr.outputs.registry }}"
docker tag ${NAME}:${VERSION} ${{ steps.login-ecr.outputs.registry }}/pusher/${NAME}:${VERSION}
docker push ${{ steps.login-ecr.outputs.registry }}/pusher/${NAME}:${VERSION}
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Build-time assets (_site/) are produced by the GitHub Actions runner before
# `docker build` runs. This image is a thin static server.
#
# Using nginxinc/nginx-unprivileged so the master process runs as the non-root
# `nginx` user (uid 101) and listens on :8080 — matches the k8s security
# context used for the rest of our web workloads.
#
# Build locally:
# yarn install && yarn build && docker build -t docs:dev .
# docker run --rm -p 8080:8080 docs:dev
# open http://localhost:8080/docs/

FROM nginxinc/nginx-unprivileged:1.27-alpine

COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
COPY _site /usr/share/nginx/html

EXPOSE 8080
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ permalink: docs/README/

An [Eleventy] powered static site using our custom [Tachyons] build with [Postcss] for styling.

It’s deployed and hosted by [Vercel] when the `main` branch changes using their [Github integration] - https://pusher-docs.vercel.app
It's built and served from our own EKS cluster (`eks-general`). On every push to `main`, GitHub Actions (`.github/workflows/release.yml`) builds the static site, pushes a Docker image to ECR (`008815156580.dkr.ecr.us-east-1.amazonaws.com/pusher/docs`), and Flux deploys it to the `docs` Service in the `internal` namespace. Public traffic reaches it via CloudFront → the `pusher-sites` nginx proxy → this pod.

See the migration plan in `pusher/engineering-manual` for the full setup.

## Running locally

Expand Down Expand Up @@ -43,11 +45,19 @@ yarn run css

### Search

Search is powered by Algolia, on every production build a refreshed index of all content is sent to them.
Search is powered by Algolia; on every `main` production build, `yarn update:algolia` pushes a refreshed index. The primary search experience is client-side JS (see `js/modules/search.mjs`). Users with JavaScript disabled see a short fallback message — no server-side rendering is offered.

Required secret for the Algolia push: `ALGOLIA_UPDATE_KEY`, set as a GitHub Actions secret on this repo.

For users without JS there is a fallback page which is powered by Vercel’s serverless functions.
### Building a production-like image locally

If you need to debug this you can run the project with `vercel dev` and it will hot reload any changes.
```bash
yarn install
yarn build
docker build -t docs:dev .
docker run --rm -p 8080:8080 docs:dev
open http://localhost:8080/docs/
```

## How to add / update new pages

Expand Down Expand Up @@ -226,8 +236,6 @@ Contributions welcome!
[eleventy]: https://www.11ty.io
[tachyons]: http://tachyons.io/
[postcss]: https://postcss.org
[vercel]: https://vercel.co/
[github integration]: https://vercel.com/docs/git-integrations
[markdown]: https://www.markdownguide.org/
[yarn]: https://yarnpkg.com/
[browsersync]: https://www.browsersync.io/
Expand Down
12 changes: 11 additions & 1 deletion _data/env.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
// BUILD_ENV is set by the release workflow:
// "production" on main pushes
// "preview" on pull requests
// unset in local dev (treat as non-production)
//
// Kept named `VERCEL_ENV` historically; the new pipeline sets `BUILD_ENV`
// but we read both so local tools that still export `VERCEL_ENV` keep
// working during the transition.
const env = process.env.BUILD_ENV || process.env.VERCEL_ENV;

module.exports = {
includeAnalytics: process.env.VERCEL_ENV === "production",
includeAnalytics: env === "production",
pusherJSVersion: "8.3.0",
};
5 changes: 4 additions & 1 deletion _includes/partials/top-nav.njk
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,14 @@
<nav class="dn db-l flex-grow-1" style="margin-left: 6px;">
<ul class="list pa0 ma0 flex items-center justify-center">
<li class="ml-auto relative w-40-l" id="search-wrap">
<form id="search-form" type="POST" action="/docs/api/search">
<form id="search-form" action="/docs/" method="get" onsubmit="return false;">
<label for="search" class="clip">
Search Pusher documentation
</label>
<input name="t" id="search" type="search" value="" placeholder="Search documentation" class="sans-serif black f7 input-reset br2 ba b--smoke hover-b--silver focus-b--starflower focus-bs-starflower pa3 lh-solid h3 w-100" maxlength="200">
<noscript>
<p class="f7 pt2 lh-copy steel ma0">Search requires JavaScript. <a href="/docs/" class="link eggplant hover-dragonfruit underline">Browse the docs</a>.</p>
</noscript>
</form>
<div class="br2 mt2 ba b--smoke absolute left-0 right-0 dn bg-snow-light" id="search-results-wrap">
<ul class="bg-white list ma0 pa0 overflow-y-auto bb b--smoke br2 br--top" style="top: 100%; max-height: 60vh;" id="search-results"></ul>
Expand Down
65 changes: 0 additions & 65 deletions api/search.js

This file was deleted.

Loading
Loading