ci/cd: configure automated Docker builds on Gitea and Portainer deployment
Build and Deploy / build-and-push (push) Successful in 2m39s
Build and Deploy / build-and-push (push) Successful in 2m39s
This commit is contained in:
1 parent
7a84480d70
commit
eb29528aad
11 files changed
+82
-25
No files matched your search
@@ -1,3 +1,4 @@
|
|||||||
NEXT_PUBLIC_SUPABASE_URL=YOUR_PUBLIC_SUPABASE_URL
|
NEXT_PUBLIC_SUPABASE_URL=YOUR_PUBLIC_SUPABASE_URL
|
||||||
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=YOUR_PUBLIC_SUPABASE_PUBLISHABLE_KEY
|
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=YOUR_PUBLIC_SUPABASE_PUBLISHABLE_KEY
|
||||||
BASE_PATH=""
|
BASE_PATH=""
|
||||||
|
PORT=3000
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
name: Build and Deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to Gitea Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: gitea.pascalyazid.com
|
||||||
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and Push Docker Image
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/arm64,linux/amd64
|
||||||
|
push: true
|
||||||
|
tags: gitea.pascalyazid.com/pascalyazid/fastchat:latest
|
||||||
|
build-args: |
|
||||||
|
NEXT_PUBLIC_SUPABASE_URL=${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
|
||||||
|
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=${{ secrets.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY }}
|
||||||
@@ -18,6 +18,9 @@
|
|||||||
/out/
|
/out/
|
||||||
|
|
||||||
# production
|
# production
|
||||||
|
.env.production
|
||||||
|
.env.development
|
||||||
|
.env
|
||||||
/build
|
/build
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
|
|||||||
+10
-1
@@ -11,6 +11,15 @@ FROM base AS builder
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# --- MUST BE HERE IN THE BUILDER STAGE ---
|
||||||
|
ARG NEXT_PUBLIC_SUPABASE_URL
|
||||||
|
ARG NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY
|
||||||
|
|
||||||
|
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL
|
||||||
|
ENV NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=$NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY
|
||||||
|
# -----------------------------------------
|
||||||
|
|
||||||
RUN bun run build
|
RUN bun run build
|
||||||
|
|
||||||
# Step 3. Production image
|
# Step 3. Production image
|
||||||
@@ -24,4 +33,4 @@ COPY --from=builder /app/.next/static ./.next/static
|
|||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
ENV PORT=3000
|
ENV PORT=3000
|
||||||
CMD ["bun", "server.js"]
|
CMD ["bun", "server.js"]
|
||||||
@@ -51,6 +51,7 @@ export function AvatarUpload({ avatarUrl }: Readonly<{ avatarUrl: string | null
|
|||||||
<Image
|
<Image
|
||||||
src={avatarUrl}
|
src={avatarUrl}
|
||||||
alt=""
|
alt=""
|
||||||
|
loading="eager"
|
||||||
width={200}
|
width={200}
|
||||||
height={200}
|
height={200}
|
||||||
className="size-20 rounded-full border-4 border-white object-cover shadow-md transition group-hover:opacity-80"
|
className="size-20 rounded-full border-4 border-white object-cover shadow-md transition group-hover:opacity-80"
|
||||||
|
|||||||
+12
-12
@@ -1,13 +1,13 @@
|
|||||||
services:
|
services:
|
||||||
web:
|
web:
|
||||||
build: .
|
build:
|
||||||
image: fastchat:latest
|
context: .
|
||||||
container_name: fastchat
|
args:
|
||||||
pull_policy: build
|
NEXT_PUBLIC_SUPABASE_URL: ${NEXT_PUBLIC_SUPABASE_URL}
|
||||||
restart: always
|
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY: ${NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY}
|
||||||
ports:
|
ports:
|
||||||
- "${PORT}:3000"
|
- "${PORT:-3000}:3000"
|
||||||
environment:
|
environment:
|
||||||
- NEXT_PUBLIC_SUPABASE_URL
|
- NEXT_PUBLIC_SUPABASE_URL
|
||||||
- NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY
|
- NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY
|
||||||
- BASE_PATH
|
- BASE_PATH
|
||||||
+16
-8
@@ -1,16 +1,24 @@
|
|||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from 'next';
|
||||||
|
|
||||||
|
const getHostname = (urlStr: string | undefined): string | null => {
|
||||||
|
if (!urlStr || urlStr.trim() === '') return null;
|
||||||
|
try {
|
||||||
|
return new URL(urlStr).hostname;
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const supabaseHostname = getHostname(process.env.NEXT_PUBLIC_SUPABASE_URL);
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
output: "standalone",
|
output: 'standalone',
|
||||||
basePath: process.env.BASE_PATH,
|
|
||||||
allowedDevOrigins: ["100.64.0.10"],
|
|
||||||
images: {
|
images: {
|
||||||
remotePatterns: [
|
remotePatterns: [
|
||||||
{
|
{
|
||||||
protocol: "https",
|
protocol: 'https',
|
||||||
hostname: "supabase.pascalyazid.com",
|
hostname: supabaseHostname ?? '**.supabase.co',
|
||||||
port: "",
|
pathname: '/storage/v1/object/**',
|
||||||
pathname: "/storage/v1/object/sign/avatars/**",
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ export async function listRooms() {
|
|||||||
|
|
||||||
const { data: rooms, error: roomsError } = await supabase
|
const { data: rooms, error: roomsError } = await supabase
|
||||||
.from("rooms")
|
.from("rooms")
|
||||||
.select("id, name, created_at")
|
.select("id, name, created_at, owner_id")
|
||||||
.in("id", roomIds)
|
.in("id", roomIds)
|
||||||
.order("created_at", { ascending: false });
|
.order("created_at", { ascending: false });
|
||||||
|
|
||||||
@@ -98,6 +98,7 @@ export async function listRooms() {
|
|||||||
id: room.id,
|
id: room.id,
|
||||||
name: room.name,
|
name: room.name,
|
||||||
created_at: room.created_at,
|
created_at: room.created_at,
|
||||||
|
owner_id: room.owner_id,
|
||||||
member_count: countMap.get(room.id) ?? 0,
|
member_count: countMap.get(room.id) ?? 0,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ import { createBrowserClient } from "@supabase/ssr";
|
|||||||
export function createClient() {
|
export function createClient() {
|
||||||
return createBrowserClient(
|
return createBrowserClient(
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY!,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@ export async function updateSession(request: NextRequest) {
|
|||||||
|
|
||||||
const supabase = createServerClient(
|
const supabase = createServerClient(
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY!,
|
||||||
{
|
{
|
||||||
cookies: {
|
cookies: {
|
||||||
getAll() {
|
getAll() {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export async function createClient() {
|
|||||||
|
|
||||||
return createServerClient(
|
return createServerClient(
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY!,
|
||||||
{
|
{
|
||||||
cookies: {
|
cookies: {
|
||||||
getAll() {
|
getAll() {
|
||||||
|
|||||||
Reference in new issue
Block a user