This commit is contained in:
2026-07-18 01:12:55 +12:00
parent ebb2d8a2ab
commit 0c9a87e8be
9 changed files with 2269 additions and 946 deletions
-3
View File
@@ -1,3 +0,0 @@
{
"extends": "next/core-web-vitals"
}
+103
View File
@@ -0,0 +1,103 @@
name: Docker
# Gitea Actions workflow: builds the Docker image and publishes it to the
# Gitea Container Registry hosted on this Gitea instance.
on:
push:
branches:
- main
- develop
tags:
- "v*.*.*"
pull_request:
branches:
- main
- develop
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
# Derive the registry host from the Gitea instance URL (e.g.
# https://gitea.example.com -> gitea.example.com). The Gitea Container
# Registry is served from the instance root, so this works on any host.
- name: Resolve registry host
run: echo "REGISTRY=${GITHUB_SERVER_URL#*://}" >> "$GITHUB_ENV"
- name: Checkout repository
uses: actions/checkout@v4
# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache.
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Log into the Gitea Container Registry except on PR.
#
# NOTE: Gitea's automatic Actions token (secrets.GITHUB_TOKEN) is NOT
# granted package scope, so it cannot push to the container registry.
# Create a Gitea personal access token with the "write:package" scope
# (Settings -> Applications -> Access Tokens) and add it as a repo/org
# Actions secret named PACKAGES_TOKEN. Set PACKAGES_USER to the token
# owner's username (defaults to the triggering actor).
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ vars.PACKAGES_USER || github.actor }}
password: ${{ secrets.PACKAGES_TOKEN }}
# Extract metadata (tags, labels) for Docker.
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
# Build and push the Docker image with Buildx (don't push on PR).
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# NOTE: type=gha cache is intentionally omitted. Gitea's act_runner cache
# service is not reachable from the buildx container on this instance, so
# cache import timed out (~30s) on every run. The Dockerfile's BuildKit
# cache mounts still speed up dependency installs within a build.
platforms: linux/amd64
# Tell Arcane to pull the freshly-pushed image and recreate the container.
#
# Create the webhook in Arcane: Settings -> Webhooks -> New, targeting the
# compose PROJECT with the "update" action (pulls new images + recreates
# changed services). Arcane shows the token (arc_wh_...) exactly once; the
# full trigger URL is
# https://<arcane-host>/api/webhooks/trigger/arc_wh_xxxxxxxx...
# Store that whole URL as the Actions secret ARCANE_WEBHOOK_URL. The
# endpoint is unauthenticated apart from the token in the path (rate-limited
# to 60 req / 10s per IP), takes no body, and only fires on real pushes to
# main — not on PRs, and skipped automatically if the secret is unset.
- name: Trigger Arcane deployment
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
ARCANE_WEBHOOK_URL: ${{ secrets.ARCANE_WEBHOOK_URL }}
run: |
if [ -z "$ARCANE_WEBHOOK_URL" ]; then
echo "ARCANE_WEBHOOK_URL not set; skipping deploy trigger."
exit 0
fi
code=$(curl -sS -o /dev/null -w '%{http_code}' -X POST "$ARCANE_WEBHOOK_URL")
echo "Arcane webhook responded with HTTP $code"
case "$code" in
2*) echo "Deployment triggered." ;;
*) echo "::error::Arcane webhook failed (HTTP $code)"; exit 1 ;;
esac
-99
View File
@@ -1,99 +0,0 @@
name: Docker
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
schedule:
- cron: '38 21 * * *'
push:
branches: [ "master" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "master" ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
with:
cosign-release: 'v2.2.4'
# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
+86 -35
View File
@@ -1,66 +1,117 @@
# syntax=docker.io/docker/dockerfile:1
# ============================================
# Stage 1: Dependencies Installation Stage
# ============================================
FROM node:18-alpine AS base
# IMPORTANT: Node.js Version Maintenance
# This Dockerfile uses Node.js 24.18.0-slim, which was the latest LTS version at the time of writing.
# To ensure security and compatibility, regularly update the NODE_VERSION ARG to the latest LTS version.
ARG NODE_VERSION=24.18.0-slim
# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
FROM node:${NODE_VERSION} AS dependencies
# Set working directory
WORKDIR /app
# Install dependencies based on the preferred package manager
# Copy package-related files first to leverage Docker's caching mechanism
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
# Install project dependencies with frozen lockfile for reproducible builds
RUN --mount=type=cache,target=/root/.npm \
--mount=type=cache,target=/usr/local/share/.cache/yarn \
--mount=type=cache,target=/root/.local/share/pnpm/store \
if [ -f package-lock.json ]; then \
npm ci --no-audit --no-fund; \
elif [ -f yarn.lock ]; then \
corepack enable yarn && yarn install --frozen-lockfile --production=false; \
elif [ -f pnpm-lock.yaml ]; then \
# --config.strictDepBuilds=false: pnpm 11 hard-fails (ERR_PNPM_IGNORED_BUILDS)
# when a dependency with a build script (e.g. sharp) isn't explicitly approved.
# sharp ships prebuilt binaries so its build script is unnecessary; this flag
# downgrades the gate to a warning and keeps the build resilient regardless of
# pnpm-workspace.yaml's allowBuilds value. See CLAUDE.md "pnpm / sharp build".
corepack enable pnpm && pnpm install --frozen-lockfile --config.strictDepBuilds=false; \
else \
echo "No lockfile found." && exit 1; \
fi
# ============================================
# Stage 2: Build Next.js application in standalone mode
# ============================================
# Rebuild the source code only when needed
FROM base AS builder
FROM node:${NODE_VERSION} AS builder
# Set working directory
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
# Copy project dependencies from dependencies stage
COPY --from=dependencies /app/node_modules ./node_modules
# Copy application source code
COPY . .
ENV NODE_ENV=production
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED=1
RUN \
if [ -f yarn.lock ]; then yarn run build; \
elif [ -f package-lock.json ]; then npm run build; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
else echo "Lockfile not found." && exit 1; \
# Build Next.js application
# If you want to speed up Docker rebuilds, you can cache the build artifacts
# by adding: --mount=type=cache,target=/app/.next/cache
# This caches the .next/cache directory across builds, but it also prevents
# .next/cache/fetch-cache from being included in the final image, meaning
# cached fetch responses from the build won't be available at runtime.
RUN if [ -f package-lock.json ]; then \
npm run build; \
elif [ -f yarn.lock ]; then \
corepack enable yarn && yarn build; \
elif [ -f pnpm-lock.yaml ]; then \
corepack enable pnpm && pnpm build; \
else \
echo "No lockfile found." && exit 1; \
fi
# Production image, copy all the files and run next
FROM base AS runner
# ============================================
# Stage 3: Run Next.js application
# ============================================
FROM node:${NODE_VERSION} AS runner
# Set working directory
WORKDIR /app
# Set production environment variables
ENV NODE_ENV=production
# Uncomment the following line in case you want to disable telemetry during runtime.
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the run time.
# ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Copy production assets
COPY --from=builder --chown=node:node /app/public ./public
COPY --from=builder /app/public ./public
# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown node:node .next
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=node:node /app/.next/standalone ./
COPY --from=builder --chown=node:node /app/.next/static ./.next/static
USER nextjs
# If you want to persist the fetch cache generated during the build so that
# cached responses are available immediately on startup, uncomment this line:
# COPY --from=builder --chown=node:node /app/.next/cache ./.next/cache
# Switch to non-root user for security best practices
USER node
# Expose port 3000 to allow HTTP traffic
EXPOSE 3000
ENV PORT=3000
# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/config/next-config-js/output
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]
# Start Next.js standalone server
CMD ["node", "server.js"]
+9
View File
@@ -0,0 +1,9 @@
import { defineConfig, globalIgnores } from "eslint/config";
import nextVitals from "eslint-config-next/core-web-vitals";
const eslintConfig = defineConfig([
...nextVitals,
globalIgnores([".next/**", "out/**", "build/**"]),
]);
export default eslintConfig;
+3
View File
@@ -1,6 +1,9 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "standalone",
images: {
qualities: [75, 100],
},
};
export default nextConfig;
+2042 -780
View File
File diff suppressed because it is too large Load Diff
+9 -9
View File
@@ -3,14 +3,14 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev --turbopack",
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "eslint ."
},
"dependencies": {
"@next/env": "15.2.4",
"@next/third-parties": "15.2.4",
"@next/env": "^16.2.10",
"@next/third-parties": "^16.2.10",
"@radix-ui/react-accordion": "^1.2.3",
"@vercel/analytics": "^1.4.1",
"@vercel/speed-insights": "^1.1.0",
@@ -18,17 +18,17 @@
"clsx": "^2.1.1",
"lucide-react": "^0.487.0",
"motion": "^11.16.0",
"next": "15.2.4",
"react": "19.1.0",
"react-dom": "19.1.0",
"next": "^16.2.10",
"react": "^19.2.7",
"react-dom": "^19.2.7",
"sharp": "^0.33.5",
"tailwind-merge": "^3.1.0",
"tw-animate-css": "^1.2.5"
},
"devDependencies": {
"@tailwindcss/postcss": "^4.1.1",
"eslint": "^8",
"eslint-config-next": "15.2.4",
"eslint": "^9.39.5",
"eslint-config-next": "^16.2.10",
"postcss": "^8.4.49",
"tailwindcss": "^4.1.1"
}
+17 -20
View File
@@ -24,27 +24,24 @@ export default function Navbar() {
setDropdownActive(!isDropdownActive);
}
function useOutsideAlerter(ref) {
useEffect(() => {
/**
* Alert if clicked on outside of element
*/
function handleClickOutside(event) {
if (ref.current && !ref.current.contains(event.target)) {
setActive(true);
}
}
// Bind the event listener
document.addEventListener("mousedown", handleClickOutside);
return () => {
// Unbind the event listener on clean up
document.removeEventListener("mousedown", handleClickOutside);
};
}, [ref]);
}
const wrapperRef = useRef(null);
useOutsideAlerter(wrapperRef);
useEffect(() => {
/**
* Close the menu if clicked on outside of element
*/
function handleClickOutside(event) {
if (wrapperRef.current && !wrapperRef.current.contains(event.target)) {
setActive(true);
}
}
// Bind the event listener
document.addEventListener("mousedown", handleClickOutside);
return () => {
// Unbind the event listener on clean up
document.removeEventListener("mousedown", handleClickOutside);
};
}, []);
return (
<nav className={`${styles.navbar} shadow-sm`}>