-
Notifications
You must be signed in to change notification settings - Fork 157
Rb/bye bitnami #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Rb/bye bitnami #141
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d7b1901
use self defined charts instead of bitnami's since they are going away
rberrelleza 4c13cc4
Fixing yarn errors
jvc5546 ade554c
Added infrastructure chart as excetion to .oktetoignore
jvc5546 eb7cf55
Fix deployment issues on rb/bye-bitnami branch
oktetobot 7937a22
Fix e2e tests: Update Playwright Docker image from v1.52.0 to v1.55.0
oktetobot dc25c8f
Add mongodb auth
jvc5546 b6d95bb
Resolve merge conflict by deleting the files
jvc5546 625a027
Update .oktetoignore
jvc5546 7b427bc
Remove unnecessary line from .oktetoignore
jvc5546 dc82896
Remove unnecessary file
jvc5546 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
FROM node:20 | ||
|
||
WORKDIR /src | ||
# Enable Corepack and prepare Yarn 4.9.4 | ||
RUN corepack enable && corepack prepare yarn@4.9.4 --activate | ||
|
||
# Copy dependencies | ||
WORKDIR /src | ||
COPY package.json yarn.lock ./ | ||
RUN --mount=type=cache,target=/root/.yarn YARN_CACHE_FOLDER=/root/.yarn yarn install | ||
|
||
# Install using Yarn 4 with node_modules (disable PnP) | ||
RUN --mount=type=cache,target=/root/.yarn \ | ||
YARN_CACHE_FOLDER=/root/.yarn \ | ||
yarn config set nodeLinker node-modules && \ | ||
yarn install --immutable | ||
|
||
COPY . . | ||
CMD ["yarn", "start"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,51 @@ | ||
const mongo = require("mongodb").MongoClient; | ||
const { MongoClient } = require("mongodb"); | ||
|
||
const url = `mongodb://${process.env.MONGODB_USERNAME}:${encodeURIComponent(process.env.MONGODB_PASSWORD)}@${process.env.MONGODB_HOST}:27017/${process.env.MONGODB_DATABASE}`; | ||
const url = process.env.MONGODB_USERNAME && process.env.MONGODB_PASSWORD | ||
? `mongodb://${process.env.MONGODB_USERNAME}:${encodeURIComponent(process.env.MONGODB_PASSWORD)}@${process.env.MONGODB_HOST}:27017/${process.env.MONGODB_DATABASE}?authSource=admin` | ||
: `mongodb://${process.env.MONGODB_HOST}:27017/${process.env.MONGODB_DATABASE}`; | ||
|
||
var insert = function(collection, data, resolve, reject) { | ||
const d = require(data); | ||
d.results.forEach((doc) => { | ||
async function insertData(collection, dataPath) { | ||
const data = require(dataPath); | ||
data.results.forEach((doc) => { | ||
doc._id = doc.id; | ||
}); | ||
collection.insertMany(d.results, (err, r) => { | ||
if (err) { | ||
if (err.code != 11000) { | ||
return reject(err); | ||
} | ||
|
||
try { | ||
await collection.insertMany(data.results); | ||
console.log(`Inserted ${data.results.length} documents`); | ||
} catch (err) { | ||
if (err.code !== 11000) { | ||
throw err; | ||
} | ||
|
||
resolve(); | ||
}); | ||
console.log('Documents already exist, skipping insertion'); | ||
} | ||
} | ||
|
||
function loadWithRetry() { | ||
mongo.connect(url, { | ||
useUnifiedTopology: true, | ||
useNewUrlParser: true, | ||
connectTimeoutMS: 300, | ||
socketTimeoutMS: 300, | ||
}, (err, client) => { | ||
if (err) { | ||
console.error(`Error connecting, retrying in 300 msec: ${err}`); | ||
setTimeout(loadWithRetry, 300); | ||
return; | ||
} | ||
async function loadWithRetry() { | ||
const client = new MongoClient(url, { | ||
connectTimeoutMS: 30000, | ||
socketTimeoutMS: 30000, | ||
serverSelectionTimeoutMS: 30000, | ||
}); | ||
|
||
var promises = []; | ||
db = client.db(process.env.MONGODB_DATABASE); | ||
promises.push(new Promise((resolve, reject)=>{ | ||
insert(db.collection('catalog'), "./data/catalog.json", resolve, reject); | ||
})); | ||
try { | ||
console.log('Connecting to MongoDB...'); | ||
await client.connect(); | ||
console.log('Connected successfully'); | ||
|
||
Promise.all(promises) | ||
.then(function() { | ||
console.log('all loaded'); | ||
process.exit(0); | ||
}) | ||
.catch((err) => { | ||
console.error(`fail to load: ${err}`); | ||
process.exit(1); | ||
}); | ||
}); | ||
}; | ||
const db = client.db(process.env.MONGODB_DATABASE); | ||
await insertData(db.collection('catalog'), "./data/catalog.json"); | ||
|
||
console.log('All data loaded successfully'); | ||
await client.close(); | ||
process.exit(0); | ||
} catch (err) { | ||
console.error(`Error: ${err}`); | ||
await client.close(); | ||
|
||
console.log('Retrying in 3 seconds...'); | ||
setTimeout(loadWithRetry, 3000); | ||
} | ||
} | ||
|
||
loadWithRetry(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.