Skip to content

Commit

Permalink
Merge pull request #4 from timia2109/epic/users
Browse files Browse the repository at this point in the history
[V2] Multiuser support
  • Loading branch information
timia2109 authored Aug 7, 2024
2 parents 2e710b5 + 1a8603d commit 0d88708
Show file tree
Hide file tree
Showing 118 changed files with 7,479 additions and 7,531 deletions.
15 changes: 5 additions & 10 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Since .env is gitignored, you can use .env.example to build a new `.env` file when you clone the repo.
# Keep this file up-to-date when you add new variables to `.env`.

# This file will be committed to version control, so make sure not to have any secrets in it.
# If you are cloning this repo, create a copy of this file named `.env` and populate it with your secrets.

# When adding additional env variables, the schema in /env/schema.mjs should be updated accordingly

# Prisma
DATABASE_URL=file:./db.sqlite
DATABASE_URL=mysql://root:root@db/simple-meal-plan
INVITATION_VALIDITY=P30D
NEXTAUTH_SECRET=A_SECRET
ROOT_URL=https://example.com
NEXT_PUBLIC_PRIVACY_URL=https://example.com
14 changes: 10 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint"],
"extends": ["next/core-web-vitals", "plugin:@typescript-eslint/recommended"],
"plugins": [
"@typescript-eslint"
],
"extends": [
"next/core-web-vitals",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/consistent-type-imports": "warn"
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/no-non-null-assertion": "off"
}
}
}
35 changes: 35 additions & 0 deletions .github/workflows/publish-epic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish Epic
on:
push:
branches:
- epic/*
env:
REGISTRY: ghcr.io
jobs:
build-docker-image:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Docker Login
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker Metadata action
id: docker_metadata
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=ref,event=branch
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.docker_metadata.outputs.tags }}
labels: ${{ steps.docker_metadata.outputs.labels }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ yarn-error.log*

# typescript
*.tsbuildinfo
.yarn/cache
.yarn/cache
OLD_pages
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug server-side",
"type": "node-terminal",
"request": "launch",
"command": "pnpm dev"
},
{
"name": "Debug client-side",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000"
},
{
"name": "Debug full stack",
"type": "node-terminal",
"request": "launch",
"command": "pnpm dev",
"serverReadyAction": {
"pattern": "- Local:.+(https?://.+)",
"uriFormat": "%s",
"action": "debugWithChrome"
}
}
]
}
25 changes: 18 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
# Simple Meal Plan

This is a very simple meal planner which I build in two hours.
I want to replace the Excel Sheet, my girlfriend was using.
Currently there a no authentication build in. So this should only deployed on private networks.
Work in Progress.
This is a very simple meal planner. It's main purpose is to host it as a free SaaS solution.
You can use it [here](https://example.com). Anyway you can deploy it using Docker.

I want to replace the Excel Sheet, my girlfriend was using.

## Features

![Example Screenshot](public/example.png)

- Plan Meal for any date
- (Tablet, Desktop): See a complete calendar of the month which is editable
- Share meal plans with magic links to other users to collaborate (household, etc.)
- Manage multiple meal plans per user

## Techstack

- [Next.js](https://nextjs.org)
- [Prisma](https://prisma.io)
- [Tailwind CSS](https://tailwindcss.com)
- [tRPC](https://trpc.io)
- [DaisyUI](https://daisyui.com)

## Deployment

## Screenshot
![Example Screenshot](docs/example.png)
You'll need a MySQL / MariaDB database.
Have a look at [`.env.example`](./.env.example) or at the [schema](./src/env/schema.mjs)
71 changes: 26 additions & 45 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -1,64 +1,45 @@
##### DEPENDENCIES
FROM node:20 AS base

FROM node:16-alpine AS deps
RUN apk add --no-cache libc6-compat openssl1.1-compat
FROM base AS builder
WORKDIR /app

# Install Prisma Client - remove if not using Prisma

COPY prisma ./

# Install dependencies based on the preferred package manager

COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml\* ./

RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; \
else echo "Lockfile not found." && exit 1; \
fi

##### BUILDER

FROM node:16-alpine AS builder
ARG DATABASE_URL
ARG NEXT_PUBLIC_CLIENTVAR
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# ENV NEXT_TELEMETRY_DISABLED 1
ENV NEXT_TELEMETRY_DISABLED=1 SKIP_ENV_VALIDATION=1

RUN \
if [ -f yarn.lock ]; then SKIP_ENV_VALIDATION=1 yarn build; \
elif [ -f package-lock.json ]; then SKIP_ENV_VALIDATION=1 npm run build; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && SKIP_ENV_VALIDATION=1 pnpm run build; \
else echo "Lockfile not found." && exit 1; \
fi
# SET DUMMY VALUES FOR BUILD
ENV DATABASE_URL=CHANGE_ME
ENV GOOGLE_CLIENT_ID=CHANGE_ME
ENV GOOGLE_CLIENT_SECRET=CHANGE_ME
ENV NEXTAUTH_SECRET=CHANGE_ME

##### RUNNER
RUN corepack enable pnpm && pnpm i --frozen-lockfile && pnpm run build

FROM node:16-alpine AS runner
RUN apk add --no-cache libc6-compat openssl1.1-compat
# ================================#
# PROD
# ================================
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production

# ENV NEXT_TELEMETRY_DISABLED 1
ENV NODE_ENV=production NEXT_TELEMETRY_DISABLED=1

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

COPY --from=builder /app/next.config.mjs ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
COPY --chown=nextjs:nodejs prisma ./prisma/

COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next
RUN npm install prisma

COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --chown=nextjs:nodejs ./init.sh .

USER nextjs

EXPOSE 3000
ENV PORT 3000

CMD ["node", "server.js"]
ENV PORT=3000 HOSTNAME=0.0.0.0
ENTRYPOINT [ "/bin/sh", "./init.sh" ]
Binary file removed docs/example.png
Binary file not shown.
4 changes: 4 additions & 0 deletions init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

#!/bin/sh
npx prisma migrate deploy
node server.js
16 changes: 11 additions & 5 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@
/** @type {import("next").NextConfig} */
const config = {
reactStrictMode: true,
swcMinify: true,
i18n: {
locales: ["en"],
defaultLocale: "en",
},
output: "standalone",
images: {
remotePatterns: [
{
hostname: "img.shields.io",
},
{
hostname: "*.googleusercontent.com",
},
],
},
};

export default config;
Loading

0 comments on commit 0d88708

Please sign in to comment.