-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2a553f
commit 03ad218
Showing
170 changed files
with
12,175 additions
and
9,103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules | ||
npm-debug.log | ||
.git | ||
.gitignore | ||
*.md | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
PAYLOAD_DATABASE_URL="mongodb://127.0.0.1/payload" | ||
PAYLOAD_SECRET="verysecretkey" | ||
PAYLOAD_REVALIDATION_KEY="veryprivatekey" | ||
PAYLOAD_PORT=3001 | ||
PAYLOAD_DEVELOPMENT_AUTOLOGIN_EMAIL=[email protected] | ||
PAYLOAD_DEVELOPMENT_AUTOLOGIN_PASSWORD=root | ||
PAYLOAD_LOCAL_DEVELOPMENT=true | ||
|
||
NEXT_REVALIDATION_KEY="veryprivatekey" | ||
|
||
PUBLIC_FRONTEND_URL="http://localhost:3000" | ||
PUBLIC_SERVER_URL="http://localhost:3001" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,38 @@ | ||
name: Build on push | ||
name: CI | ||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
types: [opened, synchronize] | ||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
- name: Use Node.js 20 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
cache: 'pnpm' | ||
- name: Install dependencies | ||
run: pnpm install | ||
- name: Build all | ||
run: pnpm -r build | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
|
||
- name: Use Node.js 20 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
cache: "pnpm" | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Build all | ||
run: pnpm build | ||
env: | ||
PAYLOAD_DATABASE_URL: ${{ secrets.PAYLOAD_DATABASE_URL }} | ||
PAYLOAD_SECRET: ${{ secrets.PAYLOAD_SECRET }} | ||
PAYLOAD_REVALIDATION_KEY: ${{ secrets.PAYLOAD_REVALIDATION_KEY }} | ||
PAYLOAD_PORT: ${{ secrets.PAYLOAD_PORT }} | ||
NEXT_REVALIDATION_KEY: ${{ secrets.NEXT_REVALIDATION_KEY }} | ||
PUBLIC_FRONTEND_URL: ${{ vars.PUBLIC_FRONTEND_URL }} | ||
PUBLIC_SERVER_URL: ${{ vars.PUBLIC_SERVER_URL }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
.DS_Store | ||
node_modules | ||
.turbo | ||
*.log | ||
.next | ||
dist | ||
dist-ssr | ||
build | ||
*.local | ||
.env | ||
.cache | ||
server/dist | ||
public/dist | ||
.vscode | ||
!.vscode/extensions.json | ||
!.vscode/extensions.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
auto-install-peers=true | ||
legacy-peer-deps=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,2 @@ | ||
/packages/next/.next | ||
*.yaml | ||
|
||
dist | ||
build | ||
|
||
/packages/ui/storybook-static | ||
/packages/ui/pnpm-lock.yaml | ||
/packages/ui/CHANGELOG.md | ||
/packages/ui/vite.config.ts.timestamp-* | ||
/packages/cms/generated | ||
/packages/cms/db_data | ||
/packages/cms/src/payload-types.ts | ||
data/gen | ||
packages/cms-types/payload.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"plugins": ["prettier-plugin-tailwindcss", "prettier-plugin-packagejson"] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# Base image with Node.js | ||
ARG NODE_VERSION=20 | ||
# Use a specific version of the Node.js Alpine image as the base. Alpine images are minimal and lightweight. | ||
FROM node:${NODE_VERSION}-alpine AS base | ||
# Update the package list and install libc6-compat. This package is often required for binary Node.js modules. | ||
RUN apk update && apk add --no-cache libc6-compat | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
RUN pnpm config set store-dir ~/.pnpm-store | ||
|
||
# Set environment variables (copied from .env.example) | ||
# TODO: Figure out a better way to do this | ||
ENV PAYLOAD_DATABASE_URL="mongodb://127.0.0.1:27017/payload" | ||
ENV PAYLOAD_SECRET="verysecretkey" | ||
ENV PAYLOAD_REVALIDATION_KEY="veryprivatekey" | ||
ENV PAYLOAD_PORT=3001 | ||
ENV [email protected] | ||
ENV PAYLOAD_DEVELOPMENT_AUTOLOGIN_PASSWORD=root | ||
ENV PAYLOAD_LOCAL_DEVELOPMENT=true | ||
|
||
ENV NEXT_REVALIDATION_KEY="veryprivatekey" | ||
|
||
ENV PUBLIC_FRONTEND_URL="http://localhost:3000" | ||
ENV PUBLIC_SERVER_URL="http://localhost:3001" | ||
|
||
|
||
# Setup pnpm and turbo | ||
# Start a new stage based on the base image for setting up pnpm (a package manager) and turbo (for monorepo management). | ||
FROM base as setup | ||
RUN pnpm install --global turbo | ||
|
||
# Build argument for specifying the project | ||
# Introduce a build argument 'PROJECT' to specify which project in the monorepo to build. | ||
ARG PROJECT=web | ||
|
||
# Install all dependencies in the monorepo | ||
# Start a new stage for handling dependencies. This stage uses the previously setup image with pnpm and turbo installed. | ||
FROM setup AS dependencies | ||
WORKDIR /app | ||
# Copy the essential configuration files and the specific project's files into the Docker image. | ||
COPY packages/ ./packages/ | ||
COPY turbo.json ./ | ||
COPY package.json turbo.json packages ./ | ||
COPY apps/${PROJECT} ./apps/${PROJECT} | ||
COPY pnpm-lock.yaml pnpm-workspace.yaml ./ | ||
# Install dependencies as per the lockfile to ensure consistent dependency resolution. | ||
RUN pnpm install --frozen-lockfile | ||
|
||
# Prune projects to focus on the specified project scope | ||
# Start a new stage to prune the monorepo, focusing only on the necessary parts for the specified project. | ||
FROM dependencies AS pruner | ||
RUN turbo prune --scope=${PROJECT} --docker | ||
# Remove all empty node_modules folders. This is a cleanup step to remove unnecessary directories and reduce image size. | ||
RUN rm -rf /app/out/full/*/*/node_modules | ||
|
||
# Build the project using turbo | ||
# Start a new stage for building the project. This stage will compile and prepare the project for production. | ||
FROM pruner AS builder | ||
WORKDIR /app | ||
|
||
# Copy pruned lockfile and package.json files | ||
# This ensures that the builder stage has the exact dependencies needed for the project. | ||
COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml | ||
COPY --from=pruner /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml | ||
COPY --from=pruner /app/out/json/ . | ||
|
||
# Install dependencies for the pruned project | ||
# Utilize BuildKit's cache to speed up the dependency installation process. | ||
RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm install | ||
# TODO Readd: --frozen-lockfile when turbo prune is fixed https://github.com/vercel/turbo/issues/3382#issuecomment-1684098542 | ||
|
||
# Copy pruned source code | ||
# Bring in the necessary source code to the builder stage for compilation. | ||
COPY --from=pruner /app/out/full/ . | ||
|
||
# Build with turbo and prune dev dependencies | ||
# Use turbo to build the project, followed by pruning development dependencies to minimize the final image size. | ||
RUN turbo build --filter=${PROJECT}... | ||
RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm prune --prod --no-optional | ||
# Remove source files to further reduce the image size, keeping only the compiled output and necessary runtime files. | ||
RUN rm -rf ./**/*/src | ||
|
||
# Final production image | ||
# Start the final stage for the production-ready image. | ||
FROM base AS runner | ||
# Create a non-root user and group for better security. | ||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nodejs | ||
# Switch to the non-root user. | ||
USER nodejs | ||
|
||
WORKDIR /app | ||
# Copy the entire app directory, including node_modules and built code. This includes all necessary runtime files. | ||
COPY --from=builder --chown=nodejs:nodejs /app . | ||
|
||
WORKDIR /app/apps/${PROJECT} | ||
# Specify the command to run the application. Adjust the path as needed for your project's start script. | ||
CMD ["npm", "run", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** @type {import("eslint").Linter.Config} */ | ||
module.exports = { | ||
extends: ["@tietokilta/eslint-config/server.js"], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
project: true, | ||
}, | ||
rules: { | ||
"unicorn/prefer-node-protocol": "off", | ||
}, | ||
}; |
Oops, something went wrong.