diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..4a32dff --- /dev/null +++ b/.drone.yml @@ -0,0 +1,57 @@ +kind: pipeline +type: docker +name: Demo Deploy Pipeline + +workspace: + path: /drone/auth + +steps: +- name: Deploy Container + image: docker + privileged: true + commands: + - docker compose -f docker-compose.prod.yml build --pull --no-cache + - docker compose -f docker-compose.prod.yml up --remove-orphans --force-recreate --wait + volumes: + # - name: env-secrets + # path: /drone/auth/staging.env + - name: dockersock + path: /var/run/docker.sock + - name: dockerconfig + path: /drone/auth/.docker/config.json +- name: Send Status Notifications + image: plugins/webhook + privileged: true + settings: + urls: https://lab.mifi.dev/hooks/ccw34hdf7tgbjmzp96nptn938r + content_type: application/json + template: | + { + "icon_url":"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/apple/198/freezing-face_1f976.png", + "text": "[{{ repo.name }} - Build # {{ build.number }}] Staging Deploy {{ build.status }} {{#success build.status}}:tada:{{else}}:poop:{{/success}}", + "username":"DroneBot" + } + when: + status: + - success + - failure + +volumes: +- name: dockerconfig + host: + path: /volume1/docker/dockerconfig.json +- name: dockersock + host: + path: /var/run/docker.sock +- name: env-secrets + host: + path: /volume1/docker/beethoven/labs-auth/staging.env + +# depends_on: +# - Test Pipeline + +trigger: + branch: + - main + event: + - push diff --git a/.yarn/cache/@types-json-schema-npm-7.0.15-fd16381786-97ed0cb44d.zip b/.yarn/cache/@types-json-schema-npm-7.0.15-fd16381786-97ed0cb44d.zip new file mode 100644 index 0000000..dbab109 Binary files /dev/null and b/.yarn/cache/@types-json-schema-npm-7.0.15-fd16381786-97ed0cb44d.zip differ diff --git a/.yarn/cache/@types-semver-npm-7.5.6-9d2637fc95-563a0120ec.zip b/.yarn/cache/@types-semver-npm-7.5.6-9d2637fc95-563a0120ec.zip new file mode 100644 index 0000000..7d7ba19 Binary files /dev/null and b/.yarn/cache/@types-semver-npm-7.5.6-9d2637fc95-563a0120ec.zip differ diff --git a/.yarn/cache/@typescript-eslint-eslint-plugin-npm-6.19.1-e33b439de1-ad04000cd6.zip b/.yarn/cache/@typescript-eslint-eslint-plugin-npm-6.19.1-e33b439de1-ad04000cd6.zip new file mode 100644 index 0000000..96b7fc7 Binary files /dev/null and b/.yarn/cache/@typescript-eslint-eslint-plugin-npm-6.19.1-e33b439de1-ad04000cd6.zip differ diff --git a/.yarn/cache/@typescript-eslint-scope-manager-npm-6.19.1-ad7101299b-848cdebc16.zip b/.yarn/cache/@typescript-eslint-scope-manager-npm-6.19.1-ad7101299b-848cdebc16.zip new file mode 100644 index 0000000..bde241c Binary files /dev/null and b/.yarn/cache/@typescript-eslint-scope-manager-npm-6.19.1-ad7101299b-848cdebc16.zip differ diff --git a/.yarn/cache/@typescript-eslint-type-utils-npm-6.19.1-95d1c070fd-eab1a30f8d.zip b/.yarn/cache/@typescript-eslint-type-utils-npm-6.19.1-95d1c070fd-eab1a30f8d.zip new file mode 100644 index 0000000..0f93386 Binary files /dev/null and b/.yarn/cache/@typescript-eslint-type-utils-npm-6.19.1-95d1c070fd-eab1a30f8d.zip differ diff --git a/.yarn/cache/@typescript-eslint-types-npm-6.19.1-b1df73ad9d-598ce222b5.zip b/.yarn/cache/@typescript-eslint-types-npm-6.19.1-b1df73ad9d-598ce222b5.zip new file mode 100644 index 0000000..7c0f39c Binary files /dev/null and b/.yarn/cache/@typescript-eslint-types-npm-6.19.1-b1df73ad9d-598ce222b5.zip differ diff --git a/.yarn/cache/@typescript-eslint-typescript-estree-npm-6.19.1-559df34951-fb71a14aee.zip b/.yarn/cache/@typescript-eslint-typescript-estree-npm-6.19.1-559df34951-fb71a14aee.zip new file mode 100644 index 0000000..75d27ea Binary files /dev/null and b/.yarn/cache/@typescript-eslint-typescript-estree-npm-6.19.1-559df34951-fb71a14aee.zip differ diff --git a/.yarn/cache/@typescript-eslint-utils-npm-6.19.1-0ea17c27eb-fe72e75c3e.zip b/.yarn/cache/@typescript-eslint-utils-npm-6.19.1-0ea17c27eb-fe72e75c3e.zip new file mode 100644 index 0000000..ac803fe Binary files /dev/null and b/.yarn/cache/@typescript-eslint-utils-npm-6.19.1-0ea17c27eb-fe72e75c3e.zip differ diff --git a/.yarn/cache/@typescript-eslint-visitor-keys-npm-6.19.1-e80d067b31-bdf057a42e.zip b/.yarn/cache/@typescript-eslint-visitor-keys-npm-6.19.1-e80d067b31-bdf057a42e.zip new file mode 100644 index 0000000..1197bd2 Binary files /dev/null and b/.yarn/cache/@typescript-eslint-visitor-keys-npm-6.19.1-e80d067b31-bdf057a42e.zip differ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2374ea2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,69 @@ +ARG MONGO_ENTRY_FILE +ARG MONGO_VERSION=latest + +## mongo build stage +FROM mongo:${MONGO_VERSION} AS database +ARG MONGO_ENTRY_FILE=${MONGO_ENTRY_FILE:-latest} +# COPY docker-entrypoint-initdb.d/mongo-init-${MONGO_ENTRY_FILE}.sh ./docker-entrypoint-initdb.d/mongo-init.sh + +FROM node:18-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; \ + elif [ -f package-lock.json ]; then npm ci; \ + elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \ + else echo "Lockfile not found." && exit 1; \ + fi + +FROM base AS dev + +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + + + +# 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 yarn build + +# If using npm comment out above and use below instead +# RUN npm run build + +# Production image, copy all the files and run next +FROM base AS runner +WORKDIR /app + +# 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 + +# 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 + +CMD ["node", "server.js"] \ No newline at end of file diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 0000000..a3ea425 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,51 @@ +version: "3.8" +services: + mongo: + container_name: mongo + build: + context: . + target: database + args: + - MONGO_ENTRY_FILE=4.4 + - MONGO_VERSION=4.4 + networks: + - walden-backend + volumes: + - 'db:/data/db' + - 'db:/data/configdb' + restart: unless-stopped + + frontend: + container_name: frontend + build: + context: . + target: base + restart: always + environment: + - NODE_ENV=production + ports: + - 3000:3000 + labels: + - 'traefik.enable=true' + - 'traefik.docker.network=docknet' + - 'traefik.http.routers.labs-bopeep.rule=Host(`mifi.dev`) && PathPrefix(`/bopeep`)' + - 'traefik.http.routers.labs-bopeep.entrypoints=websecure' + - 'traefik.http.routers.labs-bopeep.tls=true' + - 'traefik.http.routers.labs-bopeep.tls.certresolver=letsencrypt' + - 'traefik.http.routers.labs-bopeep.service=labs-bopeep-service' + - 'traefik.http.services.labs-bopeep-service.loadbalancer.server.port=3000' + networks: + - walden-backend + - docknet + +networks: + walden-backend: + driver: bridge + external: false + docknet: + name: docknet + external: true + +volumes: + db: + external: false diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..47ab4ac --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,47 @@ +version: "3.8" +services: + mongo: + container_name: mongo + build: + context: . + target: database + args: + - MONGO_ENTRY_FILE=4.4 + - MONGO_VERSION=4.4 + networks: + - walden-backend + volumes: + - 'db:/data/db' + - 'db:/data/configdb' + restart: unless-stopped + + frontend: + container_name: frontend + build: + context: . + target: dev + restart: always + command: yarn dev + environment: + - NODE_ENV=development + volumes: + - .:/app + - /app/node_modules + - /app/.next + ports: + - 3000:3000 + networks: + - walden-backend + - labs-net + +networks: + walden-backend: + driver: bridge + external: false + labs-net: + name: labs-net + external: true + +volumes: + db: + external: false diff --git a/next.config.mjs b/next.config.mjs index 81aa05b..2dda15e 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,5 +1,12 @@ /** @type {import('next').NextConfig} */ -const nextConfig = {}; +const nextConfig = { + experimental: { + outputStandalone: true, + }, + typescript: { + ignoreBuildErrors: true, + } +}; export default nextConfig; diff --git a/package.json b/package.json index be5bf5a..c1f4d50 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", + "@typescript-eslint/eslint-plugin": "^6.19.1", "eslint": "^8", "eslint-config-next": "14.1.0", "sass": "^1.70.0", diff --git a/public/next.svg b/public/next.svg deleted file mode 100644 index 5174b28..0000000 --- a/public/next.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/vercel.svg b/public/vercel.svg deleted file mode 100644 index d2f8422..0000000 --- a/public/vercel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/app/lib/db/connection.ts b/src/app/lib/db/connection.ts index d358b64..f93d3d6 100644 --- a/src/app/lib/db/connection.ts +++ b/src/app/lib/db/connection.ts @@ -8,7 +8,7 @@ declare global { var mongoose: any; } -const MONGO_URL = process.env.MONGO_URL || 'mongodb://localhost:27017/bopeep'; +const MONGO_URL = process.env.MONGO_URL || 'mongodb://mongo:27017/bopeep'; if (!MONGO_URL) { throw new Error( diff --git a/tsconfig.json b/tsconfig.json index 7b28589..250f47b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,6 +21,6 @@ "@/*": ["./src/*"] } }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "src/app/lib/db/seedDb.js"], "exclude": ["node_modules"] } diff --git a/yarn.lock b/yarn.lock index 9a3d21f..cdeb588 100644 --- a/yarn.lock +++ b/yarn.lock @@ -21,7 +21,7 @@ __metadata: languageName: node linkType: hard -"@eslint-community/eslint-utils@npm:^4.2.0": +"@eslint-community/eslint-utils@npm:^4.2.0, @eslint-community/eslint-utils@npm:^4.4.0": version: 4.4.0 resolution: "@eslint-community/eslint-utils@npm:4.4.0" dependencies: @@ -32,7 +32,7 @@ __metadata: languageName: node linkType: hard -"@eslint-community/regexpp@npm:^4.6.1": +"@eslint-community/regexpp@npm:^4.5.1, @eslint-community/regexpp@npm:^4.6.1": version: 4.10.0 resolution: "@eslint-community/regexpp@npm:4.10.0" checksum: 2a6e345429ea8382aaaf3a61f865cae16ed44d31ca917910033c02dc00d505d939f10b81e079fa14d43b51499c640138e153b7e40743c4c094d9df97d4e56f7b @@ -313,6 +313,13 @@ __metadata: languageName: node linkType: hard +"@types/json-schema@npm:^7.0.12": + version: 7.0.15 + resolution: "@types/json-schema@npm:7.0.15" + checksum: 97ed0cb44d4070aecea772b7b2e2ed971e10c81ec87dd4ecc160322ffa55ff330dace1793489540e3e318d90942064bb697cc0f8989391797792d919737b3b98 + languageName: node + linkType: hard + "@types/json5@npm:^0.0.29": version: 0.0.29 resolution: "@types/json5@npm:0.0.29" @@ -372,6 +379,13 @@ __metadata: languageName: node linkType: hard +"@types/semver@npm:^7.5.0": + version: 7.5.6 + resolution: "@types/semver@npm:7.5.6" + checksum: 563a0120ec0efcc326567db2ed920d5d98346f3638b6324ea6b50222b96f02a8add3c51a916b6897b51523aad8ac227d21d3dcf8913559f1bfc6c15b14d23037 + languageName: node + linkType: hard + "@types/webidl-conversions@npm:*": version: 7.0.3 resolution: "@types/webidl-conversions@npm:7.0.3" @@ -398,6 +412,31 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/eslint-plugin@npm:^6.19.1": + version: 6.19.1 + resolution: "@typescript-eslint/eslint-plugin@npm:6.19.1" + dependencies: + "@eslint-community/regexpp": ^4.5.1 + "@typescript-eslint/scope-manager": 6.19.1 + "@typescript-eslint/type-utils": 6.19.1 + "@typescript-eslint/utils": 6.19.1 + "@typescript-eslint/visitor-keys": 6.19.1 + debug: ^4.3.4 + graphemer: ^1.4.0 + ignore: ^5.2.4 + natural-compare: ^1.4.0 + semver: ^7.5.4 + ts-api-utils: ^1.0.1 + peerDependencies: + "@typescript-eslint/parser": ^6.0.0 || ^6.0.0-alpha + eslint: ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: ad04000cd6c15d864ff92655baa3aec99bb0ccf4714fedd145fedde60a27590a5feafe480beb2f0f3864b416098bde1e9431bada7480eb7ca4efad891e1d2f6f + languageName: node + linkType: hard + "@typescript-eslint/parser@npm:^5.4.2 || ^6.0.0": version: 6.19.0 resolution: "@typescript-eslint/parser@npm:6.19.0" @@ -426,6 +465,33 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/scope-manager@npm:6.19.1": + version: 6.19.1 + resolution: "@typescript-eslint/scope-manager@npm:6.19.1" + dependencies: + "@typescript-eslint/types": 6.19.1 + "@typescript-eslint/visitor-keys": 6.19.1 + checksum: 848cdebc16a3803e8a6d6035a7067605309a652bb2425f475f755b5ace4d80d2c17c8c8901f0f4759556da8d0a5b71024d472b85c3f3c70d0e6dcfe2a972ef35 + languageName: node + linkType: hard + +"@typescript-eslint/type-utils@npm:6.19.1": + version: 6.19.1 + resolution: "@typescript-eslint/type-utils@npm:6.19.1" + dependencies: + "@typescript-eslint/typescript-estree": 6.19.1 + "@typescript-eslint/utils": 6.19.1 + debug: ^4.3.4 + ts-api-utils: ^1.0.1 + peerDependencies: + eslint: ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: eab1a30f8d85f7c6e2545de5963fbec2f3bb91913d59623069b4b0db372a671ab048c7018376fc853c3af06ea39417f3e7b27dd665027dd812347a5e64cecd77 + languageName: node + linkType: hard + "@typescript-eslint/types@npm:6.19.0": version: 6.19.0 resolution: "@typescript-eslint/types@npm:6.19.0" @@ -433,6 +499,13 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/types@npm:6.19.1": + version: 6.19.1 + resolution: "@typescript-eslint/types@npm:6.19.1" + checksum: 598ce222b59c20432d06f60703d0c2dd16d9b2151569c192852136c57b8188e3ef6ef9fddaa2c136c9a756fcc7d873c0e29ec41cfd340564842287ef7b4571cd + languageName: node + linkType: hard + "@typescript-eslint/typescript-estree@npm:6.19.0": version: 6.19.0 resolution: "@typescript-eslint/typescript-estree@npm:6.19.0" @@ -452,6 +525,42 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/typescript-estree@npm:6.19.1": + version: 6.19.1 + resolution: "@typescript-eslint/typescript-estree@npm:6.19.1" + dependencies: + "@typescript-eslint/types": 6.19.1 + "@typescript-eslint/visitor-keys": 6.19.1 + debug: ^4.3.4 + globby: ^11.1.0 + is-glob: ^4.0.3 + minimatch: 9.0.3 + semver: ^7.5.4 + ts-api-utils: ^1.0.1 + peerDependenciesMeta: + typescript: + optional: true + checksum: fb71a14aeee0468780219c5b8d39075f85d360b04ccd0ee88f4f0a615d2c232a6d3016e36d8c6eda2d9dfda86b4f4cc2c3d7582940fb29d33c7cf305e124d4e2 + languageName: node + linkType: hard + +"@typescript-eslint/utils@npm:6.19.1": + version: 6.19.1 + resolution: "@typescript-eslint/utils@npm:6.19.1" + dependencies: + "@eslint-community/eslint-utils": ^4.4.0 + "@types/json-schema": ^7.0.12 + "@types/semver": ^7.5.0 + "@typescript-eslint/scope-manager": 6.19.1 + "@typescript-eslint/types": 6.19.1 + "@typescript-eslint/typescript-estree": 6.19.1 + semver: ^7.5.4 + peerDependencies: + eslint: ^7.0.0 || ^8.0.0 + checksum: fe72e75c3ea17a85772b83f148555ea94ff5d55d13586f3fc038833197a74f8071e14c2bbf1781c40eec20005f052f4be2513a725eea82a15da3cb9af3046c70 + languageName: node + linkType: hard + "@typescript-eslint/visitor-keys@npm:6.19.0": version: 6.19.0 resolution: "@typescript-eslint/visitor-keys@npm:6.19.0" @@ -462,6 +571,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/visitor-keys@npm:6.19.1": + version: 6.19.1 + resolution: "@typescript-eslint/visitor-keys@npm:6.19.1" + dependencies: + "@typescript-eslint/types": 6.19.1 + eslint-visitor-keys: ^3.4.1 + checksum: bdf057a42e776970a89cdd568e493e3ea7ec085544d8f318d33084da63c3395ad2c0fb9cef9f61ceeca41f5dab54ab064b7078fe596889005e412ec74d2d1ae4 + languageName: node + linkType: hard + "@ungap/structured-clone@npm:^1.2.0": version: 1.2.0 resolution: "@ungap/structured-clone@npm:1.2.0" @@ -1860,7 +1979,7 @@ __metadata: languageName: node linkType: hard -"ignore@npm:^5.2.0": +"ignore@npm:^5.2.0, ignore@npm:^5.2.4": version: 5.3.0 resolution: "ignore@npm:5.3.0" checksum: 2736da6621f14ced652785cb05d86301a66d70248597537176612bd0c8630893564bd5f6421f8806b09e8472e75c591ef01672ab8059c07c6eb2c09cefe04bf9 @@ -3805,6 +3924,7 @@ __metadata: "@types/node": ^20 "@types/react": ^18 "@types/react-dom": ^18 + "@typescript-eslint/eslint-plugin": ^6.19.1 chart.js: ^4.4.1 clsx: ^2.1.0 eslint: ^8