From 7d739dac17ecdbb360b4ec19bbcc0cda416fff70 Mon Sep 17 00:00:00 2001 From: Quinten <67589015+QuintenQVD0@users.noreply.github.com> Date: Sun, 18 Dec 2022 10:57:10 +0100 Subject: [PATCH 1/5] bastion: move to mongodb6 + python2 -> 3 + set mongodb to use always the same log file --- bot/bastion/Dockerfile | 6 +++--- bot/bastion/entrypoint.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bot/bastion/Dockerfile b/bot/bastion/Dockerfile index c23c30c..796e847 100644 --- a/bot/bastion/Dockerfile +++ b/bot/bastion/Dockerfile @@ -3,12 +3,12 @@ FROM --platform=$TARGETOS/$TARGETARCH node:18-bullseye LABEL author="Michael Parker" maintainer="parker@pterodactyl.io" ## install mongo -RUN wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | apt-key add - \ - && echo "deb http://repo.mongodb.org/apt/debian bullseye/mongodb-org/5.0 main" | tee /etc/apt/sources.list.d/mongodb-org-5.0.list \ +RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | apt-key add - \ + && echo "deb http://repo.mongodb.org/apt/debian bullseye/mongodb-org/6.0 main" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list \ && apt update \ && apt install -y mongodb-org mongodb-org-server mongodb-org-shell mongodb-org-mongos mongodb-org-tools \ ## install bastion reqs - && apt install -y python build-essential git libtool netcat ffmpeg iproute2 curl tzdata \ + && apt install -y python3 build-essential git libtool netcat ffmpeg iproute2 curl tzdata \ ## add container user && useradd -d /home/container -m container -s /bin/bash diff --git a/bot/bastion/entrypoint.sh b/bot/bastion/entrypoint.sh index 7859814..c747df6 100644 --- a/bot/bastion/entrypoint.sh +++ b/bot/bastion/entrypoint.sh @@ -10,10 +10,10 @@ MODIFIED_STARTUP=$(echo -e $(echo -e ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/ echo -e ":/home/container$ ${MODIFIED_STARTUP}" # start mongo -mongod --fork --dbpath /home/container/mongodb/ --port 27017 --logpath /home/container/mongod.log && until nc -z -v -w5 127.0.0.1 27017; do echo 'Waiting for mongodb connection...'; sleep 5; done +mongod --fork --dbpath /home/container/mongodb/ --port 27017 --logpath /home/container/mongod.log --logRotate reopen --logappend && until nc -z -v -w5 127.0.0.1 27017; do echo 'Waiting for mongodb connection...'; sleep 5; done # Run the Server eval ${MODIFIED_STARTUP} # stop mongo -mongo --eval \"db.getSiblingDB('admin').shutdownServer()\ +mongo --eval "db.getSiblingDB('admin').shutdownServer()" From 8b5acf69177a2102d25f79fd24ff8bc2a6c010f8 Mon Sep 17 00:00:00 2001 From: Quinten <67589015+QuintenQVD0@users.noreply.github.com> Date: Sun, 18 Dec 2022 11:23:08 +0100 Subject: [PATCH 2/5] Bastion: pritify entrypoint --- bot/bastion/entrypoint.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/bot/bastion/entrypoint.sh b/bot/bastion/entrypoint.sh index c747df6..e898b6d 100644 --- a/bot/bastion/entrypoint.sh +++ b/bot/bastion/entrypoint.sh @@ -1,4 +1,21 @@ #!/bin/bash +#Variables +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +clear +#show versions +echo -e "${BLUE}-------------------------------------------------${NC}" +echo -e "${YELLOW}BastionBot Installation${NC}" +echo -e "${BLUE}-------------------------------------------------${NC}" +echo -e "${YELLOW}MongoDB Version:${NC} " && mongod --version +echo -e "${YELLOW}NodeJS Version:${NC} " && node -v +echo -e "${YELLOW}Python Version:${NC} " && python3 --version +echo -e "${BLUE}-------------------------------------------------${NC}" + cd /home/container # Set environment variable that holds the Internal Docker IP @@ -7,12 +24,18 @@ export INTERNAL_IP # Replace Startup Variables MODIFIED_STARTUP=$(echo -e $(echo -e ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')) -echo -e ":/home/container$ ${MODIFIED_STARTUP}" +echo -e "${YELLOW}:/home/container${NC} ${MODIFIED_STARTUP}" # start mongo +echo -e "${BLUE}-------------------------------------------------${NC}" +echo -e "${YELLOW}starting MongoDB...${NC}" +echo -e "${BLUE}-------------------------------------------------${NC}" mongod --fork --dbpath /home/container/mongodb/ --port 27017 --logpath /home/container/mongod.log --logRotate reopen --logappend && until nc -z -v -w5 127.0.0.1 27017; do echo 'Waiting for mongodb connection...'; sleep 5; done # Run the Server +echo -e "${BLUE}-------------------------------------------------${NC}" +echo -e "${YELLOW}BastionBot starting...${NC}" +echo -e "${BLUE}-------------------------------------------------${NC}" eval ${MODIFIED_STARTUP} # stop mongo From 67177391f88b685fe0ec0ec0cf675164f94ce449 Mon Sep 17 00:00:00 2001 From: Quinten <67589015+QuintenQVD0@users.noreply.github.com> Date: Sun, 18 Dec 2022 11:26:46 +0100 Subject: [PATCH 3/5] bastion add npm update to the docker file --- bot/bastion/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/bot/bastion/Dockerfile b/bot/bastion/Dockerfile index 796e847..d50635c 100644 --- a/bot/bastion/Dockerfile +++ b/bot/bastion/Dockerfile @@ -9,6 +9,7 @@ RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | apt-key add - && apt install -y mongodb-org mongodb-org-server mongodb-org-shell mongodb-org-mongos mongodb-org-tools \ ## install bastion reqs && apt install -y python3 build-essential git libtool netcat ffmpeg iproute2 curl tzdata \ + && npm install -g npm@latest \ ## add container user && useradd -d /home/container -m container -s /bin/bash From 181059486165749519d9707833822d1495d157e0 Mon Sep 17 00:00:00 2001 From: Quinten <67589015+QuintenQVD0@users.noreply.github.com> Date: Sat, 24 Dec 2022 14:04:37 +0100 Subject: [PATCH 4/5] bastion: move images arround so it can be build for arm64. --- .github/workflows/bot.yml | 55 ++++++++++++++++++++------------------- bot/bastion/Dockerfile | 17 ++++++------ 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/.github/workflows/bot.yml b/.github/workflows/bot.yml index ba9b0fe..133cbe0 100644 --- a/.github/workflows/bot.yml +++ b/.github/workflows/bot.yml @@ -19,6 +19,7 @@ jobs: - parkertron - red - sinusbot + - bastion steps: - uses: actions/checkout@v3 - uses: docker/setup-buildx-action@v2 @@ -56,30 +57,30 @@ jobs: rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - pushAmd: - name: "yolks:bot_${{ matrix.tag }}" - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - tag: - - bastion - steps: - - uses: actions/checkout@v2 - - uses: docker/setup-buildx-action@v1 - with: - version: "v0.7.0" - buildkitd-flags: --debug - - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.REGISTRY_TOKEN }} - - uses: docker/build-push-action@v2 - with: - context: ./bot/${{ matrix.tag }} - file: ./bot/${{ matrix.tag }}/Dockerfile - platforms: linux/amd64 - push: true - tags: | - ghcr.io/parkervcp/yolks:bot_${{ matrix.tag }} + # pushAmd: + # name: "yolks:bot_${{ matrix.tag }}" + # runs-on: ubuntu-latest + # strategy: + # fail-fast: false + # matrix: + # tag: + # - bastion + # steps: + # - uses: actions/checkout@v2 + # - uses: docker/setup-buildx-action@v1 + # with: + # version: "v0.7.0" + # buildkitd-flags: --debug + # - uses: docker/login-action@v1 + # with: + # registry: ghcr.io + # username: ${{ github.repository_owner }} + # password: ${{ secrets.REGISTRY_TOKEN }} + # - uses: docker/build-push-action@v2 + # with: + # context: ./bot/${{ matrix.tag }} + # file: ./bot/${{ matrix.tag }}/Dockerfile + # platforms: linux/amd64 + # push: true + # tags: | + # ghcr.io/parkervcp/yolks:bot_${{ matrix.tag }} diff --git a/bot/bastion/Dockerfile b/bot/bastion/Dockerfile index d50635c..056a813 100644 --- a/bot/bastion/Dockerfile +++ b/bot/bastion/Dockerfile @@ -1,15 +1,14 @@ -FROM --platform=$TARGETOS/$TARGETARCH node:18-bullseye +FROM --platform=$TARGETOS/$TARGETARCH mongo:6-focal LABEL author="Michael Parker" maintainer="parker@pterodactyl.io" -## install mongo -RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | apt-key add - \ - && echo "deb http://repo.mongodb.org/apt/debian bullseye/mongodb-org/6.0 main" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list \ - && apt update \ - && apt install -y mongodb-org mongodb-org-server mongodb-org-shell mongodb-org-mongos mongodb-org-tools \ - ## install bastion reqs - && apt install -y python3 build-essential git libtool netcat ffmpeg iproute2 curl tzdata \ +## install nodejs 18 +RUN apt update && apt install --no-install-recommends -y curl \ + && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ + && apt install -y nodejs \ && npm install -g npm@latest \ + ## install bastion reqs + && apt install -y python3 build-essential git libtool netcat ffmpeg iproute2 tzdata \ ## add container user && useradd -d /home/container -m container -s /bin/bash @@ -18,4 +17,4 @@ ENV USER=container HOME=/home/container WORKDIR /home/container COPY ./entrypoint.sh /entrypoint.sh -CMD ["/bin/bash", "/entrypoint.sh"] +CMD ["/bin/bash", "/entrypoint.sh"] \ No newline at end of file From 4edd4e1e27512d55bf6fe869f308cbf54363c997 Mon Sep 17 00:00:00 2001 From: Quinten <67589015+QuintenQVD0@users.noreply.github.com> Date: Tue, 31 Jan 2023 17:08:50 +0100 Subject: [PATCH 5/5] bastion: change mongodb stop cmd --- bot/bastion/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/bastion/entrypoint.sh b/bot/bastion/entrypoint.sh index e898b6d..8a8604a 100644 --- a/bot/bastion/entrypoint.sh +++ b/bot/bastion/entrypoint.sh @@ -39,4 +39,4 @@ echo -e "${BLUE}-------------------------------------------------${NC}" eval ${MODIFIED_STARTUP} # stop mongo -mongo --eval "db.getSiblingDB('admin').shutdownServer()" +mongod --eval "db.adminCommand({ "shutdown" : 1 })"