Skip to content
Merged
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: 10 additions & 1 deletion .github/workflows/build-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ jobs:
steps:
- name: Checkout PicImpact
uses: actions/checkout@v4
- name: Resolve build SHA
id: sha
run: echo "short=${GITHUB_SHA::12}" >> "$GITHUB_OUTPUT"
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
Expand All @@ -33,4 +36,10 @@ jobs:
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/picimpact:latest
build-args: |
BUILD_SHA=${{ steps.sha.outputs.short }}
# Also tag with the commit so the pushed image is identifiable, and the
# running container reports the same value at GET /api/public/version.
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/picimpact:latest
${{ secrets.DOCKERHUB_USERNAME }}/picimpact:git-${{ steps.sha.outputs.short }}
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ WORKDIR /app

ENV NODE_ENV=production

# Git commit this image was built from, passed by the build workflow. Exposed at
# runtime via GET /api/public/version so a deploy's running commit is verifiable.
ARG BUILD_SHA=unknown
ENV BUILD_SHA=${BUILD_SHA}

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

Expand Down
2 changes: 2 additions & 0 deletions app/api/[[...route]]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import route from '~/hono'
import download from '~/hono/open/download'
import images from '~/hono/open/images'
import cameraLens from '~/hono/open/camera-lens'
import version from '~/hono/open/version'

const app = new Hono().basePath('/api')

Expand All @@ -13,6 +14,7 @@ app.route('/v1', route)
app.route('/public/download', download)
app.route('/public/images', images)
app.route('/public/camera-lens', cameraLens)
app.route('/public/version', version)
app.notFound((c) => {
return c.text('not found', 404)
})
Expand Down
18 changes: 18 additions & 0 deletions hono/open/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'server-only'

import { Hono } from 'hono'
import { ok } from '~/hono/_lib/response'

const app = new Hono()

// Public deployment marker. Returns the git commit the running image was built
// from (`BUILD_SHA`, injected as a Docker build-arg by the build-main workflow).
// Lets a deploy be verified at a glance — `curl /api/public/version` reports the
// commit actually running — instead of guessing whether `:latest` is the branch
// HEAD (which has repeatedly caused half-deploy confusion). Falls back to
// "unknown" for local/dev builds where the arg isn't set.
app.get('/', (c) => {
return ok(c, { sha: process.env.BUILD_SHA ?? 'unknown' })
})

export default app
Loading