Skip to content

Commit

Permalink
Merge pull request #39 from techulus/main
Browse files Browse the repository at this point in the history
Try Self hosted mode
  • Loading branch information
arjunkomath authored Dec 25, 2024
2 parents 03b214d + 3845bef commit c216502
Show file tree
Hide file tree
Showing 79 changed files with 5,100 additions and 2,766 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Dockerfile
docker-compose.yml
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git
26 changes: 26 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Push to Docker hub

on:
push:
branches: [ "release" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: arjunkomath/manage:latest
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ yarn-error.log*
.env
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# vscode
.vscode
.idea

# database
sqlite

# blob
blob-data
1 change: 0 additions & 1 deletion .prettierrc

This file was deleted.

55 changes: 55 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# syntax=docker.io/docker/dockerfile:1

FROM node:20-alpine AS base

# 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
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
RUN corepack enable pnpm && pnpm i --frozen-lockfile

# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# 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 corepack enable pnpm && pnpm run build

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app

ENV NODE_ENV=production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED=1

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

COPY --from=builder /app/public ./public

# 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

USER nextjs

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"]
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,37 @@ Manage is an open-source alternative to Basecamp, offering a streamlined project
- [ ] Permissions
- [ ] Billing

## Development

### Environment

```
# Logto for Auth
LOGTO_ENDPOINT=
LOGTO_APP_ID=""
LOGTO_APP_SECRET=""
LOGTO_BASE_URL=""
LOGTO_COOKIE_SECRET=""
LOGTO_M2M_APP_ID=""
LOGTO_M2M_APP_SECRET=""
# Any S3 compatible storage
S3_BUCKET_ENDPOINT="
S3_ACCESS_KEY_ID=""
S3_SECRET_ACCESS_KEY=""
S3_BUCKET_NAME=""
```

### Run using Docker

```bash
docker-compose up
```

## Note on Performance

> **Warning**
> This app is using the unstable releases for Next.js and React.
> This app is still in development. It's not ready for production use.
> **Expect some bugs & performance hits when testing**.
> If you see something broken, you can ping me [@arjunz](https://twitter.com/arjunz).
Expand Down
3 changes: 0 additions & 3 deletions app/(api)/api/auth/[...nextauth]/route.ts

This file was deleted.

19 changes: 10 additions & 9 deletions app/(api)/api/blob/[fileId]/[fileName]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@ import { eq } from "drizzle-orm";
import type { NextRequest } from "next/server";

export async function GET(
_: NextRequest,
{ params }: { params: { fileId: string; fileName: string } },
_: NextRequest,
props: { params: Promise<{ fileId: string; fileName: string }> }
) {
const { ownerId } = await getOwner();
const db = await database();
const { fileId } = params;
const key = `${ownerId}/${fileId}`;
const params = await props.params;
const { ownerId } = await getOwner();
const db = await database();
const { fileId } = params;
const key = `${ownerId}/${fileId}`;

const fileDetails = await db.query.blob.findFirst({
const fileDetails = await db.query.blob.findFirst({
where: eq(blob.key, key),
});

if (!fileDetails) {
if (!fileDetails) {
return new Response("Not found", { status: 404 });
}

try {
try {
const signedUrl = await getUrl(key);
const file = await fetch(signedUrl);

Expand Down
7 changes: 4 additions & 3 deletions app/(api)/api/calendar/[ownerId]/[projectId]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { calendarEvent, project, task, taskList } from "@/drizzle/schema";
import { getDatabaseForOwner } from "@/lib/utils/turso";
import { getDatabaseForOwner } from "@/lib/utils/useDatabase";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import { and, desc, eq, lte } from "drizzle-orm";
Expand All @@ -12,11 +12,12 @@ export const dynamic = "force-dynamic";

export async function GET(
_: Request,
{ params }: { params: { projectId: string; ownerId: string } },
props: { params: Promise<{ projectId: string; ownerId: string }> },
) {
const params = await props.params;
const { projectId, ownerId } = params;

const db = getDatabaseForOwner(ownerId);
const db = await getDatabaseForOwner(ownerId);

const projectDetails = await db.query.project
.findFirst({
Expand Down
56 changes: 0 additions & 56 deletions app/(auth)/actions.ts

This file was deleted.

11 changes: 11 additions & 0 deletions app/(auth)/callback/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { logtoConfig } from "@/app/logto";
import { handleSignIn } from "@logto/next/server-actions";
import { redirect } from "next/navigation";
import type { NextRequest } from "next/server";

export async function GET(request: NextRequest) {
const searchParams = request.nextUrl.searchParams;
await handleSignIn(logtoConfig, searchParams);

redirect("/start");
}
20 changes: 20 additions & 0 deletions app/(auth)/sign-in.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"use client";

type Props = {
onSignIn: () => Promise<void>;
};

const SignIn = ({ onSignIn }: Props) => {
return (
<button
type="button"
onClick={() => {
onSignIn();
}}
>
Sign In
</button>
);
};

export default SignIn;
Loading

0 comments on commit c216502

Please sign in to comment.