diff --git a/.cirrus.yml b/.cirrus.yml index f4f28c792..34fbe5ccf 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -70,3 +70,23 @@ task: - yarn build Test_script: - yarn test:main + +docker_builder: + name: Docker + # only_if: $CIRRUS_TAG != '' + depends_on: + - Build + env: + DOCKER_USERNAME: ENCRYPTED[...] + DOCKER_PASSWORD: ENCRYPTED[...] + get_artifact_script: + - apt update --yes + - apt install unzip curl --yes + - curl -L "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/Build/Peacock_Release.zip" -o Peacock.zip + - unzip Peacock.zip + - unzip Peacock-v*-linux.zip + - rm Peacock*.zip + build_script: docker build --tag thepeacockproject/peacock:latest . + # build_script: docker build --tag thepeacockproject/peacock:$CIRRUS_TAG --tag thepeacockproject/peacock:latest . + # login_script: docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD + # push_script: docker push thepeacockproject/peacock:$CIRRUS_TAG && docker push thepeacockproject/peacock:latest \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0a64975da..b2df00f37 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,5 @@ DEBUG_PROFILE.zip packaging/add_itemsize/* !packaging/add_itemsize/add_itemsize.js /.idea/AIAssistantCustomInstructionsStorage.xml + +config/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..fc75e6db3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM node:22.13.0-alpine3.21 + +RUN apk add --update su-exec shadow jq + +RUN rm -rf /var/cache/apk/* + +RUN mkdir /app_build +RUN mkdir /app_linux +WORKDIR /app_build + +COPY . . + +RUN chmod +x packaging/docker-build.sh +RUN chmod +x packaging/entrypoint.sh + +RUN packaging/docker-build.sh + +ENTRYPOINT ["./packaging/entrypoint.sh"] diff --git a/packaging/ciAssemble.sh b/packaging/ciAssemble.sh index c8a8aee81..a689eca5a 100755 --- a/packaging/ciAssemble.sh +++ b/packaging/ciAssemble.sh @@ -31,7 +31,7 @@ fi # generate options.ini node chunk0.js noop -mkdir "$OUT_DIR" +mkdir -p "$OUT_DIR" cp packaging/HOW_TO_USE.html "$OUT_DIR" cp PeacockPatcher.exe "$OUT_DIR" cp chunk*.js "$OUT_DIR" @@ -43,15 +43,15 @@ fi cp LICENSE "$OUT_DIR" cp THIRDPARTYNOTICES.txt "$OUT_DIR" cp .nvmrc "$OUT_DIR" -mkdir "$OUT_DIR"/resources +mkdir -p "$OUT_DIR"/resources cp resources/dynamic_resources_h3.rpkg "$OUT_DIR"/resources/dynamic_resources_h3.rpkg cp resources/dynamic_resources_h2.rpkg "$OUT_DIR"/resources/dynamic_resources_h2.rpkg cp resources/dynamic_resources_h1.rpkg "$OUT_DIR"/resources/dynamic_resources_h1.rpkg cp -r resources/challenges "$OUT_DIR"/resources/challenges cp -r resources/mastery "$OUT_DIR"/resources/mastery cp resources/contracts.prp "$OUT_DIR"/resources/contracts.prp -mkdir "$OUT_DIR"/webui -mkdir "$OUT_DIR"/webui/dist +mkdir -p "$OUT_DIR"/webui +mkdir -p "$OUT_DIR"/webui/dist cp webui/dist/*.html "$OUT_DIR"/webui/dist cp -r webui/dist/assets "$OUT_DIR"/webui/dist/assets cp webui/dist/THIRDPARTYNOTICES.txt "$OUT_DIR"/webui/dist/THIRDPARTYNOTICES.txt diff --git a/packaging/docker-build.sh b/packaging/docker-build.sh new file mode 100644 index 000000000..8e2c8394e --- /dev/null +++ b/packaging/docker-build.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +VERSION=$(jq -r '.version' package.json) +BUILD_DIR=Peacock-v"$VERSION"-linux + +cp -r "$BUILD_DIR"/* /app_linux \ No newline at end of file diff --git a/packaging/entrypoint.sh b/packaging/entrypoint.sh new file mode 100644 index 000000000..ef0aff719 --- /dev/null +++ b/packaging/entrypoint.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +mkdir -p /app + +cp /app_linux/chunk0* /app +cp -r /app_linux/resources /app +cp -r /app_linux/webui /app + +cd /app + +if [ -z "$PUID" ] || [ -z "$PGID" ]; then + exec node chunk0.js +else + EXISTING_USER=$(getent passwd "$PUID" | cut -d: -f1) + EXISTING_GROUP=$(getent group "$PGID" | cut -d: -f1) + + if [ -z "$EXISTING_USER" ]; then + adduser -u $PUID -D abc + EXISTING_USER=abc + fi + + if [ -z "$EXISTING_GROUP" ]; then + groupmod -g $PGID abc + EXISTING_GROUP=abc + fi + + chown $EXISTING_USER:$EXISTING_GROUP -R /app + + su-exec $EXISTING_USER node chunk0.js +fi