Skip to content

Commit

Permalink
Merge pull request #4 from JoseRMorales/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
JoseRMorales authored Nov 13, 2024
2 parents 21d8d96 + 81127aa commit 04b83c8
Show file tree
Hide file tree
Showing 11 changed files with 1,467 additions and 25 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
docker
.git
**/*.env
**/*.env.local
**/*.env.example
50 changes: 50 additions & 0 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Docker Image CI

on:
push:
branches: ['main']
pull_request:
branches: ['main']

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
file: docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@ yarn-error.log*
# env files (can opt-in for commiting if needed)
.env.local
.env
.env.locals

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts


data.sql
roles.sql
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ Manage your team's stats via Supabase dashboard, and display them on your NextJS
![{E6BFACB0-626E-4CE0-A88B-5C3A45F2459D}](https://github.com/user-attachments/assets/10126cd6-4618-4a0d-83d5-422fafe533bd)


Mobile friendly.

## Attributions

[Default User Vectors by Vecteezy](https://www.vecteezy.com/free-vector/default-user)

## TODDs
## TODOs

- [ ] Demo
- [ ] Local deployment
- [ ] Avatar images
70 changes: 70 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# syntax=docker.io/docker/dockerfile:1

FROM node:20-alpine AS base

# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi


# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# 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 during the build.
ENV NEXT_TELEMETRY_DISABLED=1

RUN \
if [ -f yarn.lock ]; then yarn run build; \
elif [ -f package-lock.json ]; then npm run build; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
else echo "Lockfile not found." && exit 1; \
fi

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app

ENV NODE_ENV=production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED=1

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

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

# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next

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

USER nextjs

EXPOSE 3000

ENV PORT=3000

# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]
3 changes: 2 additions & 1 deletion next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
sassOptions: {
silenceDeprecations: ['legacy-js-api']
}
},
output: 'standalone'
}

export default nextConfig
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"postcss": "^8",
"prettier-eslint": "^16.3.0",
"sass": "^1.80.5",
"supabase": ">=1.8.1",
"supabase": "^1.207.9",
"tailwindcss": "^3.4.1",
"typescript": "^5"
}
Expand Down
26 changes: 13 additions & 13 deletions pnpm-lock.yaml

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

8 changes: 6 additions & 2 deletions src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,13 @@ export const getMatchDate = async (season: string, round: number) => {
const date = data?.date
const time = data?.time

if (!date || !time) return null

if (!time) return new Date(date)

const dateTime = new Date(`${date}T${time}`)

return data ? dateTime : null
return dateTime
}

export const getPlayers = async (season: string) => {
Expand Down Expand Up @@ -525,7 +529,7 @@ export async function login (state: FormState, formData: FormData) {
}
}

goToCurrentRound()
await goToCurrentRound()
}

export const logout = async () => {
Expand Down
15 changes: 8 additions & 7 deletions src/components/GameStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ const GameStats = async ({
<div className="flex flex-col text-center space-y-6 w-96 overflow-hidden">
<div className="text-4xl font-bold uppercase break-words">
<h3 className="text-2xl pb-4">
{matchDate?.toLocaleString('es-ES', {
month: 'short',
day: 'numeric',
year: 'numeric',
hour: 'numeric',
minute: 'numeric'
})}
{matchDate &&
matchDate?.toLocaleString('es-ES', {
month: 'short',
day: 'numeric',
year: 'numeric',
hour: 'numeric',
minute: 'numeric'
})}
</h3>
<h1 className="flex flex-col">
<span>{ownerTeam}</span>
Expand Down
Loading

0 comments on commit 04b83c8

Please sign in to comment.