Skip to content

Commit 53256e6

Browse files
committed
Configure publishing docker image
1 parent 049cb7a commit 53256e6

File tree

13 files changed

+173
-22
lines changed

13 files changed

+173
-22
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Deploy Aidbox Forms Smart Launch 2
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'aidbox-forms-smart-launch-2/**'
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
17+
- name: Set up docker
18+
uses: docker/setup-buildx-action@v3
19+
20+
- name: Login to registry
21+
uses: docker/login-action@v1
22+
with:
23+
registry: ghcr.io
24+
username: ${{ github.actor }}
25+
password: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Define env variables
28+
run: |
29+
echo "IMAGE=${GITHUB_REPOSITORY@L}-aidbox-forms-smart-launch-2" >>${GITHUB_ENV}
30+
31+
- name: Publish image
32+
uses: docker/build-push-action@v2
33+
with:
34+
platforms: linux/amd64,linux/arm64
35+
context: aidbox-forms-smart-launch-2
36+
tags: ghcr.io/${{ env.IMAGE }}
37+
push: true
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Dependencies
2+
node_modules
3+
.pnpm-store
4+
5+
# Next.js build output
6+
.next
7+
out
8+
9+
# Development files
10+
.git
11+
.gitignore
12+
README.md
13+
.env
14+
.env.*
15+
!.env.example
16+
17+
# Docker files
18+
Dockerfile
19+
.dockerignore
20+
docker-compose.yaml
21+
kubernetes.yaml
22+
23+
# Debug logs
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
pnpm-debug.log*
28+
29+
# Local data directories
30+
pgdata
31+
redisdata
32+
33+
# IDE directories
34+
.idea
35+
.vscode
36+
*.swp
37+
*.swo
38+
39+
# Test files
40+
__tests__
41+
*.test.*
42+
*.spec.*
43+
44+
# OS files
45+
.DS_Store
46+
Thumbs.db
+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"extends": ["next/core-web-vitals", "next/typescript"]
2+
"extends": ["next/core-web-vitals", "next/typescript"],
3+
"rules": {
4+
"@typescript-eslint/no-explicit-any": "off"
5+
}
36
}
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# syntax=docker.io/docker/dockerfile:1
2+
3+
FROM node:18-alpine AS base
4+
5+
# Stage 1: Dependencies
6+
FROM base AS deps
7+
RUN apk add --no-cache libc6-compat
8+
9+
WORKDIR /app
10+
11+
# Install pnpm
12+
RUN corepack enable && corepack prepare pnpm@latest --activate
13+
14+
# Copy package files
15+
COPY package.json pnpm-lock.yaml ./
16+
17+
# Install dependencies
18+
RUN pnpm install --frozen-lockfile
19+
20+
# Stage 2: Builder
21+
FROM base AS builder
22+
WORKDIR /app
23+
24+
# Install pnpm
25+
RUN corepack enable && corepack prepare pnpm@latest --activate
26+
27+
# Copy dependencies from deps stage
28+
COPY --from=deps /app/node_modules ./node_modules
29+
COPY . .
30+
31+
# Build application
32+
ENV NEXT_TELEMETRY_DISABLED=1
33+
RUN pnpm build
34+
35+
# Stage 3: Runner
36+
FROM base AS runner
37+
WORKDIR /app
38+
39+
40+
RUN addgroup -g 1001 -S nodejs
41+
RUN adduser -S nextjs -u 1001
42+
43+
# Set proper permissions
44+
RUN mkdir .next && \
45+
chown nextjs:nodejs .next
46+
47+
# Copy only necessary files
48+
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
49+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
50+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
51+
52+
# Set environment variables
53+
ENV NODE_ENV=production
54+
ENV NEXT_TELEMETRY_DISABLED=1
55+
56+
# Switch to non-root user
57+
USER nextjs
58+
59+
# Expose port
60+
EXPOSE 3000
61+
62+
ENV PORT=3000
63+
64+
CMD HOSTNAME="0.0.0.0" node server.js

aidbox-forms-smart-launch-2/docker-compose.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,15 @@ services:
2929
- "${REDIS_PORT}:6379"
3030
volumes:
3131
- "./redisdata:/data"
32+
33+
# app:
34+
# image: aidbox-forms-smart-launch-2
35+
# pull_policy: never
36+
# env_file:
37+
# - .env
38+
# environment:
39+
# REDIS_URL: "redis://redis:6379/0"
40+
# AIDBOX_BASE_URL: http://aidbox:8888
41+
# PGHOST: postgres
42+
# ports:
43+
# - "3001:3000"

