Docker image fix #158

Merged
Sirherobrine23 merged 4 commits from Docker_Image into main 2021-08-15 08:51:36 +00:00
8 changed files with 126 additions and 67 deletions
Showing only changes of commit f5a4ebcdc0 - Show all commits

View File

@@ -0,0 +1,60 @@
#!/usr/bin/env bash
set -ex
# Update Debian Repository
apt update
# Install Necessary Packages
apt install -y curl wget git zsh sudo unzip zip jq python python3 screen
# Install Build Dependencies
apt install -y ca-certificates make build-essential
# Install Libs
apt install -y procps lsb-release xdg-utils g++ libnss3 libatk-bridge2.0-0 gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxrandr2 libxrender1 libxss1 libxtst6 fonts-liberation libnss3 libgbm-dev
# Install Dependencies to diferent architectures
if ! [ "$(uname -m)" == "x86_64" ];then
mkdir -p /lib64
apt install -y qemu-user-static
wget -q "https://github.com/The-Bds-Maneger/external_files/raw/main/linux_libries.zip" -O /tmp/libries.zip
unzip -o /tmp/libries.zip -d /
rm -rfv /tmp/libries.zip
fi
# Install openjdk
case "$(uname -m)" in
x86_64 | aarch64 ) apt install -y openjdk-17*;;
* ) apt install -y openjdk-11*;;
esac
# Install nodejs from github release
get_current_node_version=$(curl -sL https://api.github.com/repos/nodejs/node/releases/latest | grep tag_name | cut -d '"' -f 4)
case $(uname -m) in
x86_64 ) wget -q https://nodejs.org/download/release/$get_current_node_version/node-$get_current_node_version-linux-x64.tar.xz -O /tmp/node.tar.xz;;
aarch64 ) wget -q https://nodejs.org/download/release/$get_current_node_version/node-$get_current_node_version-linux-arm64.tar.xz -O /tmp/node.tar.xz;;
armv7l ) wget -q https://nodejs.org/download/release/$get_current_node_version/node-$get_current_node_version-linux-armv7l.tar.xz -O /tmp/node.tar.xz;;
ppc64el ) wget -q https://nodejs.org/download/release/$get_current_node_version/node-$get_current_node_version-linux-ppc64le.tar.xz -O /tmp/node.tar.xz;;
s390x ) wget -q https://nodejs.org/download/release/$get_current_node_version/node-$get_current_node_version-linux-s390x.tar.xz -O /tmp/node.tar.xz;;
*) echo "Unsupported architecture"; exit 1;;
esac
tar -xJf /tmp/node.tar.xz -C /usr
rm -rf /tmp/node.tar.xz
# Setup non root user
useradd -m -p "$(perl -e 'print crypt($ARGV[0], "password")' "LucaA1113ba21")" "thebds"
addgroup thebds sudo
addgroup thebds root
usermod --shell /bin/bash thebds;
echo "thebds ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
# Remove Unnecessary Packages
apt autoremove -y
# Clean up apt cache
apt clean -y
# Remove Unnecessary Files
rm -rf /var/lib/apt/lists/* /root/.gnupg /tmp/*
# Sucessfully installed
exit 0

View File

@@ -1,31 +1,8 @@
const fetchSync = require("@the-bds-maneger/fetchsync")
const { writeFileSync } = require("fs");
const { exit } = require("process");
const { resolve } = require("path");
const { exec, execSync } = require("child_process");
const JSon_release = fetchSync("https://api.github.com/repos/Sirherobrine23/MSQ-files/releases").json()
writeFileSync("./Docker.js", JSON.stringify(JSon_release, null, 4))
const DockerLatestBin = [];
for (let _Check of JSon_release){
if (DockerLatestBin.length >= 1) break;
for (let _file of _Check.assets) {
if (`DockerRunBuild_${process.platform}_${process.arch}` === _file.name) {
DockerLatestBin.push(_Check);
break
}
}
}
if (!(DockerLatestBin.length >= 1)) exit(1);
const bin = fetchSync(`https://github.com/Sirherobrine23/MSQ-files/releases/download/${DockerLatestBin[0].tag_name}/DockerRunBuild_${process.platform}_${process.arch}`, true);
const binPath = resolve(__dirname, "../Docker.exe")
bin.save(binPath)
if (process.platform !== "win32") execSync(`chmod 777 "${binPath}"`)
const exe = exec(binPath)
function Log(data = ""){
data = data.split("\r").join("\n").split("\n").filter(_D => {return (_D !== "")})
for (let _log of data) console.log(_log);
}
exe.stdout.on("data", d => Log(d))
exe.stderr.on("data", d => Log(d))
exe.on("exit", c => exit(c))
#!/usr/bin/env node
const path = require("path");
process.env.Docker_Root = path.resolve(__dirname, "../");
(async () => {
const Docker = require("docker-run_build");
await Docker.Build();
await Docker.Run();
})();

2
.gitattributes vendored
View File

@@ -1 +1 @@
*.sh text eol=lf
*.sh text=lf eol=lf

9
.vscode/launch.json vendored
View File

@@ -4,13 +4,8 @@
{
"type": "node",
"request": "launch",
"name": "Build Dev Docker Image",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"Docker"
],
"port": 9229
"name": "Docker Build and Run",
"program": "${workspaceFolder}/.Build/DockerImage.js"
},
{
"type": "node",

View File

@@ -1,8 +1,10 @@
name: BdsCore
file: Dockerfile
tag: bdsmaneger/maneger:latestdebug
tag: bdsmaneger/core:dev
target: bdscore
buildx: true
buildx:
enable: true
platform: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
# Docker Run envs
env:

View File

@@ -1,37 +1,38 @@
# bdsmaneger/node_image
# Base
FROM debian:latest AS bdsbase
# Setup Bds Manerger Project Docker Base
FROM debian:testing AS bdsbase
USER root
ENV DEBIAN_FRONTEND=noninteractive DOCKER_IMAGE="true"
RUN apt update && \
apt -y install curl wget git zsh sudo unzip zip jq python python3 ca-certificates make build-essential screen procps lsb-release xdg-utils g++ openjdk-11-jdk openjdk-11-jre \
libnss3 libatk-bridge2.0-0 gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 \
libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 \
libxdamage1 libxext6 libxfixes3 libxrandr2 libxrender1 libxss1 libxtst6 fonts-liberation libappindicator1 libnss3 libgbm-dev && \
apt autoremove -y && \
apt clean -y && \
rm -rf /var/lib/apt/lists/* /root/.gnupg /tmp/library-scripts /tmp/* && \
case $(uname -m) in "x86_64") echo "Do not need dependency on the x86_64";; *) apt update; apt install -y qemu-user-static ;wget -q https://raw.githubusercontent.com/The-Bds-Maneger/external_files/main/linux_libries.zip -O /tmp/libries.zip ;unzip /tmp/libries.zip -d / ;rm -rfv /tmp/libries.zip ;mkdir -p /lib64 ;rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* /tmp/* ;;esac && \
wget -qO- https://raw.githubusercontent.com/Sirherobrine23/MSQ-files/main/DockerBuild/Build/bin/NodeInstall.sh | bash -; \
export username="thebds" && export password="123aa3456s7" && \
pass=$(perl -e 'print crypt($ARGV[0], "password")' $password); useradd -m -p "$pass" "$username"; addgroup ${username} sudo; addgroup ${username} root; \
usermod --shell /bin/bash --home /home/bds ${username}; echo "${username} ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
ENV DEBIAN_FRONTEND="noninteractive" DOCKER_IMAGE="true"
# bdsmaneger/core
# Bds Maneger Core
# Copy Docker Files
COPY .Build/Docker/* /tmp
# Configure BASE
RUN bash /tmp/Configure.sh
# Setup bdsmaneger/core
FROM bdsbase AS bdscore
RUN apt update && apt install -y nginx && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* /tmp/* /etc/nginx/sites-*/default && mkdir -p /home/bds/
# Copy Bds Maneger Core
COPY ./ /opt/bds_core/
WORKDIR /opt/bds_core/
RUN chmod -v 7777 /opt/bds_core && chown thebds:thebds -v /opt/bds_core; chmod a+x bin/* && npm install --force && chmod -Rv 7777 /home && chown thebds:thebds -Rv /home && chmod a+x bin/*; mkdir -vp /home/bds/bds_core
# Non Root User
# Set Non Root User
USER thebds
VOLUME [ "/home/bds/bds_core" ]
VOLUME [ "/home/thebds/bds_core" ]
ENV TELEGRAM_TOKEN="null" DESCRIPTION="running Minecraft Bedrock Server on the docker by Bds Manager" WORLD_NAME="Bds Maneger Docker" GAMEMODE="survival" DIFFICULTY="normal" XBOX_ACCOUNT="false" PLAYERS="13" SERVER="bedrock" ENABLE_COMMANDS="false" BDS_DOCKER_IMAGE="true"
# Set default ENVs to Bds Core
ENV PLAYERS="5" \
WORLD_NAME="The Ultimate Server" \
DESCRIPTION="running Minecraft Server on Bds Maneger by Bds Manager Project" \
GAMEMODE="survival" \
DIFFICULTY="normal" \
ENABLE_COMMANDS="false" \
ACCOUNT="false" \
SERVER="bedrock"
# Bds Maneger Core required ports
EXPOSE 19132/udp 19133/udp 1932/tcp
# Entrypint
WORKDIR /opt/bds_core/
ENTRYPOINT [ "node", "./bin/bds_maneger.js" ,"--DOCKER_IMAGE" ,"-s" ]
# Set Entrypint
ENTRYPOINT [ "node", "./bin/Docker.js" ]

23
package-lock.json generated
View File

@@ -36,6 +36,7 @@
"bds_maneger": "bin/bds_maneger.js"
},
"devDependencies": {
"docker-run_build": "github:Sirherobrine23/Docker-Run_Build#main",
"eslint": "^7.19.0",
"husky": "^7.0.0",
"nexe": "*",
@@ -1811,6 +1812,19 @@
"node": ">=8"
}
},
"node_modules/docker-run_build": {
"version": "1.0.0",
"resolved": "git+ssh://git@github.com/Sirherobrine23/Docker-Run_Build.git#1b6e28d3ec1ff635c7637dd0dffb2f394c6f0b27",
"dev": true,
"license": "GPL-3.0-or-later",
"dependencies": {
"js-yaml": "^4.1.0",
"minimist": "^1.2.5"
},
"bin": {
"docker-run_build": "bin/cli.js"
}
},
"node_modules/doctrine": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
@@ -8439,6 +8453,15 @@
"path-type": "^4.0.0"
}
},
"docker-run_build": {
"version": "git+ssh://git@github.com/Sirherobrine23/Docker-Run_Build.git#1b6e28d3ec1ff635c7637dd0dffb2f394c6f0b27",
"dev": true,
"from": "docker-run_build@github:Sirherobrine23/Docker-Run_Build#main",
"requires": {
"js-yaml": "^4.1.0",
"minimist": "^1.2.5"
}
},
"doctrine": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",

View File

@@ -78,6 +78,7 @@
"telegraf": "^4.0.0"
},
"devDependencies": {
"docker-run_build": "github:Sirherobrine23/Docker-Run_Build#main",
"eslint": "^7.19.0",
"husky": "^7.0.0",
"nexe": "*",