diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..16fbe0a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +.dockerignore +.git +.github +**/*.DS_Store +docker-bake.hcl +docs +httpd-php-dev.yml +httpd-php.Dockerfile +httpd-php.yml +README.md diff --git a/.github/workflows/httpd-php-multiarch.yml b/.github/workflows/httpd-php-multiarch.yml new file mode 100644 index 0000000..0eef83b --- /dev/null +++ b/.github/workflows/httpd-php-multiarch.yml @@ -0,0 +1,76 @@ +name: buildx + +on: + workflow_dispatch: + +env: + GHCR_SLUG: ghcr.io/rodber/chevereto-free-httpd-php + +jobs: + buildx: + runs-on: ubuntu-20.04 + strategy: + matrix: + operating-system: [ubuntu-latest] + php-versions: ["8.0"] + name: Build on PHP ${{ matrix.php-versions }} ${{ matrix.operating-system }} + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + env: + fail-fast: true + + # - name: Build + # run: php src/build.php + + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: | + ${{ env.GHCR_SLUG }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + labels: | + org.opencontainers.image.title=Chevereto-Free + org.opencontainers.image.description=Chevereto-Free Image Hosting + org.opencontainers.image.vendor=rodber + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to GHCR + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build + uses: docker/bake-action@v1 + with: + files: | + ./docker-bake.hcl + ${{ steps.meta.outputs.bake-file }} + targets: build + push: true + + - name: Check manifest + run: | + docker buildx imagetools inspect ${{ env.GHCR_SLUG }}:${{ steps.meta.outputs.version }} + + - name: Inspect image + run: | + docker pull ${{ env.GHCR_SLUG }}:${{ steps.meta.outputs.version }} + docker image inspect ${{ env.GHCR_SLUG }}:${{ steps.meta.outputs.version }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 48f2527..759808a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,12 +42,15 @@ jobs: id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + - name: Packaging + run: | + rm -rf .git .github .dockerignore docs app/settings.php docker-bake.hcl httpd-php-dev.yml httpd-php.Dockerfile httpd-php.yml sync.sh + - name: Archive dev uses: thedoctor0/zip-release@master with: type: "zip" filename: "${{ steps.get_version.outputs.VERSION }}-lite.zip" - exclusions: "/*.git/* /*.github/*" - name: Install dependencies run: composer install --prefer-dist --no-progress --classmap-authoritative --ignore-platform-reqs @@ -57,12 +60,13 @@ jobs: with: type: "zip" filename: "${{ steps.get_version.outputs.VERSION }}.zip" - exclusions: "/*.git/* /*.github/* ${{ steps.get_version.outputs.VERSION }}-lite.zip" + exclusions: "${{ steps.get_version.outputs.VERSION }}-lite.zip" - name: Upload artifacts uses: ncipollo/release-action@v1 with: allowUpdates: true removeArtifacts: true + omitBodyDuringUpdate: true artifacts: "${{ steps.get_version.outputs.VERSION }}.zip,${{ steps.get_version.outputs.VERSION }}-lite.zip" token: ${{ secrets.GITHUB_TOKEN }} diff --git a/docker-bake.hcl b/docker-bake.hcl new file mode 100644 index 0000000..b616509 --- /dev/null +++ b/docker-bake.hcl @@ -0,0 +1,11 @@ +target "docker-metadata-action" {} + +target "build" { + inherits = ["docker-metadata-action"] + context = "./" + dockerfile = "httpd-php.Dockerfile" + platforms = [ + "linux/amd64", + "linux/arm64", + ] +} diff --git a/httpd-php-dev.yml b/httpd-php-dev.yml new file mode 100644 index 0000000..c7f083a --- /dev/null +++ b/httpd-php-dev.yml @@ -0,0 +1,47 @@ +version: "3.2" + +services: + database: + container_name: chevereto-free-dev_database + image: mariadb:focal + networks: + - chevereto + volumes: + - database:/var/lib/mysql + restart: always + environment: + MYSQL_ROOT_PASSWORD: password + MYSQL_DATABASE: chevereto + MYSQL_USER: chevereto + MYSQL_PASSWORD: user_database_password + + app: + container_name: chevereto-free-dev_app + image: ghcr.io/rodber/chevereto-free-httpd-php:1.6 + networks: + - chevereto + volumes: + - storage:/var/www/html/images/ + - app:/var/www/html/ + - type: bind + source: ${SOURCE} + target: /var/www/chevereto + ports: + - 8910:80 + restart: always + environment: + CHEVERETO_TAG: dev + CHEVERETO_DB_HOST: database + CHEVERETO_DB_USER: chevereto + CHEVERETO_DB_PASS: user_database_password + CHEVERETO_DB_PORT: 3306 + CHEVERETO_DB_NAME: chevereto + CHEVERETO_HTTPS: 0 + +volumes: + database: + storage: + app: + +networks: + chevereto: diff --git a/httpd-php.Dockerfile b/httpd-php.Dockerfile new file mode 100644 index 0000000..2eec371 --- /dev/null +++ b/httpd-php.Dockerfile @@ -0,0 +1,87 @@ +FROM composer:latest as composer +FROM php:7.4-apache +COPY --from=composer /usr/bin/composer /usr/local/bin/composer + +RUN apt-get update && apt-get install -y \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libpng-dev \ + libwebp-dev \ + libgd-dev \ + libzip-dev \ + zip \ + unzip \ + imagemagick libmagickwand-dev --no-install-recommends \ + && docker-php-ext-configure gd \ + --with-freetype=/usr/include/ \ + --with-jpeg=/usr/include/ \ + --with-webp=/usr/include/ \ + && docker-php-ext-configure opcache --enable-opcache \ + && docker-php-ext-install -j$(nproc) exif gd pdo_mysql zip opcache \ + && pecl install imagick \ + && docker-php-ext-enable imagick opcache \ + && php -m + +RUN apt-get install -y \ + rsync \ + inotify-tools \ + && a2enmod rewrite + +ARG CHEVERETO_SOFTWARE=chevereto +ARG CHEVERETO_TAG=free +ARG CHEVERETO_SERVICING=docker + +ENV CHEVERETO_SOFTWARE=$CHEVERETO_SOFTWARE \ + CHEVERETO_TAG=$CHEVERETO_TAG \ + CHEVERETO_SERVICING=$CHEVERETO_SERVICING \ + CHEVERETO_DB_HOST=mariadb \ + CHEVERETO_DB_USER=chevereto \ + CHEVERETO_DB_PASS=user_database_password \ + CHEVERETO_DB_NAME=chevereto \ + CHEVERETO_DB_TABLE_PREFIX=chv_ \ + CHEVERETO_DB_PORT=3306 \ + CHEVERETO_DB_DRIVER=mysql \ + CHEVERETO_DB_PDO_ATTRS=[] \ + CHEVERETO_DEBUG_LEVEL=1 \ + CHEVERETO_DISABLE_PHP_PAGES=1 \ + CHEVERETO_DISABLE_UPDATE_HTTP=1 \ + CHEVERETO_DISABLE_UPDATE_CLI=1 \ + CHEVERETO_ERROR_LOG= \ + CHEVERETO_IMAGE_FORMATS_AVAILABLE=JPG,PNG,BMP,GIF,WEBP \ + CHEVERETO_IMAGE_LIBRARY=gd \ + CHEVERETO_HTTPS=1 \ + CHEVERETO_HOSTNAME=localhost \ + CHEVERETO_HOSTNAME_PATH=/ \ + CHEVERETO_SESSION_SAVE_HANDLER=files \ + CHEVERETO_SESSION_SAVE_PATH=/tmp \ + CHEVERETO_UPLOAD_MAX_FILESIZE=64M \ + CHEVERETO_POST_MAX_SIZE=64M \ + CHEVERETO_MAX_EXECUTION_TIME=30 \ + CHEVERETO_MEMORY_LIMIT=512M + +RUN set -eux; \ + { \ + echo "log_errors = On"; \ + echo "error_log = /dev/stderr"; \ + echo "upload_max_filesize = \${CHEVERETO_UPLOAD_MAX_FILESIZE}"; \ + echo "post_max_size = \${CHEVERETO_POST_MAX_SIZE}"; \ + echo "max_execution_time = \${CHEVERETO_MAX_EXECUTION_TIME}"; \ + echo "memory_limit = \${CHEVERETO_MEMORY_LIMIT}"; \ + } > $PHP_INI_DIR/conf.d/php.ini + +VOLUME /var/www/html +VOLUME /var/www/html/images +VOLUME /var/www/source + +COPY . /var/www/html +RUN rm /var/www/html/sync.sh +RUN composer install \ + --working-dir=/var/www/html \ + --prefer-dist \ + --no-progress \ + --classmap-authoritative \ + --ignore-platform-reqs +RUN chown www-data: /var/www/html -R +COPY sync.sh /var/www/sync.sh +RUN chmod +x /var/www/sync.sh +CMD ["/bin/bash", "apache2-foreground"] \ No newline at end of file diff --git a/httpd-php.yml b/httpd-php.yml new file mode 100644 index 0000000..03d0e01 --- /dev/null +++ b/httpd-php.yml @@ -0,0 +1,44 @@ +version: "3.2" + +services: + database: + container_name: chevereto-free_database + image: mariadb:focal + networks: + - chevereto + volumes: + - data:/var/lib/mysql + restart: always + environment: + MYSQL_ROOT_PASSWORD: password + MYSQL_DATABASE: chevereto + MYSQL_USER: chevereto + MYSQL_PASSWORD: user_database_password + + app: + container_name: chevereto-free_app + image: ghcr.io/rodber/chevereto-free-httpd-php:1.6 + networks: + - chevereto + volumes: + - storage:/var/www/html/images/ + - app:/var/www/html/ + ports: + - 8810:80 + restart: always + environment: + CHEVERETO_TAG: "free" + CHEVERETO_DB_HOST: database + CHEVERETO_DB_USER: chevereto + CHEVERETO_DB_PASS: user_database_password + CHEVERETO_DB_PORT: 3306 + CHEVERETO_DB_NAME: chevereto + CHEVERETO_HTTPS: 0 + +volumes: + data: + storage: + app: + +networks: + chevereto: diff --git a/sync.sh b/sync.sh new file mode 100644 index 0000000..f4d17d1 --- /dev/null +++ b/sync.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +set -e +SOURCE=/var/www/source/ +INSTALLER=/var/www/installer/ +TARGET=/var/www/html/ +EXCLUDE="\.git|\.DS_Store|\/docs" +mkdir -p $INSTALLER +cp "${SOURCE}".gitignore "${INSTALLER}".gitignore +function sync() { + rsync -r -I -og \ + --chown=www-data:www-data \ + --info=progress2 \ + --filter=':- .gitignore' \ + --exclude '.git' \ + --delete \ + $SOURCE $INSTALLER + # php "${INSTALLER}"src/build.php + # cp "${INSTALLER}"build/installer.php "${TARGET}"installer.php + # chown www-data: $TARGET -R +} +sync +inotifywait \ + --event create \ + --event delete \ + --event modify \ + --event move \ + --format "%e %w%f" \ + --exclude $EXCLUDE \ + --monitor \ + --recursive \ + $SOURCE | + while read CHANGED; do + sync + done