aidbox-forms-smart-launch-2/next.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const nextConfig: NextConfig = {
55
env: {
66
NEXT_PUBLIC_VERSION: version,
77
},
8-
/* config options here */
8+
output: "standalone",
99
};
1010

1111
export default nextConfig;

aidbox-forms-smart-launch-2/src/app/patients/page.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async function extractPageSize(params: Awaited<PageProps["searchParams"]>) {
5959
export default async function PatientsPage({ searchParams }: PageProps) {
6060
const aidbox = await getCurrentAidbox();
6161
const params = await searchParams;
62-
let pageSize = await extractPageSize(params);
62+
const pageSize = await extractPageSize(params);
6363

6464
const currentPage = Number(params.page) || 1;
6565
const searchQuery = params.search;

aidbox-forms-smart-launch-2/src/app/practitioners/page.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async function extractPageSize(params: Awaited<PageProps["searchParams"]>) {
5959
export default async function PractitionersPage({ searchParams }: PageProps) {
6060
const aidbox = await getCurrentAidbox();
6161
const params = await searchParams;
62-
let pageSize = await extractPageSize(params);
62+
const pageSize = await extractPageSize(params);
6363

6464
const currentPage = Number(params.page) || 1;
6565
const searchQuery = params.search;

aidbox-forms-smart-launch-2/src/components/app-sidebar.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import * as React from "react";
4-
import { KeyRound, LayoutDashboard, UserCog, Users } from "lucide-react";
4+
import { LayoutDashboard, UserCog, Users } from "lucide-react";
55
import { usePathname } from "next/navigation";
66
import { cn } from "@/lib/utils";
77
import Image from "next/image";
@@ -16,6 +16,7 @@ import {
1616
SidebarMenuItem,
1717
SidebarRail,
1818
} from "@/components/ui/sidebar";
19+
import Link from "next/link";
1920

2021
const data = {
2122
navMain: [
@@ -46,7 +47,7 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
4647
<SidebarMenu>
4748
<SidebarMenuItem>
4849
<SidebarMenuButton size="lg" asChild>
49-
<a href="/">
50+
<Link href="/">
5051
<div className="flex aspect-square size-8 items-center justify-center rounded-lg bg-white">
5152
<Image
5253
src="/health-samurai.svg"
@@ -60,7 +61,7 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
6061
<span className="font-semibold">Aidbox Forms</span>
6162
<span className="">v{process.env.NEXT_PUBLIC_VERSION}</span>
6263
</div>
63-
</a>
64+
</Link>
6465
</SidebarMenuButton>
6566
</SidebarMenuItem>
6667
</SidebarMenu>

aidbox-forms-smart-launch-2/src/components/pager.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function Pager({ currentPage, totalPages }: PagerProps) {
3333
const searchParams = useSearchParams();
3434

3535
function buildUrl(page: number) {
36-
const params = new URLSearchParams(searchParams.toString());
36+
const params = new URLSearchParams(searchParams?.toString());
3737
params.set("page", page.toString());
3838

3939
return pathname + "?" + params.toString();

aidbox-forms-smart-launch-2/src/lib/aidbox.ts

-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ import {
99
import { sha256 } from "@/lib/utils";
1010
import assert from "node:assert";
1111

12-
interface Meta {
13-
lastUpdated: string;
14-
createdAt: string;
15-
versionId: string;
16-
}
17-
1812
interface CommonSearchParams {
1913
_count?: number;
2014
_page?: number;
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
import Redis from "ioredis";
2-
import assert from "node:assert";
32

4-
const url = process.env.REDIS_URL;
5-
assert(url, "Environment variable REDIS_URL is required");
6-
7-
export const redis = new Redis(url);
3+
export const redis = new Redis(process.env.REDIS_URL as string);

aidbox-forms-smart-launch-2/src/lib/session.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { getIronSession, IronSession } from "iron-session";
22
import { NextApiRequest, NextApiResponse } from "next";
3-
import assert from "node:assert";
43
import { cookies } from "next/headers";
54

65
export async function getSession<T extends object>(): Promise<IronSession<T>>;
@@ -13,9 +12,8 @@ export async function getSession<T extends object>(
1312
response?: NextApiResponse,
1413
): Promise<IronSession<T>> {
1514
const password = process.env.SESSION_PASSWORD;
16-
assert(password, "Environment variable SESSION_PASSWORD is required");
1715

18-
const options = { password, cookieName: "iron-session" };
16+
const options = { password: password as string, cookieName: "iron-session" };
1917

2018
return !request || !response
2119
? await getIronSession<T>(await cookies(), options)

0 commit comments

Comments
 (0)