Merge pull request #110 from parkervcp/bastion-update-2

bastion: move to mongodb6 + python2 -> 3 + set mongodb to use always use the same log file + build for arm64
This commit is contained in:
Michael (Parker) Parker
2023-03-29 08:13:13 -04:00
committed by GitHub
3 changed files with 62 additions and 38 deletions

View File

@@ -19,6 +19,7 @@ jobs:
- parkertron - parkertron
- red - red
- sinusbot - sinusbot
- bastion
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2 - uses: docker/setup-buildx-action@v2
@@ -55,30 +56,30 @@ jobs:
rm -rf /tmp/.buildx-cache rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache
pushAmd: # pushAmd:
name: "yolks:bot_${{ matrix.tag }}" # name: "yolks:bot_${{ matrix.tag }}"
runs-on: ubuntu-latest # runs-on: ubuntu-latest
strategy: # strategy:
fail-fast: false # fail-fast: false
matrix: # matrix:
tag: # tag:
- bastion # - bastion
steps: # steps:
- uses: actions/checkout@v2 # - uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1 # - uses: docker/setup-buildx-action@v1
with: # with:
version: "v0.7.0" # version: "v0.7.0"
buildkitd-flags: --debug # buildkitd-flags: --debug
- uses: docker/login-action@v1 # - uses: docker/login-action@v1
with: # with:
registry: ghcr.io # registry: ghcr.io
username: ${{ github.repository_owner }} # username: ${{ github.repository_owner }}
password: ${{ secrets.REGISTRY_TOKEN }} # password: ${{ secrets.REGISTRY_TOKEN }}
- uses: docker/build-push-action@v2 # - uses: docker/build-push-action@v2
with: # with:
context: ./bot/${{ matrix.tag }} # context: ./bot/${{ matrix.tag }}
file: ./bot/${{ matrix.tag }}/Dockerfile # file: ./bot/${{ matrix.tag }}/Dockerfile
platforms: linux/amd64 # platforms: linux/amd64
push: true # push: true
tags: | # tags: |
ghcr.io/parkervcp/yolks:bot_${{ matrix.tag }} # ghcr.io/parkervcp/yolks:bot_${{ matrix.tag }}

View File

@@ -1,14 +1,14 @@
FROM --platform=$TARGETOS/$TARGETARCH node:18-bullseye FROM --platform=$TARGETOS/$TARGETARCH mongo:6-focal
LABEL author="Michael Parker" maintainer="parker@pterodactyl.io" LABEL author="Michael Parker" maintainer="parker@pterodactyl.io"
## install mongo ## install nodejs 18
RUN wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | apt-key add - \ RUN apt update && apt install --no-install-recommends -y curl \
&& 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 \ && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt update \ && apt install -y nodejs \
&& apt install -y mongodb-org mongodb-org-server mongodb-org-shell mongodb-org-mongos mongodb-org-tools \ && npm install -g npm@latest \
## install bastion reqs ## 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 tzdata \
## add container user ## add container user
&& useradd -d /home/container -m container -s /bin/bash && useradd -d /home/container -m container -s /bin/bash
@@ -17,4 +17,4 @@ ENV USER=container HOME=/home/container
WORKDIR /home/container WORKDIR /home/container
COPY ./entrypoint.sh /entrypoint.sh COPY ./entrypoint.sh /entrypoint.sh
CMD ["/bin/bash", "/entrypoint.sh"] CMD ["/bin/bash", "/entrypoint.sh"]

View File

@@ -1,4 +1,21 @@
#!/bin/bash #!/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 cd /home/container
# Set environment variable that holds the Internal Docker IP # Set environment variable that holds the Internal Docker IP
@@ -7,13 +24,19 @@ export INTERNAL_IP
# Replace Startup Variables # Replace Startup Variables
MODIFIED_STARTUP=$(echo -e $(echo -e ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')) 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 # 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 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 # Run the Server
echo -e "${BLUE}-------------------------------------------------${NC}"
echo -e "${YELLOW}BastionBot starting...${NC}"
echo -e "${BLUE}-------------------------------------------------${NC}"
eval ${MODIFIED_STARTUP} eval ${MODIFIED_STARTUP}
# stop mongo # stop mongo
mongo --eval \"db.getSiblingDB('admin').shutdownServer()\ mongod --eval "db.adminCommand({ "shutdown" : 1 })"