diff --git a/gym-app.code-workspace b/gym-app.code-workspace deleted file mode 100644 index cb23fba..0000000 --- a/gym-app.code-workspace +++ /dev/null @@ -1,14 +0,0 @@ -{ - "folders": [ - { - "path": "." - }, - { - "path": "../ekl-logging" - }, - { - "path": "../queuenode" - } - ], - "settings": {} -} \ No newline at end of file diff --git a/package.json b/package.json index 9cd73a4..52ffbad 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,11 @@ "ci": "pnpm install --frozen-lockfile", "mongo-logs": "docker compose logs -f mongo1 | grep -oP '\"\\$date\":\"\\K[^\"]+|\"msg\":\"\\K[^\"]+' | sed -n 'N;s/\\n/ - /p'", "mongo-logs-health": "docker inspect --format='{{json .State.Health}}' gym-mongo1-1 | jq", - "sentry:sourcemaps": "sentry-cli sourcemaps inject --org thomfilgcom --project node ./build && sentry-cli sourcemaps upload --org thomfilgcom --project node ./build" + "sentry:sourcemaps": "sentry-cli sourcemaps inject --org thomfilgcom --project node ./build && sentry-cli sourcemaps upload --org thomfilgcom --project node ./build", + "kompose:convert:dev": "npm run docker:compose:merge:dev && kompose convert -f ./kubernetes/docker-compose.dev.yml --out kubernetes/dev", + "kompose:convert:prod": "npm run docker:compose:merge:prod && kompose convert -f ./kubernetes/docker-compose.prod.yml --out kubernetes/prod", + "docker:compose:merge:prod": "docker-compose -f docker-compose.yml -f docker-compose.prod.yml config > ./kubernetes/docker-compose.prod.yml", + "docker:compose:merge:dev": "docker-compose -f docker-compose.yml -f docker-compose.override.yml config > ./kubernetes/docker-compose.dev.yml" }, "dependencies": { "@emotion/react": "^11.13.0", diff --git a/scripts/init-repository.sh b/scripts/init-repository.sh index b04f7f1..6908fcc 100755 --- a/scripts/init-repository.sh +++ b/scripts/init-repository.sh @@ -5,7 +5,8 @@ source ./scripts/setup/doppler.sh source ./scripts/setup/mongo.sh source ./scripts/setup/nvm.sh source ./scripts/setup/pnpm.sh - +source ./scripts/setup/kompose.sh +source ./scripts/setup/kubernetes.sh # Ensure .nvmrc is available if [[ ! -f ".nvmrc" ]]; then @@ -16,20 +17,21 @@ fi installDocker installDockerCompose installDoppler - -configureDoppler +installKubernetes +installKompose installNVM installPnpm -pnpm install - # Check if .env file exists if [[ ! -f .env ]]; then # If not, copy .env.sample to .env cp .env.sample .env fi +configureDoppler + +pnpm install + genMongoKeyFile -# Use Doppler to run Docker Compose -doppler run -- docker compose up --build -d +pnpm dev -d \ No newline at end of file diff --git a/scripts/setup/kompose.sh b/scripts/setup/kompose.sh new file mode 100644 index 0000000..c2ce643 --- /dev/null +++ b/scripts/setup/kompose.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +installKompose() { + # Install Kompose if not already installed + if ! command -v kompose &> /dev/null + then + echo "Kompose not found! Installing..." + curl -L https://github.com/kubernetes/kompose/releases/download/v1.34.0/kompose-linux-amd64 -o kompose + chmod +x kompose + sudo mv kompose /usr/local/bin/kompose + else + echo "Kompose is already installed!" + fi + kompose version +} + diff --git a/scripts/setup/kubernetes.sh b/scripts/setup/kubernetes.sh new file mode 100755 index 0000000..1ae6365 --- /dev/null +++ b/scripts/setup/kubernetes.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Function to create MongoDB secrets +createSecrets() { + if kubectl get secret mongo-secret &> /dev/null; then + echo "Secret mongo-secret already exists" + else + echo "Creating mongo-secret" + export $(grep -v '^#' .env | xargs) + kubectl create secret generic mongo-secret \ + --from-literal=mongo-root-username=$MONGO_INITDB_ROOT_USERNAME \ + --from-literal=mongo-root-password=$MONGO_INITDB_ROOT_PASSWORD + fi +} + +installKubernetes() { + # Install kubectl if not already installed + if ! command -v kubectl &> /dev/null + then + echo "kubectl not found! Installing..." + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" + if [[ -f ./kubectl ]]; then + chmod +x ./kubectl + sudo mv ./kubectl /usr/local/bin/kubectl + echo "kubectl installed successfully!" + else + echo "Failed to download kubectl." + exit 1 + fi + else + echo "kubectl is already installed!" + fi + + kubectl version --client +}