From 7e8f962db56d83acbb1989d6887cf8a7f97926f0 Mon Sep 17 00:00:00 2001 From: Kovah Date: Sun, 30 Oct 2022 14:50:35 +0100 Subject: [PATCH] Optimize Pixelfed Dockerfile, add Github Actions build --- .github/workflows/build-docker.yml | 37 ++++++++++++++++++++++++++++++ contrib/docker/Dockerfile.apache | 23 ++++++++----------- 2 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/build-docker.yml diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml new file mode 100644 index 000000000..9413a4e7f --- /dev/null +++ b/.github/workflows/build-docker.yml @@ -0,0 +1,37 @@ +--- +name: Build Docker image + +on: + push: + branches: + - dev + +jobs: + build_regular_docker: + + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + file: ./contrib/docker/Dockerfile.apache + platforms: linux/amd64,linux/arm64,linux/arm/v7 + push: true + tags: kovah/pixelfed-docker:latest diff --git a/contrib/docker/Dockerfile.apache b/contrib/docker/Dockerfile.apache index 206c86d10..c4d5c305b 100644 --- a/contrib/docker/Dockerfile.apache +++ b/contrib/docker/Dockerfile.apache @@ -1,20 +1,17 @@ -FROM php:7.4-apache-bullseye +FROM php:8.0-apache + +ENV COMPOSER_MEMORY_LIMIT=-1 +ARG DEBIAN_FRONTEND=noninteractive +WORKDIR /var/www/ # Use the default production configuration COPY contrib/docker/php.production.ini "$PHP_INI_DIR/php.ini" -# Install Composer -ENV COMPOSER_VERSION=2.1.14 \ - COMPOSER_HOME=/var/www/.composer \ - COMPOSER_MEMORY_LIMIT=-1 \ - PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}" -ARG DEBIAN_FRONTEND=noninteractive -WORKDIR /var/www/ -RUN curl -o /tmp/composer-setup.php https://getcomposer.org/installer \ - && curl -o /tmp/composer-setup.sig https://composer.github.io/installer.sig \ - && php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }" \ - && php /tmp/composer-setup.php --no-ansi --install-dir=/usr/local/bin --filename=composer --version=${COMPOSER_VERSION} && rm -rf /tmp/composer-setup.php \ - && apt-get update \ +# Get Composer binary +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +# Install package dependencies +RUN apt-get update \ && apt-get upgrade -y \ # && apt-get install -y --no-install-recommends apt-utils \ && apt-get install -y --no-install-recommends \