Skip to content

Commit

Permalink
Merge pull request #59 from starpep-web/rewrite
Browse files Browse the repository at this point in the history
Rewrite to Next.js 14
  • Loading branch information
moonstar-x authored Nov 1, 2024
2 parents d00ec3f + 06acc63 commit aed9bf4
Show file tree
Hide file tree
Showing 541 changed files with 21,518 additions and 20,724 deletions.
21 changes: 10 additions & 11 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# Ignore everything by default
# Ignore everything by default.
*

# Allow the public project files.
# Manually add what to use.
!public
!src
!Dockerfile
!README.md
!package.json
!package-lock.json
!next-env.d.ts
!entrypoint.sh
!graphql-codegen.ts
!LICENSE
!next.config.js
!next-env.d.ts
!package*.json
!remote-schema.graphql
!tsconfig.json
!components
!lib
!pages
!public
!styles
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
.next
build
next-env.d.ts
src/lib/services/strapi/graphql/__generated__/*
6 changes: 4 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"extends": [
"greencoast/react-ts"
"@moonstar-x/eslint-config/rules/react/typescript"
],
"rules": {
"no-extra-parens": "off",
"camelcase": "off"
},
"globals": {
"RequestInit": true
}
}
63 changes: 63 additions & 0 deletions .github/workflows/callable-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Build Docker Image

on:
workflow_call:
inputs:
image_tag:
type: string
required: true
ghcr_username:
type: string
required: true
ghcr_image_name:
type: string
required: true
secrets:
ghcr_token:
required: true

jobs:
build:
name: Build Docker Image
runs-on: ubuntu-latest

steps:
- name: Checkout the Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Cache Docker Layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ inputs.ghcr_username }}
password: ${{ secrets.ghcr_token }}

- name: Build & Push Docker Image
id: docker_build
uses: docker/build-push-action@v6
env:
GHCR_IMAGE: ghcr.io/${{ inputs.ghcr_image_name }}
with:
context: .
push: true
tags: |
${{ env.GHCR_IMAGE }}:${{ inputs.image_tag }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/amd64,linux/arm64/v8

- name: Image Digest
run: echo ${{ steps.docker_build.outputs.digest }}
33 changes: 33 additions & 0 deletions .github/workflows/callable-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Run Tests

on:
workflow_call:

jobs:
test:
name: Run Tests
runs-on: ubuntu-latest

steps:
- name: Checkout the Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install Dependencies
run: npm ci

- name: Run Type Checks
run: npm run type-check

- name: Run Linter
run: npm run lint

- name: Run Tests
run: npm run test
14 changes: 14 additions & 0 deletions .github/workflows/on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: On Pull Request

on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened

jobs:
test:
name: Run Tests
uses: ./.github/workflows/callable-test.yml
23 changes: 23 additions & 0 deletions .github/workflows/on-push-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: On Push (Main)

on:
push:
branches:
- main

jobs:
test:
name: Run Tests
uses: ./.github/workflows/callable-test.yml

build:
name: Build Docker Image
uses: ./.github/workflows/callable-build.yml
needs:
- test
with:
ghcr_username: ${{ github.actor }}
ghcr_image_name: ${{ github.repository }}
image_tag: latest
secrets:
ghcr_token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ yarn-error.log*
# typescript
*.tsbuildinfo

# secrets
*.env
.idea
48 changes: 30 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,46 @@
# Build Stage
FROM node:16-alpine AS build
FROM node:20.18.0-alpine AS base

WORKDIR /tmp/app
FROM base AS deps

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

COPY package*.json ./
RUN npm ci

ENV BUILDING_STAGE true
FROM base AS build

ENV NODE_ENV=production
WORKDIR /tmp/app

COPY --from=deps /tmp/app/node_modules ./node_modules
COPY . .
RUN npm run build

# Image
FROM node:16-alpine
# Any NEXT_PUBLIC env variables must be added here for them to work.
ENV NEXT_PUBLIC_URL=NEXT_PUBLIC_URL
ENV NEXT_PUBLIC_DOWNLOADS_URL=NEXT_PUBLIC_DOWNLOADS_URL
ENV NEXT_PUBLIC_STRAPI_PROTO=NEXT_PUBLIC_STRAPI_PROTO
ENV NEXT_PUBLIC_STRAPI_HOST=NEXT_PUBLIC_STRAPI_HOST
ENV NEXT_PUBLIC_STRAPI_PORT=NEXT_PUBLIC_STRAPI_PORT

WORKDIR /opt/app
ENV NODE_ENV production
RUN npm run build

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
FROM base AS runner

COPY README.md Dockerfile ./
COPY --from=build /tmp/app/public ./public
COPY --from=build --chown=nextjs:nodejs /tmp/app/.next/standalone ./
COPY --from=build --chown=nextjs:nodejs /tmp/app/.next/static ./.next/static
RUN adduser -D starpep-web-frontend
USER starpep-web-frontend

USER nextjs
WORKDIR /opt/app

ENV PORT 3000
COPY --from=build --chown=starpep-web-frontend /tmp/app/public ./public
COPY --from=build --chown=starpep-web-frontend /tmp/app/.next/standalone ./
COPY --from=build --chown=starpep-web-frontend /tmp/app/.next/static ./.next/static

ENV NODE_ENV=production
ENV PORT=3000
EXPOSE 3000

COPY --chown=starpep-web-frontend entrypoint.sh ./
RUN chmod +x /opt/app/entrypoint.sh

ENTRYPOINT ["./entrypoint.sh"]
CMD ["node", "server.js"]
131 changes: 0 additions & 131 deletions Jenkinsfile

This file was deleted.

Loading

0 comments on commit aed9bf4

Please sign in to comment.