mirror of
https://github.com/Chewbaccalakis/rfid-database.git
synced 2026-09-10 00:11:56 -07:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88c0c4a453 | ||
|
|
443dba5bba | ||
|
|
3bcdc14106 |
@@ -22,11 +22,3 @@ jobs:
|
|||||||
- run: npm run build
|
- run: npm run build
|
||||||
env:
|
env:
|
||||||
AUTH_SECRET: ci-build-secret-at-least-32-characters
|
AUTH_SECRET: ci-build-secret-at-least-32-characters
|
||||||
|
|
||||||
docker:
|
|
||||||
name: docker-build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Build production image
|
|
||||||
run: docker build -t rfid-database:ci .
|
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
name: Docker
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
tags: ["v*"]
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
# GHCR requires lowercase image names
|
||||||
|
IMAGE_NAME: ghcr.io/chewbaccalakis/rfid-database
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
name: build-and-push
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
attestations: write
|
||||||
|
id-token: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to GitHub Container Registry
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels)
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.IMAGE_NAME }}
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
type=sha,prefix=sha-,format=short
|
||||||
|
type=ref,event=branch
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
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
|
||||||
@@ -117,10 +117,26 @@ npm run typecheck
|
|||||||
npm run build
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
GitHub Actions runs on every pull request and push to `main`:
|
GitHub Actions on every pull request and push to `main`:
|
||||||
|
|
||||||
1. **lint / typecheck / test / Next.js build**
|
1. **lint / typecheck / test / Next.js build**
|
||||||
2. **`docker build`** — catches Dockerfile parse/build failures (the class of break that conflict markers previously caused)
|
2. **Docker image** — build on PRs; on `main` (and `v*` tags) push to GHCR:
|
||||||
|
`ghcr.io/chewbaccalakis/rfid-database`
|
||||||
|
|
||||||
|
### Pull the published image
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker pull ghcr.io/chewbaccalakis/rfid-database:latest
|
||||||
|
# or a specific commit: ghcr.io/chewbaccalakis/rfid-database:sha-<shortsha>
|
||||||
|
```
|
||||||
|
|
||||||
|
If the package is private, authenticate first:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin
|
||||||
|
```
|
||||||
|
|
||||||
|
Or in Compose, set `image: ghcr.io/chewbaccalakis/rfid-database:latest` and comment out `build:`.
|
||||||
|
|
||||||
## Docker
|
## Docker
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
services:
|
services:
|
||||||
rfid-database:
|
rfid-database:
|
||||||
|
# Local build (default):
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
image: rfid-database:local
|
image: rfid-database:local
|
||||||
|
# Or pull from GHCR instead of building:
|
||||||
|
# image: ghcr.io/chewbaccalakis/rfid-database:latest
|
||||||
|
# pull_policy: always
|
||||||
container_name: rfid-database
|
container_name: rfid-database
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -6,16 +6,10 @@ import { LoginPageClient } from "@/components/LoginPageClient";
|
|||||||
export const dynamic = "force-dynamic";
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
const authUrl = (process.env.AUTH_URL || "").replace(/\/$/, "");
|
|
||||||
const callbackUrlHint = authUrl
|
|
||||||
? `${authUrl}/api/auth/callback/oidc`
|
|
||||||
: "https://<your-host>/api/auth/callback/oidc";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LoginPageClient
|
<LoginPageClient
|
||||||
oidcEnabled={isOidcConfigured()}
|
oidcEnabled={isOidcConfigured()}
|
||||||
oidcName={process.env.AUTH_OIDC_NAME || "SSO"}
|
oidcName={process.env.AUTH_OIDC_NAME || "SSO"}
|
||||||
callbackUrlHint={callbackUrlHint}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,11 @@ import { Suspense } from "react";
|
|||||||
type Props = {
|
type Props = {
|
||||||
oidcEnabled: boolean;
|
oidcEnabled: boolean;
|
||||||
oidcName: string;
|
oidcName: string;
|
||||||
callbackUrlHint: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type AuthConfig = {
|
type AuthConfig = {
|
||||||
oidcEnabled: boolean;
|
oidcEnabled: boolean;
|
||||||
oidcName: string;
|
oidcName: string;
|
||||||
callbackUrl: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function authErrorMessage(code: string | null): string | null {
|
function authErrorMessage(code: string | null): string | null {
|
||||||
@@ -36,7 +34,7 @@ function authErrorMessage(code: string | null): string | null {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function LoginForm({ oidcEnabled, oidcName, callbackUrlHint }: Props) {
|
function LoginForm({ oidcEnabled, oidcName }: Props) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const params = useSearchParams();
|
const params = useSearchParams();
|
||||||
const callbackUrl = params.get("callbackUrl") || "/";
|
const callbackUrl = params.get("callbackUrl") || "/";
|
||||||
@@ -62,7 +60,6 @@ function LoginForm({ oidcEnabled, oidcName, callbackUrlHint }: Props) {
|
|||||||
|
|
||||||
const showOidc = runtimeOidc?.oidcEnabled ?? oidcEnabled;
|
const showOidc = runtimeOidc?.oidcEnabled ?? oidcEnabled;
|
||||||
const displayName = runtimeOidc?.oidcName || oidcName;
|
const displayName = runtimeOidc?.oidcName || oidcName;
|
||||||
const redirectHint = runtimeOidc?.callbackUrl || callbackUrlHint;
|
|
||||||
|
|
||||||
async function onSubmit(e: FormEvent) {
|
async function onSubmit(e: FormEvent) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -121,7 +118,6 @@ function LoginForm({ oidcEnabled, oidcName, callbackUrlHint }: Props) {
|
|||||||
{loading ? "Signing in…" : "Sign in"}
|
{loading ? "Signing in…" : "Sign in"}
|
||||||
</button>
|
</button>
|
||||||
{showOidc && (
|
{showOidc && (
|
||||||
<>
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn btn-secondary"
|
className="btn btn-secondary"
|
||||||
@@ -129,12 +125,6 @@ function LoginForm({ oidcEnabled, oidcName, callbackUrlHint }: Props) {
|
|||||||
>
|
>
|
||||||
Sign in with {displayName}
|
Sign in with {displayName}
|
||||||
</button>
|
</button>
|
||||||
<p className="muted" style={{ margin: 0, fontSize: "0.75rem" }}>
|
|
||||||
IdP redirect URI must be exactly:
|
|
||||||
<br />
|
|
||||||
<code className="mono">{redirectHint}</code>
|
|
||||||
</p>
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ function buildProviders(): Provider[] {
|
|||||||
wellKnown: `${issuer}/.well-known/openid-configuration`,
|
wellKnown: `${issuer}/.well-known/openid-configuration`,
|
||||||
clientId: process.env.AUTH_OIDC_CLIENT_ID!,
|
clientId: process.env.AUTH_OIDC_CLIENT_ID!,
|
||||||
clientSecret: process.env.AUTH_OIDC_CLIENT_SECRET!,
|
clientSecret: process.env.AUTH_OIDC_CLIENT_SECRET!,
|
||||||
|
// Auth.js OIDC defaults to PKCE-only; Authelia requires a strong `state`
|
||||||
|
checks: ["pkce", "state"],
|
||||||
authorization: {
|
authorization: {
|
||||||
params: {
|
params: {
|
||||||
scope: "openid email profile",
|
scope: "openid email profile",
|
||||||
|
|||||||
Reference in New Issue
Block a user