diff --git a/.dockerignore b/.dockerignore index 8e61eb35c..a1b521ac0 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,5 +2,4 @@ node_modules .tsbuildinfo **/node_modules -**/.tsbuildinfo -database-seeds \ No newline at end of file +**/.tsbuildinfo \ No newline at end of file diff --git a/.eslintignore b/.eslintignore index 1642c05af..808f9cc07 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ node_modules -js \ No newline at end of file +js +package.json \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..855758dfb --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +# if you don't do this +# a windows clone will fail +# because the .sh scripts will have their \n's turned into +# \r\n, and then bash will fail to run \r as a command. +# the future is now. +*.sh text eol=lf \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0a290ff55..d8654947f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ node_modules # PNPM noise .pnpm-debug.log +.pnpm-store # Compiled output js @@ -36,4 +37,7 @@ coverage out.* failed-tests.log -.tsbuildinfo \ No newline at end of file +.tsbuildinfo + +# bootstrap flag +I_HAVE_BOOTSTRAPPED_OK \ No newline at end of file diff --git a/Dockerfile.bootstrap b/Dockerfile.bootstrap new file mode 100644 index 000000000..fef9016dc --- /dev/null +++ b/Dockerfile.bootstrap @@ -0,0 +1,15 @@ +# Yes, I've made an entire docker container just to run a bash script +# instead of rewriting the script in a ~~real~~ cross-platform scripting language. +# This docker container **depends** on an external volume being mounted +# (see how it's used in docker-compose-dev.yml) +# and *intentionally* mutates state outside of its container. + +# I really do not care. +# Want it better? Do it yourself. +FROM node:16 as base + +RUN npm install --silent -g pnpm + +WORKDIR /app + +CMD ["bash", "_scripts/bootstrap.sh"] \ No newline at end of file diff --git a/Dockerfile.client b/Dockerfile.client new file mode 100644 index 000000000..fd1344019 --- /dev/null +++ b/Dockerfile.client @@ -0,0 +1,21 @@ +FROM node:16-alpine as base + +RUN npm install --silent -g pnpm + +FROM base AS build +WORKDIR /app + +COPY pnpm-lock.yaml . +COPY patches ./patches + +RUN pnpm fetch + +COPY client ./client +COPY common ./common +COPY *.json *.yaml ./ + +RUN pnpm --filter tachi-client... --filter . install --offline --frozen-lockfile + +WORKDIR /app/client + +CMD ["pnpm", "start"] \ No newline at end of file diff --git a/Dockerfile.seeds b/Dockerfile.seeds new file mode 100644 index 000000000..b6335fb4c --- /dev/null +++ b/Dockerfile.seeds @@ -0,0 +1,25 @@ +# no alpine here as we want bash + general nice-to-haves +FROM node:16 as base + +RUN npm install --silent -g pnpm + +FROM base AS build +WORKDIR /app + +COPY pnpm-lock.yaml . +COPY patches ./patches + +RUN pnpm fetch + +COPY database-seeds ./database-seeds +COPY common ./common +COPY *.json *.yaml ./ + +RUN pnpm --filter tachi-database-seeds... --filter . install --offline --frozen-lockfile + +WORKDIR /app/database-seeds + +# keep container alive indefinitely +# we just have this container so db-seeds maintainers have a nice "context" +# to work with +CMD ["tail", "-f", "/dev/null"] \ No newline at end of file diff --git a/Dockerfile.server b/Dockerfile.server index 4833fefc3..1af63fc10 100644 --- a/Dockerfile.server +++ b/Dockerfile.server @@ -2,6 +2,7 @@ # It does not spin up mongodb instances or redis instances, which the server # does need to boot. You should consider using docker-compose for this. +# base image FROM node:16-alpine as base ARG COMMIT_HASH ENV COMMIT_HASH=${COMMIT_HASH} @@ -9,7 +10,8 @@ ENV COMMIT_HASH=${COMMIT_HASH} RUN npm install --silent -g pnpm RUN apk add --no-cache git curl -FROM base AS build +# install dependencies +FROM base AS install WORKDIR /app COPY pnpm-lock.yaml . @@ -20,15 +22,30 @@ RUN pnpm fetch COPY server ./server COPY common ./common COPY *.json *.yaml ./ - RUN pnpm --filter tachi-server... --filter . install --offline --frozen-lockfile + +# development image, keeps installed dependencies +FROM install AS dev + +RUN git config --global --add safe.directory /app + +HEALTHCHECK --interval=15s --timeout=5s CMD curl -f http://localhost:8080/api/v1/status || exit 1 +WORKDIR /app/server + +ENV NODE_PATH=js/ +CMD ["pnpm", "dev"] + +# build source and dependencies +FROM install AS build + RUN pnpm --filter tachi-server... -r build -FROM base AS app +# built source only for production +FROM base AS prod COPY --from=build /app /app HEALTHCHECK --interval=15s --timeout=5s CMD curl -f http://localhost:8080/api/v1/status || exit 1 WORKDIR /app/server ENV NODE_PATH=js/ -CMD ["node", "js/main.js"] +CMD ["node", "js/main.js"] \ No newline at end of file diff --git a/_scripts/add-repo-to-monorepo.sh b/_scripts/add-repo-to-monorepo.sh deleted file mode 100755 index 86807280e..000000000 --- a/_scripts/add-repo-to-monorepo.sh +++ /dev/null @@ -1,29 +0,0 @@ -#! /bin/bash - -set -eo pipefail - -BRANCH="${2:-develop}" -PROJECT="$1" - -if [ -z "$PROJECT" ]; then - echo "Please pass a tachi-X repo to meld with this repository." - exit 1 -fi - -git remote add "$PROJECT" gh:/tng-dev/tachi-"$PROJECT" || echo "remote already mounted. continuing anyway." - -git fetch "$PROJECT" --no-tags - -git branch "$PROJECT-$BRANCH" "$PROJECT/$BRANCH" || echo "branch already exists. continuing anyway." - -git remote remove "$PROJECT" - -git switch "$PROJECT-$BRANCH" - -mkdir -p "$PROJECT" - -git filter-repo --to-subdirectory-filter "$PROJECT/" --refs "$PROJECT-$BRANCH" --force - -git switch master - -git merge --allow-unrelated-histories "$PROJECT-$BRANCH" \ No newline at end of file diff --git a/_scripts/bootstrap.sh b/_scripts/bootstrap.sh index 88ff7d2d7..5587527a9 100755 --- a/_scripts/bootstrap.sh +++ b/_scripts/bootstrap.sh @@ -2,6 +2,7 @@ set -eo pipefail + # https://stackoverflow.com/questions/59895/how-can-i-get-the-directory-where-a-bash-script-is-located-from-within-the-scrip # if you actually think bash is a good programming language you are # *straight up delusional* @@ -10,6 +11,11 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) cd "$SCRIPT_DIR"; cd ..; +if [ -e I_HAVE_BOOTSTRAPPED_OK ]; then + echo "Already bootstrapped." + exit 0 +fi + function mvExampleFiles { echo "Moving example config files into usable places..." @@ -54,12 +60,26 @@ function pnpmInstall { echo "Installed dependencies." } +function setIndexes { + echo "Setting indexes..." + + ( + cd server + pnpm run set-indexes + ) + + echo "Set." + +} + function syncDatabaseWithSeeds { echo "Syncing database with seeds..." - cd server + ( + cd server - pnpm run sync-database-local + pnpm run sync-database-local + ) echo "Synced." } @@ -67,23 +87,18 @@ function syncDatabaseWithSeeds { mvExampleFiles selfSignHTTPS pnpmInstall +setIndexes syncDatabaseWithSeeds -tput setaf 1 +echo "Bootstrap Complete." -cat << EOF -=== READ THIS YOU MUPPET === +cat << EOF > I_HAVE_BOOTSTRAPPED_OK +Tachi was bootstrapped here on $(date). -YOU ARE USING SELF-SIGNED HTTPS CERTIFICATES. -YOU WILL LIKELY HAVE TO GO TO HTTPS://127.0.0.1:8080 AFTER STARTING TACHI-SERVER. -TELL YOUR BROWSER THESE CERTIFICATES ARE TRUSTED! -OTHERWISE, THE CLIENT WILL FAIL TO LAUNCH, AND WILL JUST BE A WHITE PAGE! -EOF +The existence of this file stops Tachi from bootstrapping again. +There's nothing harmful about this -- you can bootstrap as much as you want! +We just don't want to necessarily bootstrap *each* time we boot Tachi. -tput sgr0 - -cat << EOF -Bootstrapped. -Launch the server with pnpm start-server. -Launch the client with pnpm start-client. +To bootstrap again (incase you think something has gone wrong) +Delete this file and re-run npm start. EOF diff --git a/client/package.json b/client/package.json index bb6d8080e..99f584f8b 100644 --- a/client/package.json +++ b/client/package.json @@ -35,6 +35,7 @@ "@fullcalendar/react": "^6.0.0", "@mui/material": "^5.11.1", "@nivo/bar": "0.79.1", + "@nivo/colors": "0.79.1", "@nivo/core": "0.79.0", "@nivo/line": "0.79.1", "@nivo/tooltip": "0.79.0", @@ -42,6 +43,7 @@ "@types/natural-compare": "^1.4.1", "@types/react-google-recaptcha": "2.1.2", "csstype": "3.1.1", + "d3-scale": "3.3.0", "deepmerge": "4.2.2", "dotenv": "6.2.0", "fast-json-stable-hash": "^1.0.3", diff --git a/client/src/app/pages/dashboard/import/SilentHookPage.tsx b/client/src/app/pages/dashboard/import/SilentHookPage.tsx index bf38ba053..9ce73d4b1 100644 --- a/client/src/app/pages/dashboard/import/SilentHookPage.tsx +++ b/client/src/app/pages/dashboard/import/SilentHookPage.tsx @@ -23,7 +23,7 @@ export default function SilentHookPage() { Download silent from{" "} Here - + {" "} and place all the .dll files in the same folder as{" "} popn22.dll.
diff --git a/client/src/lib/config.ts b/client/src/lib/config.ts index 1e1beefda..da98489be 100644 --- a/client/src/lib/config.ts +++ b/client/src/lib/config.ts @@ -55,11 +55,10 @@ try { ? `
You're in local development mode. -