Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Script taken from
# https://github.com/darless1/gollum/blob/docker/.github/workflows/build-and-test.yml
# MIT License

name: Build and Test Docker
on: [push, pull_request]

env:
CI_IMAGE: ${{ secrets.DOCKER_HUB_USERNAME }}/w2wiki:dev-${{ github.sha }}
DEPLOY_IMAGE: ${{ secrets.DOCKER_HUB_USERNAME }}/w2wiki:latest

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@v2
- name: Login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Containerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ env.CI_IMAGE }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

deploy-on-master:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
needs: build
steps:
- name: Login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Pull
run: docker pull ${{ env.CI_IMAGE }}
- name: Tag
run: docker tag ${{ env.CI_IMAGE }} ${{ env.DEPLOY_IMAGE }}
- name: Push
run: docker push ${{ env.DEPLOY_IMAGE }}

23 changes: 23 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM php:7-apache

RUN docker-php-ext-install exif

RUN set -eux; \
\
apt-get update; \
apt-get install -y --no-install-recommends git; \
rm -rf /var/lib/apt/lists/*; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false

COPY --chown=www-data:www-data . /var/www/html

RUN set -eux; \
\
sed -i "s/BASE_PATH \\. //" /var/www/html/config.php ;\
sed -i "s/'GIT_COMMIT_ENABLED', false/'GIT_COMMIT_ENABLED', true/" /var/www/html/config.php ;\
echo "" > /etc/apache2/mods-enabled/alias.conf

VOLUME /pages
EXPOSE 80

CMD /var/www/html/container-start.sh
22 changes: 22 additions & 0 deletions container-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
set -e

# on empty volume copy default pages
if ! test -f /pages/Home.md ; then
cp /var/www/html/pages/* /pages

(
cd /pages
git init
git config user.email "w2wiki@w2wiki"
git config user.name "w2wiki"

git add -A .
git commit -m "Init with default pages"
)
fi

mkdir -p /pages/images
chown -R www-data:www-data /pages

exec apache2-foreground "$@"