From 2e2dcf65c61feeb87ae5978dba154ade44e92cd6 Mon Sep 17 00:00:00 2001 From: Mindfang Date: Tue, 16 Jan 2024 16:58:10 -0600 Subject: [PATCH] Upload project --- .dockerignore | 3 ++ .gitea/workflows/commit.yaml | 48 +++++++++++++++++ Dockerfile | 32 +++++++++++ README.md | 53 ++++++++++++++++++- root/etc/s6-overlay/s6-rc.d/initialize/type | 1 + root/etc/s6-overlay/s6-rc.d/initialize/up | 1 + .../s6-overlay/s6-rc.d/user/contents.d/wings | 0 .../etc/s6-overlay/s6-rc.d/wings/dependencies | 1 + root/etc/s6-overlay/s6-rc.d/wings/run | 3 ++ root/etc/s6-overlay/s6-rc.d/wings/type | 1 + root/etc/s6-overlay/scripts/container-prep | 20 +++++++ 11 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 .gitea/workflows/commit.yaml create mode 100644 Dockerfile create mode 100644 root/etc/s6-overlay/s6-rc.d/initialize/type create mode 100644 root/etc/s6-overlay/s6-rc.d/initialize/up create mode 100644 root/etc/s6-overlay/s6-rc.d/user/contents.d/wings create mode 100644 root/etc/s6-overlay/s6-rc.d/wings/dependencies create mode 100644 root/etc/s6-overlay/s6-rc.d/wings/run create mode 100644 root/etc/s6-overlay/s6-rc.d/wings/type create mode 100644 root/etc/s6-overlay/scripts/container-prep diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3787a26 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.gitignore +README.md +docker-compose.yml \ No newline at end of file diff --git a/.gitea/workflows/commit.yaml b/.gitea/workflows/commit.yaml new file mode 100644 index 0000000..f20fcc7 --- /dev/null +++ b/.gitea/workflows/commit.yaml @@ -0,0 +1,48 @@ +name: Build on Commit +run-name: Build + +on: + push: + branches: + - "main" + +env: + REGISTRY: gitea.taco.quest + IMAGE_NAME: ${{ gitea.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Prepare the container + run: curl -fsSL https://get.docker.com -o get-docker.sh && sh ./get-docker.sh + + - name: Log in to registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ gitea.actor }} + password: ${{ secrets.AUTH_TOKEN }} + + - name: Extract metadata for registry + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4b7f09a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +FROM docker +ENV S6_BEHAVIOUR_IF_STAGE2_FAILS="2" \ + S6_CMD_WAIT_FOR_SERVICES_MAXTIME="0" +COPY root/ / + +# Download latest Wings build from project repository: https://github.com/pterodactyl/wings +ADD https://github.com/pterodactyl/wings/releases/latest/download/wings_linux_amd64 /usr/bin/wings + +# Download latest S6-Overlay build from project repository: https://github.com/just-containers/s6-overlay +ADD https://github.com/just-containers/s6-overlay/releases/latest/download/s6-overlay-noarch.tar.xz /tmp +ADD https://github.com/just-containers/s6-overlay/releases/latest/download/s6-overlay-x86_64.tar.xz /tmp + +# Download common tools +ADD https://raw.githubusercontent.com/Gethec/ProjectTools/main/DockerUtilities/ContainerTools /usr/local/sbin/ContainerTools + +# Upgrade installed packages, install new ones +RUN apk --no-cache add \ + bash \ + tzdata && \ + # Install S6-Overlay, enable execution of Wings + chmod u+x /usr/bin/wings && \ + tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz && \ + tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz && \ + # Container cleanup + rm -rf /tmp/* + +# Expose ports: 8080 for webservice, 2022 for SFTP +EXPOSE 8080 +EXPOSE 2022 + +# Set entrypoint to S6-Overlay +ENTRYPOINT ["/init"] \ No newline at end of file diff --git a/README.md b/README.md index 0144057..ab06b49 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,53 @@ -# Pterodactyl-Wings +# Pterodactyl Wings # +## Disclaimer ## +As with anything else, exposing your system to the Internet incurs risks! This container does its best to be as secure as possible, but makes no guarantees to being completely impenetrable. Use at your own risk, and feel free to suggest changes that can further increase security. + +## About ## +The Pterodactyl project is an impressive one to me, but I wanted a way to make use of it in Unraid without installing it to the system. Thus, this set of containers was born. Wings specifically uses the official [Docker in a Docker](https://hub.docker.com/_/docker) image to connect to the host Docker environment and maximize performance. + +## Features ## +* Built on Alpine Linux for a minimal footprint +* Connects to the host's docker.sock to provide maximum performance + +## Configuration ## +Because of how the Docker works while containerized in this fashion, any files accessed by Docker **MUST** share the same path in the container as on the host! If you fail to mirror the host path to the container path, containers cannot be created. + +Additionally, a requirement of the Docker-in-Docker container is for it to be run in Privileged mode, so make sure `--privileged` is part of the run command. + +### Variables ### +| Variable | Default | Note | Example | +|----------|---------|------|---------| +| DATADIR | /var/lib/pterodactyl | Used to mirror container data path to host data directory | `-e DATADIR="/path/to/configfolder"` | + +### Volumes ### +| Volume | Note | Example | +|--------|------|---------| +| /var/run/docker.sock | Grants container access to the Docker sockfile | `-v "/var/run/docker.sock":"/var/run/docker.sock"` | +| /var/lib/docker | Grants container access to the Docker application files | `-v "/var/lib/docker/":"/var/lib/docker"` | +| /tmp/pterodactyl | While not necessary, this can help reduce the Docker image size | `-v "/tmp/pterodactyl":"/tmp/pterodactyl"` | +| /le-ssl | This is not a published volume, but is useful for providing an external cert to Wings | `-v "/letsencrypt/cert/directory":"/le-ssl"` | +| DATADIR | This is a dynamic mount path used to mirror the host Docker volume path to the container | `-v "/var/lib/pterodactyl":"/var/lib/pterodactyl"` | + +### Ports ### +| Port | Note | Example | +|------|---------|---------| +| 2022 | SFTP port | `-p 2022:2022/tcp` | +| 8080 | Wings service port | `-p 8080:8080/tcp` | + +## Setup ## +The majority of this container's setup takes place in the mapping of volumes. Once that is complete, all that is left is to provide a completed config.yml in `DATADIR`, which is created in Panel. It is important to note that some of the paths provided in the config file may need to be manually edited to point to the correct location. Pay attention to any errors Wings generates - if they're stating an issue with a directory, verify that it's actually using the right one. + +Example run command: + + docker run \ + --privileged \ + --name="Wings" \ + -v "/var/run/docker.sock":"/var/run/docker.sock" \ + -v "/var/lib/docker/":"/var/lib/docker" \ + -v "/tmp/pterodactyl":"/tmp/pterodactyl" \ + -v "/var/lib/pterodactyl":"/var/lib/pterodactyl" \ + -v "/letsencrypt/cert/directory":"/le-ssl" \ + -p 2022:2022/tcp \ + -p 8080:8080/tcp \ + gethec/pterodactyl-wings \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/initialize/type b/root/etc/s6-overlay/s6-rc.d/initialize/type new file mode 100644 index 0000000..3d92b15 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/initialize/type @@ -0,0 +1 @@ +oneshot \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/initialize/up b/root/etc/s6-overlay/s6-rc.d/initialize/up new file mode 100644 index 0000000..9974bf7 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/initialize/up @@ -0,0 +1 @@ +/etc/s6-overlay/scripts/container-prep \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/wings b/root/etc/s6-overlay/s6-rc.d/user/contents.d/wings new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/wings/dependencies b/root/etc/s6-overlay/s6-rc.d/wings/dependencies new file mode 100644 index 0000000..d55977f --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/wings/dependencies @@ -0,0 +1 @@ +initialize \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/wings/run b/root/etc/s6-overlay/s6-rc.d/wings/run new file mode 100644 index 0000000..4f0dc7e --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/wings/run @@ -0,0 +1,3 @@ +#!/command/with-contenv bash + +wings --config $DATADIR/config.yml \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/wings/type b/root/etc/s6-overlay/s6-rc.d/wings/type new file mode 100644 index 0000000..1780f9f --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/wings/type @@ -0,0 +1 @@ +longrun \ No newline at end of file diff --git a/root/etc/s6-overlay/scripts/container-prep b/root/etc/s6-overlay/scripts/container-prep new file mode 100644 index 0000000..8d02235 --- /dev/null +++ b/root/etc/s6-overlay/scripts/container-prep @@ -0,0 +1,20 @@ +#!/command/with-contenv bash +source ContainerTools +SNAME=${BASH_SOURCE##*/} +DATADIR=${DATADIR:=/var/lib/pterodactyl} + +# Create specified data directory if it doesn't exist. Defaults to Wings default. +log "Preparing workdir: ${DATADIR}" +if [ ! -d $DATADIR ]; then + mkdir -p $DATADIR +fi + +# Halt container boot unless the config file is present. Wings will not start without it. +log "Checking for $DATADIR/config.yml before beginning execution" +COUNT=1 +while [ ! -e $DATADIR/config.yml ]; do + log "Attempt $COUNT, config file \"config.yml\" not present in \"$DATADIR\" - retrying in 15 seconds" + ((COUNT=COUNT+1)) + sleep 15 +done +log "Config file found, starting Wings" \ No newline at end of file