-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Showing
14 changed files
with
198 additions
and
61 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 |
---|---|---|
|
@@ -4,8 +4,6 @@ | |
!.npmrc | ||
!turbo.json | ||
!/package.json | ||
!/pnpm-lock.yaml | ||
!/pnpm-workspace.yaml | ||
!/apps | ||
!/packages | ||
!/patches | ||
|
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
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 |
---|---|---|
|
@@ -28,44 +28,68 @@ jobs: | |
uses: cocogitto/[email protected] | ||
with: | ||
check-latest-tag-only: true | ||
# linter: | ||
# name: Lint Code Base | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Checkout Code | ||
# uses: actions/checkout@v4 | ||
# with: | ||
# # Full git history is needed to get a proper list of changed files within `super-linter` | ||
# fetch-depth: 0 | ||
# - name: Lint Code Base | ||
# uses: github/super-linter@v5 | ||
# env: | ||
# VALIDATE_ALL_CODEBASE: false | ||
# IGNORE_GENERATED_FILES: true | ||
# # FILTER_REGEX_EXCLUDE: CHANGELOG.md | ||
# DEFAULT_BRANCH: main | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# build: | ||
# name: Build and Test | ||
# timeout-minutes: 15 | ||
# runs-on: ubuntu-latest | ||
# # To use Remote Caching, uncomment the next lines and follow the steps below. | ||
# env: | ||
# TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | ||
# TURBO_TEAM: ${{ vars.TURBO_TEAM }} | ||
# linter: | ||
# name: Lint Code Base | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Checkout Code | ||
# uses: actions/checkout@v4 | ||
# with: | ||
# # Full git history is needed to get a proper list of changed files within `super-linter` | ||
# fetch-depth: 0 | ||
# - name: Lint Code Base | ||
# uses: github/super-linter@v5 | ||
# env: | ||
# VALIDATE_ALL_CODEBASE: false | ||
# IGNORE_GENERATED_FILES: true | ||
# # FILTER_REGEX_EXCLUDE: CHANGELOG.md | ||
# DEFAULT_BRANCH: main | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# build: | ||
# name: Build and Test | ||
# timeout-minutes: 15 | ||
# runs-on: ubuntu-latest | ||
# # To use Remote Caching, uncomment the next lines and follow the steps below. | ||
# env: | ||
# TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | ||
# TURBO_TEAM: ${{ vars.TURBO_TEAM }} | ||
|
||
# steps: | ||
# - name: Check out code | ||
# uses: actions/checkout@v4 | ||
# with: | ||
# fetch-depth: 2 | ||
# - uses: pnpm/action-setup@v2 | ||
# with: | ||
# version: 8 | ||
# - uses: actions/setup-node@v3 | ||
# with: | ||
# node-version: '20' | ||
# cache: 'pnpm' | ||
# - run: pnpm install | ||
# - run: pnpm build | ||
# - run: pnpm test:unit:coverage | ||
# steps: | ||
# - name: Check out code | ||
# uses: actions/checkout@v4 | ||
# with: | ||
# fetch-depth: 2 | ||
# - uses: pnpm/action-setup@v2 | ||
# with: | ||
# version: 8 | ||
# - uses: actions/setup-node@v3 | ||
# with: | ||
# node-version: '20' | ||
# cache: 'pnpm' | ||
# - run: pnpm install | ||
# - run: pnpm run build --filter=playground | ||
# - run: pnpm run test:unit:coverage --filter=playground | ||
|
||
build: | ||
name: Build and Test | ||
timeout-minutes: 15 | ||
runs-on: ubuntu-latest | ||
# To use Remote Caching, uncomment the next lines and follow the steps below. | ||
env: | ||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | ||
TURBO_TEAM: ${{ vars.TURBO_TEAM }} | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
- uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: latest | ||
- name: Install Dependencies | ||
run: bun install | ||
# - run: bun run check --filter=playground | ||
# - run: bun run lint --filter=playground | ||
- run: bun run build --filter=playground | ||
- run: bun run test:unit:coverage --filter=playground |
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,7 +1,7 @@ | ||
/* jshint esversion: 9 */ | ||
|
||
module.exports = { | ||
'*.{js,ts,json,svelte}': ['pnpm format', 'git add'], | ||
'./src/**/*.{svelte,ts}': ['pnpm format', 'git add', 'pnpm lint:fix'], | ||
'./.{ts,cjs,js}': ['pnpm lint:fix'] | ||
'*.{js,ts,json,svelte}': ['bun run format', 'git add'], | ||
'./src/**/*.{svelte,ts}': ['bun run format', 'git add', 'bun run lint:fix'], | ||
'./.{ts,cjs,js}': ['bun run lint:fix'] | ||
}; |
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
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
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
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
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
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
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
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,116 @@ | ||
ARG SCOPE=playground | ||
################################################################### | ||
# Stage 0: base image # | ||
################################################################### | ||
FROM node:20-slim AS base | ||
ENV GIT_SSL_NO_VERIFY 1 | ||
RUN apt-get update && apt-get install -y --no-install-recommends git tini | ||
|
||
ARG SCOPE | ||
ENV SCOPE=${SCOPE} | ||
|
||
#https://turbo.build/repo/docs/handbook/deploying-with-docker | ||
#https://github.com/vercel/turbo/tree/main/examples/with-docker | ||
|
||
# Install pnpm | ||
ENV PNPM_HOME="/root/.local/share/pnpm" | ||
ENV PATH="${PATH}:${PNPM_HOME}" | ||
SHELL ["/bin/bash", "-c"] | ||
RUN npm install --global pnpm \ | ||
&& SHELL=bash pnpm setup \ | ||
&& source /root/.bashrc | ||
|
||
################################################################### | ||
# Stage 1: Prune monorepo # | ||
################################################################### | ||
FROM base AS pruner | ||
|
||
WORKDIR /app | ||
RUN pnpm add -g turbo | ||
COPY . . | ||
RUN turbo prune --scope=${SCOPE} --docker | ||
|
||
################################################################### | ||
# Stage 2: Install dependencies # | ||
# Add lockfile and package.json's of isolated subworkspace # | ||
################################################################### | ||
FROM base AS builder | ||
|
||
WORKDIR /app | ||
# First install the dependencies (as they change less often) | ||
COPY .gitignore .gitignore | ||
COPY --from=pruner /app/out/json/ . | ||
COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml | ||
|
||
# https://playwright.dev/docs/browsers | ||
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD 1 | ||
|
||
RUN pnpm install | ||
|
||
# Build the project | ||
COPY --from=pruner /app/out/full/ . | ||
COPY --from=pruner /app/.git .git | ||
COPY turbo.json turbo.json | ||
|
||
# Uncomment and use build args to enable remote caching | ||
ARG TURBO_TEAM | ||
ENV TURBO_TEAM=$TURBO_TEAM | ||
|
||
ARG TURBO_TOKEN | ||
ENV TURBO_TOKEN=$TURBO_TOKEN | ||
|
||
# TODO: set any extra ENV needed for build | ||
# ENV ENCRYPTION_SECRET=encryption_secret_placeholder123 NEXTAUTH_URL=http://localhost:3000 NEXT_PUBLIC_VIEWER_URL=http://localhost:3001 | ||
RUN pnpm turbo run build --filter=${SCOPE}... | ||
|
||
################################################################### | ||
# Stage 4: Run the app (prod) # | ||
################################################################### | ||
# FROM gcr.io/distroless/nodejs:20 as final | ||
# FROM gcr.io/distroless/nodejs:20-debug as final | ||
FROM cgr.dev/chainguard/node:20 AS runner | ||
# FROM base AS runner | ||
|
||
WORKDIR /app | ||
ENV NODE_ENV production | ||
ARG SCOPE | ||
|
||
# copy tini | ||
COPY --from=builder --chown=node:node /usr/bin/tini /usr/bin/tini | ||
ENTRYPOINT ["/usr/bin/tini", "-s", "--", "/usr/bin/node"] | ||
|
||
# copy runtime needed config files??? | ||
COPY --from=builder --chown=node:node /app/apps/${SCOPE}/package.json . | ||
# COPY --from=builder --chown=node:node /app/config ./config | ||
|
||
# Automatically leverage output traces to reduce image size | ||
# https://nextjs.org/docs/advanced-features/output-file-tracing | ||
COPY --from=builder --chown=node:node /app/apps/playground/build ./build | ||
|
||
|
||
EXPOSE 3000 | ||
ENV PORT 3000 | ||
|
||
# Metadata params | ||
ARG DOCKER_REGISTRY=ghcr.io | ||
ARG VCS_CONTEXT_PATH=xmlking/spectacular | ||
ARG BUILD_TIME | ||
ARG BUILD_VERSION | ||
ARG VCS_REF=1 | ||
ARG VENDOR=xmlking | ||
|
||
# Metadata | ||
LABEL org.opencontainers.image.created=$BUILD_TIME \ | ||
org.opencontainers.image.name="${SCOPE}" \ | ||
org.opencontainers.image.title="${SCOPE}" \ | ||
org.opencontainers.image.description="Example of SvelteKit multi-stage docker build" \ | ||
org.opencontainers.image.url=https://github.com/$VCS_CONTEXT_PATH \ | ||
org.opencontainers.image.source=https://github.com/$VCS_CONTEXT_PATH \ | ||
org.opencontainers.image.revision=$VCS_REF \ | ||
org.opencontainers.image.version=$BUILD_VERSION \ | ||
org.opencontainers.image.authors=sumanth \ | ||
org.opencontainers.image.vendor=$VENDOR \ | ||
org.opencontainers.image.licenses=MIT \ | ||
org.opencontainers.image.documentation="docker run -it -e NODE_ENV=production -p 3000:3000 ${DOCKER_REGISTRY:+${DOCKER_REGISTRY}/}${VCS_CONTEXT_PATH}/${SCOPE}:${BUILD_VERSION}" | ||
|
||
CMD ["build"] |
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