chore: Create Readme
This commit is contained in:
parent
c3bf31b3d4
commit
757d790e54
5 changed files with 129 additions and 130 deletions
18
Dockerfile
18
Dockerfile
|
@ -1,5 +1,7 @@
|
||||||
|
# Use the desired base image
|
||||||
FROM node:21-alpine AS base
|
FROM node:21-alpine AS base
|
||||||
|
|
||||||
|
# Set the NODE_ENV to production
|
||||||
ENV NODE_ENV production
|
ENV NODE_ENV production
|
||||||
|
|
||||||
# Install dependencies only when needed
|
# Install dependencies only when needed
|
||||||
|
@ -10,31 +12,31 @@ WORKDIR /app
|
||||||
|
|
||||||
# Install dependencies based on the preferred package manager
|
# Install dependencies based on the preferred package manager
|
||||||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
|
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
|
||||||
RUN \
|
# Pass the Font Awesome token as a build argument
|
||||||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
|
ARG FONT_AWESOME_TOKEN
|
||||||
|
RUN echo "@fortawesome:registry=https://npm.fontawesome.com/" > ~/.npmrc \
|
||||||
|
&& echo "//npm.fontawesome.com/:_authToken=${FONT_AWESOME_TOKEN}" >> ~/.npmrc \
|
||||||
|
&& if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
|
||||||
elif [ -f package-lock.json ]; then npm ci; \
|
elif [ -f package-lock.json ]; then npm ci; \
|
||||||
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
|
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
|
||||||
else echo "Lockfile not found." && exit 1; \
|
else echo "Lockfile not found." && exit 1; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Rebuild the source code only when needed
|
# Rebuild the source code only when needed
|
||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Production image, copy all the files and run next
|
# Production image, copy all the files and run next
|
||||||
FROM base AS runner
|
FROM base AS runner
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN addgroup --system --gid 1001 nodejs
|
RUN addgroup --system --gid 1001 nodejs \
|
||||||
RUN adduser --system --uid 1001 solidjs
|
&& adduser --system --uid 1001 solidjs
|
||||||
|
|
||||||
COPY --from=builder /app/public ./public
|
COPY --from=builder /app/public ./public
|
||||||
|
|
||||||
COPY --from=builder --chown=solidjs:nodejs /app/.output ./.output
|
COPY --from=builder --chown=solidjs:nodejs /app/.output ./.output
|
||||||
COPY --from=builder --chown=solidjs:nodejs /app/.vinxi ./.vinxi
|
COPY --from=builder --chown=solidjs:nodejs /app/.vinxi ./.vinxi
|
||||||
|
|
||||||
|
@ -42,8 +44,8 @@ USER solidjs
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
|
# Set the default values for environment variables
|
||||||
ENV PORT 3000
|
ENV PORT 3000
|
||||||
# set hostname to localhost
|
|
||||||
ENV HOSTNAME "0.0.0.0"
|
ENV HOSTNAME "0.0.0.0"
|
||||||
|
|
||||||
CMD ["node", ".output/server/index.mjs"]
|
CMD ["node", ".output/server/index.mjs"]
|
||||||
|
|
133
README.md
133
README.md
|
@ -1,30 +1,125 @@
|
||||||
# SolidStart
|
# li'l Judd - Competitive Splatoon Bot
|
||||||
|
|
||||||
Everything you need to build a Solid project, powered by [`solid-start`](https://start.solidjs.com);
|
Welcome to li'l Judd, your go-to bot for enhancing your competitive Splatoon experience! Whether you're looking for match statistics, team coordination, or general Splatoon information, li'l Judd has got you covered.
|
||||||
|
|
||||||
## Creating a project
|
## Features
|
||||||
|
|
||||||
```bash
|
- **Match Statistics:** Track and analyze your Splatoon matches to improve your gameplay.
|
||||||
# create a new project in the current directory
|
- **Team Coordination:** Plan strategies and coordinate with your team more effectively.
|
||||||
npm init solid@latest
|
- **General Splatoon Information:** Get information about weapons, maps, and game updates.
|
||||||
|
|
||||||
# create a new project in my-app
|
## Getting Started
|
||||||
npm init solid@latest my-app
|
|
||||||
```
|
|
||||||
|
|
||||||
## Developing
|
To get started with li'l Judd, follow the instructions below.
|
||||||
|
|
||||||
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
### Prerequisites
|
||||||
|
|
||||||
```bash
|
- Node.js and pnpm installed (pnpm is strongly recommended for local development)
|
||||||
npm run dev
|
- Docker (optional, for containerized deployment)
|
||||||
|
- A Font Awesome subscription (required for the paid version used)
|
||||||
|
|
||||||
# or start the server and open the app in a new browser tab
|
### Installation
|
||||||
npm run dev -- --open
|
|
||||||
```
|
|
||||||
|
|
||||||
## Building
|
1. Clone the repository:
|
||||||
|
|
||||||
Solid apps are built with _adapters_, which optimise your project for deployment to different environments.
|
```bash
|
||||||
|
git clone https://git.moonleay.net/Websites/liljudd-website.git
|
||||||
|
```
|
||||||
|
|
||||||
By default, `npm run build` will generate a Node app that you can run with `npm start`. To use a different adapter, add it to the `devDependencies` in `package.json` and specify in your `vite.config.js`.
|
2. Install dependencies:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd lil-judd
|
||||||
|
|
||||||
|
# Install pnpm if not already installed
|
||||||
|
npm i -g pnpm
|
||||||
|
|
||||||
|
# Add token to authenticate when using installing Font Awesome packages
|
||||||
|
echo "@fortawesome:registry=https://npm.fontawesome.com/" > ~/.npmrc
|
||||||
|
echo "//npm.fontawesome.com/:_authToken=<YOUR_TOKEN>" >> ~/.npmrc
|
||||||
|
|
||||||
|
pnpm install
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Set up environment variables:
|
||||||
|
|
||||||
|
Create a `.env` file in the root directory and add the following variables:
|
||||||
|
|
||||||
|
```env
|
||||||
|
VITE_DISCORD_CLIENT=your_discord_client_id
|
||||||
|
VITE_DISCORD_CLIENT_SECRET=your_discord_client_secret
|
||||||
|
VITE_DISCORD_BOT_TOKEN=your_discord_bot_token
|
||||||
|
|
||||||
|
VITE_AUTH_SECRET=your_auth_secret
|
||||||
|
|
||||||
|
VITE_DATABASE_URL=your_database_url
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Development
|
||||||
|
|
||||||
|
Specify `VITE_AUTH_REDIRECT_PROXY_URL` only if necessary, particularly when setting up a reverse proxy to test authentication with callbacks to your development box. [Auth.js Docs Reference](https://authjs.dev/reference/nextjs/#redirectproxyurl)
|
||||||
|
|
||||||
|
The duplicate `DATABASE_URL` is only needed for Drizzle Studio.
|
||||||
|
|
||||||
|
```
|
||||||
|
VITE_AUTH_REDIRECT_PROXY_URL=your_auth_redirect_proxy_url
|
||||||
|
|
||||||
|
DATABASE_URL=your_database_url
|
||||||
|
```
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
|
||||||
|
- **Run development server:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm dev
|
||||||
|
# Use --host if you have set up a reverse proxy to test auth with callback to your dev box
|
||||||
|
pnpm dev --host
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Build for production:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm build
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Start production server:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm start
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Generate openapi types from specs:**
|
||||||
|
|
||||||
|
[openapi.json](https://raw.githubusercontent.com/discord/discord-api-spec/main/specs/openapi.json) (from discord-api-spec repo) -> [discord.d.ts](/src/types/discord.d.ts)
|
||||||
|
|
||||||
|
[liljudd.json](/public/api/specs/liljudd.json) -> [liljudd.d.ts](/src/types/liljudd.d.ts)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm discord-openapi-gen
|
||||||
|
pnpm liljudd-openapi-gen
|
||||||
|
```
|
||||||
|
|
||||||
|
**Drizzle Studio:**
|
||||||
|
|
||||||
|
Explore the database with ease through the intuitive web-based interface of Drizzle Studio, offering a visual and user-friendly way to interact with the data behind the scenes.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm drizzle-studio
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Docker Container:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker build --build-arg FONT_AWESOME_TOKEN=<YOUR_TOKEN> -t $image_name .
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
If you'd like to contribute to li'l Judd, feel free to open an issue or submit a pull request. Your contributions are highly appreciated!
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is licensed under the [MIT License](LICENSE).
|
||||||
|
|
||||||
|
Happy splatting! 🦑🎮
|
||||||
|
|
100
docker.sh
100
docker.sh
|
@ -1,100 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Script: your_script.sh
|
|
||||||
# Description: Brief description of what the script does.
|
|
||||||
# Usage: ./your_script.sh [options]
|
|
||||||
# Options:
|
|
||||||
# -h, --help Display this help message
|
|
||||||
# -o, --option Specify an option
|
|
||||||
|
|
||||||
# Function to display usage information
|
|
||||||
function show_usage() {
|
|
||||||
echo "Usage: $0 [options]"
|
|
||||||
echo "Options:"
|
|
||||||
echo " -h, --help Display this help message"
|
|
||||||
echo " -d, --deploy Delete possibly old images and container and deploy a new container"
|
|
||||||
echo " -f, --follow If deployed will follow the log output"
|
|
||||||
echo " -s, --stay If deployed will leave the container running instead of stopping it"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check for the number of arguments
|
|
||||||
# if [ "$#" -eq 0 ]; then
|
|
||||||
# show_usage
|
|
||||||
# exit 1
|
|
||||||
# fi
|
|
||||||
|
|
||||||
# Parse command-line options
|
|
||||||
while [[ "$#" -gt 0 ]]; do
|
|
||||||
case $1 in
|
|
||||||
-h|--help)
|
|
||||||
show_usage
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
-d|--deploy)
|
|
||||||
deploy=true
|
|
||||||
;;
|
|
||||||
-f|--follow)
|
|
||||||
follow=true
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unknown option: $1"
|
|
||||||
show_usage
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
image_name="solidjs-docker"
|
|
||||||
container_name="solidjs"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [ $deploy ]; then
|
|
||||||
# Check if the container exists
|
|
||||||
if [ "$(docker ps -a -q -f name=$container_name)" ]; then
|
|
||||||
if [ "$(docker ps -q -f name=$container_name)" ]; then
|
|
||||||
# Container exists, stop and remove it
|
|
||||||
echo "Stopping and removing existing container..."
|
|
||||||
echo "Stopped $(docker stop $container_name)"
|
|
||||||
else
|
|
||||||
echo "Removing existing container..."
|
|
||||||
fi
|
|
||||||
echo "Removed $(docker rm $container_name)"
|
|
||||||
|
|
||||||
|
|
||||||
docker rmi $(docker images -q $image_name)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run Docker container in the background and capture container ID
|
|
||||||
docker build --no-cache -t $image_name .
|
|
||||||
|
|
||||||
if [ $deploy ]; then
|
|
||||||
container_id=$(docker run --name $container_name -p 3000:3000 -d $image_name)
|
|
||||||
echo "Container deployed: $container_id"
|
|
||||||
elif [ !$follow ]; then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Function to display a message after interrupt
|
|
||||||
function exit_handler() {
|
|
||||||
# Clear the current line
|
|
||||||
echo -e "\033[2K"
|
|
||||||
|
|
||||||
if [ $stay ]; then
|
|
||||||
echo "Container is still running. To stop it, use:"
|
|
||||||
echo "docker stop $container_id"
|
|
||||||
else
|
|
||||||
echo "Stopping the container ..."
|
|
||||||
docker stop $container_id
|
|
||||||
echo "Stopped."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Register the exit_handler function to be called when the script receives the INT signal (Ctrl+C)
|
|
||||||
trap exit_handler INT
|
|
||||||
|
|
||||||
# Run Docker logs on the specified container
|
|
||||||
docker logs -f $container_id
|
|
|
@ -7,9 +7,10 @@
|
||||||
"start": "vinxi start",
|
"start": "vinxi start",
|
||||||
"lint": "eslint --fix \"**/*.{ts,tsx,js,jsx}\"",
|
"lint": "eslint --fix \"**/*.{ts,tsx,js,jsx}\"",
|
||||||
"push": "drizzle-kit push:pg",
|
"push": "drizzle-kit push:pg",
|
||||||
"discord-openapi-gen": "pnpm openapi-typescript https://raw.githubusercontent.com/discord/discord-api-spec/main/specs/openapi.json -o ./src/types/discord.d.ts",
|
"discord-openapi-gen": "openapi-typescript https://raw.githubusercontent.com/discord/discord-api-spec/main/specs/openapi.json -o ./src/types/discord.d.ts",
|
||||||
"liljudd-openapi-gen": "pnpm openapi-typescript ./public/api/specs/liljudd.json -o ./src/types/liljudd.d.ts",
|
"liljudd-openapi-gen": "openapi-typescript ./public/api/specs/liljudd.json -o ./src/types/liljudd.d.ts",
|
||||||
"typecheck": "tsc --noEmit --checkJs false --skipLibCheck"
|
"typecheck": "tsc --noEmit --checkJs false --skipLibCheck --preserveSymLinks",
|
||||||
|
"drizzle-studio": "drizzle-kit studio"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@auth/core": "^0.19.0",
|
"@auth/core": "^0.19.0",
|
||||||
|
|
|
@ -17,6 +17,7 @@ export const authOptions: SolidAuthConfig = {
|
||||||
adapter: DrizzleAdapter(db),
|
adapter: DrizzleAdapter(db),
|
||||||
secret: import.meta.env.VITE_AUTH_SECRET,
|
secret: import.meta.env.VITE_AUTH_SECRET,
|
||||||
callbacks: {
|
callbacks: {
|
||||||
|
// @ts-ignore
|
||||||
session: ({ session, user }) => {
|
session: ({ session, user }) => {
|
||||||
if (session?.user) {
|
if (session?.user) {
|
||||||
session.user.id = user.id;
|
session.user.id = user.id;
|
||||||
|
|
Loading…
Reference in a new issue