Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
FMK committed Apr 26, 2024
0 parents commit 8ce47a0
Show file tree
Hide file tree
Showing 35 changed files with 5,824 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

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

.idea/
.env
67 changes: 67 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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* ./
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
CMD HOSTNAME="0.0.0.0" node server.js
103 changes: 103 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# TuneQuest

Welcome to TuneQuest, a music guessing game that will put your music knowledge to the test!
Inspired by the board game Hitster, TuneQuest brings the excitement and challenge of guessing iconic tracks right to your table.
Are you a music aficionado? A casual listener? Or just someone who loves a good challenge? TuneQuest has something for everyone.
With the whole Spotify library to choose from, there's always a new challenge awaiting you.
How well do you know your favorite artists' discographies?
Can you pinpoint the exact year that legendary albums were released?
TuneQuest will push your memory and musical knowledge to the limit as you compete against friends or test your skills solo.

## Important Notes

Due to the Spotify API restrictions, the game can only be played by users with a Spotify Premium account.

## Hosted Version

You can play the game at [https://tunequest.rofln.de](https://tunequest.rofln.de) or just self-host your own version.
Currently the API Client is in development mode and I have not stress tested the limitations of the Spotify API in development mode.
If you encounter any issues, please let me know by opening an issue or a pull request.

## Create your own Cards

## Getting Started

If you want to run this project, you need to create a `.env` file in the root of the project with the following content:

```env
SPOTIFY_AUTHORIZE_URL=https://accounts.spotify.com/authorize
SPOTIFY_API_TOKEN_URL=https://accounts.spotify.com/api/token
SPOTIFY_REDIRECT_URI=http://localhost:3000/player
SPOTIFY_CLIENT_SECRET=xxx
SPOTIFY_CLIENT_ID=xxx
SPOTIFY_SCOPES=user-modify-playback-state streaming user-read-email user-read-private
TUNEQUEST_CREATE_URL=http://localhost:5173
```

To run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

To build the project:

```bash
npm run build
# or
yarn build
# or
pnpm build
# or
bun build
```

To run the non development server:

```bash
npm run start
# or
yarn start
# or
pnpm start
# or
bun start
```

## Docker

Build the docker image:
```bash
docker build -t tunequest .
```

Create the following `docker-compose.yaml` file:
```dockerfile
services:
tunequest:
container_name: tunequest
image: tunequest
restart: unless-stopped
ports:
- 3000:3000
```

Run the docker image with docker compose:
```bash
docker-compose up -d
```

# TODO
- [ ] Add compatibility with the original Hitster cards
- This is a painstaking process, as the original Hitster cards are not available online and I have to manually type them in.
- I will start with the cards I own and if you want to help me, please let me know.
- [ ] Add better error handling
- [ ] Improve the Docker Image to not bake in some of the environment variables
- [ ] Publish Docker image to Docker Hub
- If someone wants to help me with this, please let me know.
6 changes: 6 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "standalone",
};

export default nextConfig;
Loading

0 comments on commit 8ce47a0

Please sign in to comment.