Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"tabWidth": 4,
"printWidth": 100,
"endOfLine": "lf",
"singleQuote": true,
"trailingComma": "es5"
}
1,383 changes: 1,383 additions & 0 deletions bun.lock

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
services:
app:
container_name: robotics-app
profiles: ["full", "app"]
build:
dockerfile: ./docker/app/Dockerfile
context: .
target: dev
args:
- USER_ID=${UID:-1000}
- GROUP_ID=${GID:-1000}
user: "${UID:-1000}:${GID:-1000}"
restart: always
command: bun run dev
environment:
- NODE_ENV=development
# For our dear WSL2 users :)
- WATCHPACK_POLLING=true

env_file:
- .env

volumes:
- .:/app:cached
- modules_build:/app/node_modules
- next_build:/app/.next
- prisma-generated:/app/node_modules/.prisma
- prisma-client:/app/node_modules/@prisma/client
ports:
- 3000:3000

networks:
- db-network
- internet
depends_on:
- postgres

studio:
container_name: robotics-studio
build:
dockerfile: ./docker/studio/Dockerfile
context: .
working_dir: /app
volumes:
- .:/app
ports:
- '3001:3001'
env_file:
- .env
networks:
- internet
- db-network
depends_on:
- postgres

postgres:
image: postgres:15
container_name: robotics-postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: maindb
volumes:
- postgres:/var/lib/postgresql/data
networks:
- db-network

networks:
db-network:
external: false
internet:
driver: bridge

volumes:
postgres:
app-data:
modules_build:
next_build:
prisma-generated:
prisma-client:
90 changes: 90 additions & 0 deletions docker/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
ARG NODE_VERSION=20


FROM node:${NODE_VERSION}-alpine AS base

ARG USER_ID=1000
ARG GROUP_ID=1000

WORKDIR /app

RUN apk update && apk add curl unzip bash

RUN if getent group ${GROUP_ID}; then \
existing_group=$(getent group ${GROUP_ID} | cut -d: -f1); \
sed -i "s/^${existing_group}:/robotics:/" /etc/group; \
else \
addgroup -g ${GROUP_ID} robotics; \
fi && \
if getent passwd ${USER_ID}; then \
existing_user=$(getent passwd ${USER_ID} | cut -d: -f1); \
sed -i "s/^${existing_user}:/robotics:/" /etc/passwd; \
else \
adduser -u ${USER_ID} -G robotics -s /bin/sh -D robotics; \
fi

RUN curl -fsSL https://bun.sh/install | bash && \
mv /root/.bun/bin/bun /usr/local/bin/bun

RUN chown -R robotics:robotics /app

FROM base AS deps

# https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine
RUN apk update
RUN apk add --no-cache libc6-compat git openssl

WORKDIR /app

COPY package.json bun.lock ./

USER robotics
RUN --mount=type=cache,uid=${USER_ID},gid=${GROUP_ID},target=/home/robotics/.bun/install/cache \
bun install --frozen-lockfile --verbose


FROM base AS dev

WORKDIR /app
COPY --from=deps --chown=robotics:robotics /app/node_modules ./node_modules
COPY --chown=robotics:robotics . .
USER robotics
ENV NEXT_TELEMETRY_DISABLED=1

FROM base AS builder

WORKDIR /app

COPY --from=deps --chown=robotics:robotics /app/node_modules ./node_modules
COPY --chown=robotics:robotics . .
USER robotics
ENV NEXT_TELEMETRY_DISABLED=1

RUN bun x prisma generate

RUN bun run build


FROM base AS runner

WORKDIR /app

ENV NEXT_TELEMETRY_DISABLED=1

RUN apk add postgresql-client

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

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

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

USER nextjs

ENV PORT=3000
ENV HOSTNAME="::"

CMD ["node", "server.js"]
21 changes: 21 additions & 0 deletions docker/studio/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ARG NODE_VERSION=20

FROM node:${NODE_VERSION}-alpine AS base

WORKDIR /build

RUN apk update && apk add curl unzip bash

RUN curl -fsSL https://bun.sh/install | bash

ENV PATH="${PATH}:/root/.bun/bin"

FROM base AS deps
RUN apk update
RUN apk add --no-cache libc6-compat git openssl

WORKDIR /app

RUN --mount=type=cache,target=/root/.bun/install/cache bun install --frozen-lockfile --verbose prisma

CMD ["bun", "x", "prisma", "studio", "--hostname", "0.0.0.0", "--port", "3001"]
39 changes: 0 additions & 39 deletions dockerfile

This file was deleted.

10 changes: 10 additions & 0 deletions mdx-components.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { MDXComponents } from 'mdx/types'
import YouTube from '@/components/markdown/youtube'

const components = {
YouTube
} satisfies MDXComponents

export function useMDXComponents(): MDXComponents {
return components
}
12 changes: 10 additions & 2 deletions next.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import type { NextConfig } from "next";
import createMDX from '@next/mdx'
import rehypePrettyCode from "rehype-pretty-code";

const nextConfig: NextConfig = {
/* config options here */
pageExtensions: ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'],
};

export default nextConfig;
const withMDX = createMDX({
options: {
rehypePlugins: [['rehype-pretty-code', { theme: "github-dark" }]],
},
})

export default withMDX(nextConfig);
Loading