Skip to content

Commit

Permalink
Add docker
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-gardener committed Mar 25, 2024
1 parent 7d7522e commit f97d292
Show file tree
Hide file tree
Showing 19 changed files with 2,626 additions and 85 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
/*.sql
/.data/*
124 changes: 124 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Deploy Image

# based on: https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners

on:
push:
tags:
- 'v*'

env:
REGISTRY_IMAGE: dhilsfu/gcha

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/386
- linux/amd64
# - linux/arm/v5
- linux/arm/v7
- linux/arm64
# - linux/mips64le
# - linux/ppc64le
# - linux/s390x
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Checkout source code
uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ env.PLATFORM_PAIR }}
cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ env.PLATFORM_PAIR }},mode=max

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

push:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
- name: Trigger Gitlab Deploy Job
run: |
curl -X POST \
--fail \
-F token=${{ secrets.GITLAB_CI_TOKEN }} \
-F "ref=main" \
-F "variables[APP_RELEASE_TAG]=${{github.ref_name}}" \
https://git.lib.sfu.ca/api/v4/projects/564/trigger/pipeline
21 changes: 3 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
db.ini

/files/fullsize/*
!/files/fullsize/index.html

/files/original/*
!/files/original/index.html

/files/square_thumbnails/*
!/files/square_thumbnails/index.html

/files/theme_uploads/*
!/files/theme_uploads/index.html

/files/thumbnails/*
!/files/thumbnails/index.html
.idea
application/logs
.DS_Store
/*.sql
/.data/*
60 changes: 60 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
FROM php:8.2-apache
WORKDIR /var/www/html

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libzip-dev \
libapache2-mod-xsendfile \
netcat-traditional \
git-core \
apt-utils \
unzip \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng-dev \
libjpeg-dev \
libmemcached-dev \
zlib1g-dev \
imagemagick \
libmagickwand-dev \
curl \
ghostscript \
poppler-utils \
libsodium-dev \
libicu-dev \
libvips-tools \
apt-utils \
&& cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
&& a2enmod rewrite headers \
&& docker-php-ext-configure gd --with-jpeg=/usr/include/ --with-freetype=/usr/include/ \
&& docker-php-ext-configure intl \
&& docker-php-ext-install -j$(nproc) iconv pdo pdo_mysql mysqli gd intl \
&& pecl install imagick mcrypt \
&& docker-php-ext-enable imagick mcrypt \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Add the Omeka PHP code
# Latest Omeka version, check: https://omeka.org/s/download/
ENV OMEKA_VERSION 3.1.2
RUN curl -L "https://github.com/omeka/Omeka/releases/download/v${OMEKA_VERSION}/omeka-${OMEKA_VERSION}.zip" -o /var/www/omeka-${OMEKA_VERSION}.zip \
&& unzip /var/www/omeka-${OMEKA_VERSION}.zip -d /var/www/ \
&& rm -Rf /var/www/omeka-${OMEKA_VERSION}.zip /var/www/html \
&& mv /var/www/omeka-${OMEKA_VERSION}/ /var/www/html

# default service settings
COPY docker/docker-entrypoint.sh /docker-entrypoint.sh
COPY docker/gcha.ini /usr/local/etc/php/conf.d/gcha.ini
COPY docker/image-policy.xml /etc/ImageMagick-6/policy.xml

# omeka settings
COPY --chown=www-data:www-data --chmod=771 docker/omeka/db.ini docker/omeka/robots.txt docker/omeka/.htaccess /var/www/html/
COPY --chown=www-data:www-data --chmod=771 docker/omeka/application/config/config.ini /var/www/html/application/config/config.ini
COPY --chown=www-data:www-data --chmod=771 themes /var/www/html/themes/
COPY --chown=www-data:www-data --chmod=771 plugins /var/www/html/plugins/

RUN chown www-data:www-data -R themes/ plugins/ \
&& chmod 771 -R themes/ plugins/

CMD ["/docker-entrypoint.sh"]
Loading

0 comments on commit f97d292

Please sign in to comment.