Testing CI/CD

This commit is contained in:
2024-01-24 14:13:17 -05:00
parent 7119957c9e
commit a642ed87c4
20 changed files with 358 additions and 8 deletions

57
.drone.yml Normal file
View File

@@ -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

Binary file not shown.

Binary file not shown.

69
Dockerfile Normal file
View File

@@ -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"]

51
docker-compose.prod.yml Normal file
View File

@@ -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

47
docker-compose.yml Normal file
View File

@@ -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

View File

@@ -1,5 +1,12 @@
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = {}; const nextConfig = {
experimental: {
outputStandalone: true,
},
typescript: {
ignoreBuildErrors: true,
}
};
export default nextConfig; export default nextConfig;

View File

@@ -28,6 +28,7 @@
"@types/node": "^20", "@types/node": "^20",
"@types/react": "^18", "@types/react": "^18",
"@types/react-dom": "^18", "@types/react-dom": "^18",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"eslint": "^8", "eslint": "^8",
"eslint-config-next": "14.1.0", "eslint-config-next": "14.1.0",
"sass": "^1.70.0", "sass": "^1.70.0",

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.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.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 283 64"><path fill="black" d="M141 16c-11 0-19 7-19 18s9 18 20 18c7 0 13-3 16-7l-7-5c-2 3-6 4-9 4-5 0-9-3-10-7h28v-3c0-11-8-18-19-18zm-9 15c1-4 4-7 9-7s8 3 9 7h-18zm117-15c-11 0-19 7-19 18s9 18 20 18c6 0 12-3 16-7l-8-5c-2 3-5 4-8 4-5 0-9-3-11-7h28l1-3c0-11-8-18-19-18zm-10 15c2-4 5-7 10-7s8 3 9 7h-19zm-39 3c0 6 4 10 10 10 4 0 7-2 9-5l8 5c-3 5-9 8-17 8-11 0-19-7-19-18s8-18 19-18c8 0 14 3 17 8l-8 5c-2-3-5-5-9-5-6 0-10 4-10 10zm83-29v46h-9V5h9zM37 0l37 64H0L37 0zm92 5-27 48L74 5h10l18 30 17-30h10zm59 12v10l-3-1c-6 0-10 4-10 10v15h-9V17h9v9c0-5 6-9 13-9z"/></svg>

Before

Width:  |  Height:  |  Size: 629 B

View File

@@ -8,7 +8,7 @@ declare global {
var mongoose: any; 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) { if (!MONGO_URL) {
throw new Error( throw new Error(

View File

@@ -21,6 +21,6 @@
"@/*": ["./src/*"] "@/*": ["./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"] "exclude": ["node_modules"]
} }

126
yarn.lock
View File

@@ -21,7 +21,7 @@ __metadata:
languageName: node languageName: node
linkType: hard 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 version: 4.4.0
resolution: "@eslint-community/eslint-utils@npm:4.4.0" resolution: "@eslint-community/eslint-utils@npm:4.4.0"
dependencies: dependencies:
@@ -32,7 +32,7 @@ __metadata:
languageName: node languageName: node
linkType: hard 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 version: 4.10.0
resolution: "@eslint-community/regexpp@npm:4.10.0" resolution: "@eslint-community/regexpp@npm:4.10.0"
checksum: 2a6e345429ea8382aaaf3a61f865cae16ed44d31ca917910033c02dc00d505d939f10b81e079fa14d43b51499c640138e153b7e40743c4c094d9df97d4e56f7b checksum: 2a6e345429ea8382aaaf3a61f865cae16ed44d31ca917910033c02dc00d505d939f10b81e079fa14d43b51499c640138e153b7e40743c4c094d9df97d4e56f7b
@@ -313,6 +313,13 @@ __metadata:
languageName: node languageName: node
linkType: hard 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": "@types/json5@npm:^0.0.29":
version: 0.0.29 version: 0.0.29
resolution: "@types/json5@npm:0.0.29" resolution: "@types/json5@npm:0.0.29"
@@ -372,6 +379,13 @@ __metadata:
languageName: node languageName: node
linkType: hard 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:*": "@types/webidl-conversions@npm:*":
version: 7.0.3 version: 7.0.3
resolution: "@types/webidl-conversions@npm:7.0.3" resolution: "@types/webidl-conversions@npm:7.0.3"
@@ -398,6 +412,31 @@ __metadata:
languageName: node languageName: node
linkType: hard 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": "@typescript-eslint/parser@npm:^5.4.2 || ^6.0.0":
version: 6.19.0 version: 6.19.0
resolution: "@typescript-eslint/parser@npm:6.19.0" resolution: "@typescript-eslint/parser@npm:6.19.0"
@@ -426,6 +465,33 @@ __metadata:
languageName: node languageName: node
linkType: hard 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": "@typescript-eslint/types@npm:6.19.0":
version: 6.19.0 version: 6.19.0
resolution: "@typescript-eslint/types@npm:6.19.0" resolution: "@typescript-eslint/types@npm:6.19.0"
@@ -433,6 +499,13 @@ __metadata:
languageName: node languageName: node
linkType: hard 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": "@typescript-eslint/typescript-estree@npm:6.19.0":
version: 6.19.0 version: 6.19.0
resolution: "@typescript-eslint/typescript-estree@npm:6.19.0" resolution: "@typescript-eslint/typescript-estree@npm:6.19.0"
@@ -452,6 +525,42 @@ __metadata:
languageName: node languageName: node
linkType: hard 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": "@typescript-eslint/visitor-keys@npm:6.19.0":
version: 6.19.0 version: 6.19.0
resolution: "@typescript-eslint/visitor-keys@npm:6.19.0" resolution: "@typescript-eslint/visitor-keys@npm:6.19.0"
@@ -462,6 +571,16 @@ __metadata:
languageName: node languageName: node
linkType: hard 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": "@ungap/structured-clone@npm:^1.2.0":
version: 1.2.0 version: 1.2.0
resolution: "@ungap/structured-clone@npm:1.2.0" resolution: "@ungap/structured-clone@npm:1.2.0"
@@ -1860,7 +1979,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"ignore@npm:^5.2.0": "ignore@npm:^5.2.0, ignore@npm:^5.2.4":
version: 5.3.0 version: 5.3.0
resolution: "ignore@npm:5.3.0" resolution: "ignore@npm:5.3.0"
checksum: 2736da6621f14ced652785cb05d86301a66d70248597537176612bd0c8630893564bd5f6421f8806b09e8472e75c591ef01672ab8059c07c6eb2c09cefe04bf9 checksum: 2736da6621f14ced652785cb05d86301a66d70248597537176612bd0c8630893564bd5f6421f8806b09e8472e75c591ef01672ab8059c07c6eb2c09cefe04bf9
@@ -3805,6 +3924,7 @@ __metadata:
"@types/node": ^20 "@types/node": ^20
"@types/react": ^18 "@types/react": ^18
"@types/react-dom": ^18 "@types/react-dom": ^18
"@typescript-eslint/eslint-plugin": ^6.19.1
chart.js: ^4.4.1 chart.js: ^4.4.1
clsx: ^2.1.0 clsx: ^2.1.0
eslint: ^8 eslint: ^8