Skip to content

Commit

Permalink
run datagen outside of docker
Browse files Browse the repository at this point in the history
  • Loading branch information
PssbleTrngle committed Aug 18, 2023
1 parent aaf1be1 commit 6345256
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 35 deletions.
45 changes: 40 additions & 5 deletions .github/workflows/release-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,45 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('web/**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile --strict-peer-dependencies
working-directory: web
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Generate Data
run: pnpm gen
working-directory: web
env:
VANILLA_DATA: ${{ secrets.VANILLA_DATA }}
FORGE_DATA: ${{ secrets.FORGE_DATA }}
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_DOWNLOAD_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
Expand All @@ -39,8 +78,4 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
VANILLA_DATA=${{ secrets.VANILLA_DATA }}
FORGE_DATA=${{ secrets.FORGE_DATA }}
CURSEFORGE_TOKEN=${{ secrets.CURSEFORGE_DOWNLOAD_TOKEN }}
MODRINTH_TOKEN=${{ secrets.MODRINTH_TOKEN }}
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
33 changes: 7 additions & 26 deletions web/apps/next/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM node:20 AS base
FROM node:20-alpine AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
ENV CI=true

FROM base AS builder
#RUN apk add --no-cache libc6-compat
#RUN apk update
RUN apk add --no-cache libc6-compat
RUN apk update
# Set working directory
WORKDIR /app
RUN pnpm add -g turbo
Expand All @@ -16,30 +16,11 @@ RUN turbo prune --scope=next --docker
# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer

ENV NODE_GYP_FORCE_PYTHON=/usr/local/bin/python3.9

# required dependencies for node-canvas
RUN apt-get update
RUN apt-get install -y software-properties-common build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev pkg-config python3-launchpadlib

RUN add-apt-repository -y ppa:deadsnakes/ppa
RUN apt-get update
RUN apt-get install -y python3.9
RUN ls /usr/local/bin
RUN whereis python3.9
RUN /usr/local/bin/python3.9 -v

ARG GITHUB_TOKEN
ARG VANILLA_DATA
ARG FORGE_DATA
ARG CURSEFORGE_TOKEN
ARG MODRINTH_TOKEN

ENV GITHUB_TOKEN=$GITHUB_TOKEN
ENV VANILLA_DATA=$VANILLA_DATA
ENV FORGE_DATA=$FORGE_DATA
ENV CURSEFORGE_TOKEN=$CURSEFORGE_TOKEN
ENV MODRINTH_TOKEN=$MODRINTH_TOKEN

RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app

# First install the dependencies (as they change less often)
Expand All @@ -52,7 +33,7 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install -r --workspace-ro
COPY --from=builder /app/out/full/ .
RUN pnpm turbo run build --filter=next...

FROM node:20-alpine AS runner
FROM base AS runner
WORKDIR /app

# Don't run production as root
Expand Down
81 changes: 81 additions & 0 deletions web/apps/next/Dockerfile.full
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
FROM node:20 AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
ENV CI=true

FROM base AS builder
#RUN apk add --no-cache libc6-compat
#RUN apk update
# Set working directory
WORKDIR /app
RUN pnpm add -g turbo
COPY . .
RUN turbo prune --scope=next --docker

# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer

ENV NODE_GYP_FORCE_PYTHON=/usr/local/bin/python3.9

# required dependencies for node-canvas
RUN apt-get update
RUN apt-get install -y software-properties-common build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev pkg-config python3-launchpadlib

RUN add-apt-repository -y ppa:deadsnakes/ppa
RUN apt-get update
RUN apt-get install -y python3.9
RUN ls /usr/local/bin
RUN whereis python3.9
RUN /usr/local/bin/python3.9 -v

ARG GITHUB_TOKEN
ARG VANILLA_DATA
ARG FORGE_DATA
ARG CURSEFORGE_TOKEN
ARG MODRINTH_TOKEN

ENV GITHUB_TOKEN=$GITHUB_TOKEN
ENV VANILLA_DATA=$VANILLA_DATA
ENV FORGE_DATA=$FORGE_DATA
ENV CURSEFORGE_TOKEN=$CURSEFORGE_TOKEN
ENV MODRINTH_TOKEN=$MODRINTH_TOKEN
WORKDIR /app

# First install the dependencies (as they change less often)
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install -r --workspace-root

# Build the project
COPY --from=builder /app/out/full/ .
RUN pnpm turbo run build --filter=next...

FROM node:20-alpine AS runner
WORKDIR /app

# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs

COPY --from=installer /app/apps/next/next.config.js .
COPY --from=installer /app/apps/next/package.json .

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=installer --chown=nextjs:nodejs /app/apps/next/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/next/.next/static ./apps/next/.next/static
COPY --from=installer --chown=nextjs:nodejs /app/apps/next/public ./apps/next/public
COPY --from=installer --chown=nextjs:nodejs /app/apps/next/data ./apps/next/data
COPY --from=installer --chown=nextjs:nodejs /app/apps/next/lang ./apps/next/lang

EXPOSE 3000

# 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.
# RUN npx next telemetry disable

CMD ["node", "apps/next/server.js"]
1 change: 0 additions & 1 deletion web/apps/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"jest": "^29.6.2",
"jest-environment-jsdom": "^29.6.2",
"tsconfig": "workspace:*",
"datagen": "workspace:*",
"typescript": "^4.9.5"
}
}
3 changes: 0 additions & 3 deletions web/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6345256

Please sign in to comment.