Skip to content

Commit

Permalink
V0.1.12 - General house keeping stuff (#17)
Browse files Browse the repository at this point in the history
* General house keeping:

- Update chart to leverage Bitnami MongoDB 14.10.1
- Fix various JS vulnerabilities
- Update the dev scripts
- Add a publish script with steps to publish new image
  • Loading branch information
shuguet authored Feb 21, 2024
1 parent 96602f3 commit de82beb
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 73 deletions.
6 changes: 3 additions & 3 deletions charts/pacman/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
version: 0.1.11
appVersion: "0.1.11"
version: 0.1.12
appVersion: "0.1.12"
name: pacman
description: Pac-Man Demo App for Kubernetes
home: https://github.com/shuguet/pacman
Expand All @@ -21,6 +21,6 @@ maintainers:

dependencies:
- name: mongodb
version: 13.6.7
version: 14.10.1
repository: https://charts.bitnami.com/bitnami
condition: mongodb.enabled
157 changes: 95 additions & 62 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"dependencies": {
"body-parser": "^1.17.1",
"express": "^4.14.1",
"pug": "^3.0.2",
"mongodb": "^4.17.0"
"mongodb": "^4.17.0",
"pug": "^3.0.2"
},
"devDependencies": {
"nodemon": "^2.0.20"
"nodemon": "^3.0.3"
}
}
21 changes: 16 additions & 5 deletions scripts/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ set -o nounset
LOCAL_WORKDIR=$(pwd)
DOCKER_NETWORK_NAME='pacman-dev'
MONGO_CONTAINER_NAME='mongo'
MONGO_CONTAINER_IMAGE='mongo:latest'
MONGO_WORKDIR='/data/db'
MONGO_CONTAINER_IMAGE='registry-1.docker.io/bitnami/mongodb:7.0.5-debian-11-r22'
MONGO_BITNAMI_SCRIPTS='/bitnami/scripts'
MONGO_WORKDIR='/bitnami/mongodb'
PACMAN_CONTAINER_NAME='pacman'
PACMAN_CONTAINER_IMAGE='pacman'
PACMAN_WORKDIR='/usr/src/app'
Expand All @@ -55,8 +56,18 @@ docker network create --driver bridge ${DOCKER_NETWORK_NAME}
TMP_DOCKER_VOL=$(docker volume create)
docker run --rm -d --name ${MONGO_CONTAINER_NAME} \
--network ${DOCKER_NETWORK_NAME} \
-e MONGO_INITDB_ROOT_USERNAME=${MONGO_AUTH_USER} \
-e MONGO_INITDB_ROOT_PASSWORD=${MONGO_AUTH_PWD} \
-e MONGODB_ROOT_USER=${MONGO_AUTH_USER} \
-e MONGODB_ROOT_PASSWORD=${MONGO_AUTH_PWD} \
-e BITNAMI_DEBUG="false" \
-e ALLOW_EMPTY_PASSWORD="no" \
-e MONGODB_SYSTEM_LOG_VERBOSITY="0" \
-e MONGODB_DISABLE_SYSTEM_LOG="no" \
-e MONGODB_DISABLE_JAVASCRIPT="no" \
-e MONGODB_ENABLE_JOURNAL="yes" \
-e MONGODB_PORT_NUMBER="27017" \
-e MONGODB_ENABLE_IPV6="no" \
-e MONGODB_ENABLE_DIRECTORY_PER_DB="no" \
-v ${LOCAL_WORKDIR}/scripts/mongo:${MONGO_BITNAMI_SCRIPTS}:ro \
-v ${TMP_DOCKER_VOL}:${MONGO_WORKDIR} \
${MONGO_CONTAINER_IMAGE}

Expand All @@ -78,5 +89,5 @@ docker run --rm -it --name ${PACMAN_CONTAINER_NAME} \
-e MONGO_AUTH_PWD=${MONGO_AUTH_PWD} \
-v ${LOCAL_WORKDIR}:${PACMAN_WORKDIR} \
-p ${PACMAN_LOCAL_PORT}:${PACMAN_CONTAINER_PORT} \
--entrypoint bash \
--entrypoint ash \
${PACMAN_CONTAINER_IMAGE}
2 changes: 2 additions & 0 deletions scripts/mongo/ping-mongodb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
mongosh $TLS_OPTIONS --port $MONGODB_PORT_NUMBER --eval "db.adminCommand('ping')"
12 changes: 12 additions & 0 deletions scripts/mongo/readiness-probe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
# Run the proper check depending on the version
[[ $(mongod -version | grep "db version") =~ ([0-9]+\.[0-9]+\.[0-9]+) ]] && VERSION=${BASH_REMATCH[1]}
. /opt/bitnami/scripts/libversion.sh
VERSION_MAJOR="$(get_sematic_version "$VERSION" 1)"
VERSION_MINOR="$(get_sematic_version "$VERSION" 2)"
VERSION_PATCH="$(get_sematic_version "$VERSION" 3)"
readiness_test='db.isMaster().ismaster || db.isMaster().secondary'
if [[ ( "$VERSION_MAJOR" -ge 5 ) || ( "$VERSION_MAJOR" -ge 4 && "$VERSION_MINOR" -ge 4 && "$VERSION_PATCH" -ge 2 ) ]]; then
readiness_test='db.hello().isWritablePrimary || db.hello().secondary'
fi
mongosh $TLS_OPTIONS --port $MONGODB_PORT_NUMBER --eval "${readiness_test}" | grep 'true'
2 changes: 2 additions & 0 deletions scripts/mongo/startup-probe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
mongosh $TLS_OPTIONS --port $MONGODB_PORT_NUMBER --eval 'db.hello().isWritablePrimary || db.hello().secondary' | grep 'true'
Loading

0 comments on commit de82beb

Please sign in to comment.