From 78e42f59a9e057f3c71d778e2dba970bb064e96b Mon Sep 17 00:00:00 2001 From: Vojtech Mares Date: Mon, 16 Jan 2023 16:27:07 +0100 Subject: [PATCH] feat: correct way for nightly docker builds from source --- .github/workflows/nightly.yml | 42 +++++++++++++++++++++++ Dockerfile.nightly | 63 +++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 .github/workflows/nightly.yml create mode 100644 Dockerfile.nightly diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000..8ce66c1 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,42 @@ +name: Nightly / Build and publish a Docker image + +env: + REGISTRY: ghcr.io + IMAGE_NAME: acaslab/pterodactyl-panel + +on: + schedule: + - cron: '0 4 * * *' + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: . + file: Dockerfile.nightly + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile.nightly b/Dockerfile.nightly new file mode 100644 index 0000000..6b6ed06 --- /dev/null +++ b/Dockerfile.nightly @@ -0,0 +1,63 @@ +FROM ubuntu:22.04 as base + +RUN apt update && apt -y install \ + software-properties-common \ + apt-transport-https \ + ca-certificates \ + gnupg \ + curl + +# Add Ondrej Sury's PPA for PHP +RUN LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php \ + && apt update + +# Install PHP 8.1 +RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt -y install \ + php8.1 \ + php8.1-common \ + php8.1-cli \ + php8.1-gd \ + php8.1-mysql \ + php8.1-mbstring \ + php8.1-bcmath \ + php8.1-xml \ + php8.1-fpm \ + php8.1-curl \ + php8.1-zip \ + unzip \ + tar \ + git + +FROM base as builder + +# Add Node.js 18.x PPA +RUN curl -fsSL https://deb.nodesource.com/setup_18.x | sh - + +# Install Node.js & Yarn to build assets +RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install nodejs -y && npm i -g yarn + +RUN rm -rf /var/lib/apt && \ + rm -rf /var/lib/dpkg && \ + rm -rf /var/lib/cache && \ + rm -rf /var/lib/log + +# Install composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# Download the Pterodactyl Panel +RUN git clone https://github.com/pterodactyl/panel.git /var/www/pterodactyl + +WORKDIR /var/www/pterodactyl + +# Install Node.js dependencies & build assets +RUN yarn install --frozen-lockfile && yarn run build + +# Install PHP dependencies +RUN composer install --no-dev --optimize-autoloader + +FROM base as app + +WORKDIR /var/www/pterodactyl +USER www-data + +COPY --from=builder --chown=www-data:www-data /var/www/pterodactyl /var/www/pterodactyl