Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3f5c13c
Create utils.sh
dyeh123 Jul 21, 2021
1ccecf3
Create Dockerfile.template
dyeh123 Jul 21, 2021
fba47b3
Create adminer.yml
dyeh123 Jul 21, 2021
f18dc35
Create force.yml
dyeh123 Jul 21, 2021
b0b2b1c
Update Dockerfile.template
dyeh123 Jul 22, 2021
6455304
Update Dockerfile.template
dyeh123 Jul 22, 2021
8bacd34
Create entrypoint.sh
dyeh123 Jul 22, 2021
154f18f
Create index.php
dyeh123 Jul 22, 2021
6093c0e
Create plugin-loader.php
dyeh123 Jul 22, 2021
465333d
Update Dockerfile.template
dyeh123 Jul 22, 2021
215cebd
Create docker-php-entrypoint
dyeh123 Jul 22, 2021
45cd6d1
Create docker-php-ext-configure
dyeh123 Jul 22, 2021
306bf86
Create docker-php-ext-enable
dyeh123 Jul 22, 2021
ba7abbd
Create docker-php-ext-install
dyeh123 Jul 22, 2021
2dec952
Create docker-php-source
dyeh123 Jul 22, 2021
1db5207
Delete docker-php-entrypoint
dyeh123 Jul 22, 2021
481622a
Delete docker-php-ext-configure
dyeh123 Jul 22, 2021
1f9b4c8
Delete docker-php-ext-enable
dyeh123 Jul 22, 2021
624adce
Delete docker-php-ext-install
dyeh123 Jul 22, 2021
4f62651
Delete docker-php-source
dyeh123 Jul 22, 2021
b8fba28
Update Dockerfile.template
dyeh123 Jul 22, 2021
d25183d
Update adminer.yml
dyeh123 Jul 23, 2021
f7c3e9b
Update Dockerfile.template
dyeh123 Jul 23, 2021
c8fd3e2
Update adminer.yml
dyeh123 Jul 24, 2021
3bb26b1
Update Dockerfile.template
dyeh123 Jul 24, 2021
f8c65fb
add x to entrypoint
dyeh1234 Jul 24, 2021
1419882
Update adminer.yml
dyeh123 Jul 26, 2021
efb132f
Update adminer.yml
dyeh123 Jul 26, 2021
2c483a8
Update force.yml
dyeh123 Jul 26, 2021
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
75 changes: 75 additions & 0 deletions .github/workflows/adminer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: build on change

on:
push:
branches:
- master
- main
workflow_dispatch:
repository_dispatch:
types: adminer

jobs:
adminer:
runs-on: ubuntu-20.04
steps:
- name: checkout code
uses: actions/checkout@v2
- name: docker login
run: docker login -u ${{ secrets.DOCKERUSERNAME }} -p ${{ secrets.DOCKERAPIKEY }}
- name: treehouses adminer
run: |
export DOCKER_CLI_EXPERIMENTAL=enabled
repo="treehouses/adminer"
base="treehouses/php"
source .github/workflows/utils.sh
echo "amd64"
baseamd64=$(get_variant_sha "$base" "latest" "amd64")
echo $baseamd64
repoamd64=$(get_manifest_sha "$repo:latest" "amd64")
echo $repoamd64
echo "arm"
basearm=$(get_tag_sha "$base" "latest")
echo $basearm
repoarm=$(get_manifest_sha "$repo:latest" "arm")
echo $repoarm
echo "arm64"
basearm64=$(get_variant_sha "$base" "latest" "arm64")
echo $basearm64
repoarm64=$(get_manifest_sha "$repo:latest" "arm64")
echo $repoarm64
echo "change"
flag=$(compare_sha "$baseamd64" "$repoamd64" "$basearm" "$repoarm" "$basearm64" "$repoarm64")
echo $flag
if [[ $flag == true ]]; then
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
build_image "$base:latest" amd64 $repo
build_image "$base:latest" arm $repo
build_image "$base:latest" arm64 $repo
deploy_image $repo arm
deploy_image $repo amd64
deploy_image $repo arm64
sudo npm install -g @treehouses/cli
export gitter_channel="${{ secrets.CHANNEL }}"
echo "tags"
tag="$(date +%Y%m%d%H%M)"
echo $tag
docker manifest create $repo:$tag $repo-tags:amd64 $repo-tags:arm $repo-tags:arm64
docker manifest annotate $repo:$tag $repo-tags:amd64 --arch amd64
docker manifest annotate $repo:$tag $repo-tags:arm64 --arch arm64
docker manifest annotate $repo:$tag $repo-tags:arm --arch arm
docker manifest inspect $repo:$tag
docker manifest push $repo:$tag
tag2="latest"
echo $tag2
docker manifest create $repo:$tag2 $repo-tags:amd64 $repo-tags:arm $repo-tags:arm64
docker manifest annotate $repo:$tag2 $repo-tags:amd64 --arch amd64
docker manifest annotate $repo:$tag2 $repo-tags:arm64 --arch arm64
docker manifest annotate $repo:$tag2 $repo-tags:arm --arch arm
docker manifest inspect $repo:$tag2
docker manifest push $repo:$tag2
echo "https://hub.docker.com/r/treehouses/adminer/tags"
treehouses feedback "new treehouses/adminer check https://hub.docker.com/r/treehouses/adminer/tags"
else
echo "no changes"
fi
75 changes: 75 additions & 0 deletions .github/workflows/force.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: build by force

on:
# push:
# branches:
# - master
# - main
workflow_dispatch:
# repository_dispatch:
# types: adminer

jobs:
adminer:
runs-on: ubuntu-20.04
steps:
- name: checkout code
uses: actions/checkout@v2
- name: docker login
run: docker login -u ${{ secrets.DOCKERUSERNAME }} -p ${{ secrets.DOCKERAPIKEY }}
- name: treehouses adminer
run: |
export DOCKER_CLI_EXPERIMENTAL=enabled
repo="treehouses/adminer"
base="treehouses/php"
source .github/workflows/utils.sh
echo "amd64"
baseamd64=$(get_variant_sha "$base" "latest" "amd64")
echo $baseamd64
# repoamd64=$(get_manifest_sha "$repo:latest" "amd64")
# echo $repoamd64
echo "arm"
basearm=$(get_tag_sha "$base" "latest")
echo $basearm
# repoarm=$(get_manifest_sha "$repo:latest" "arm")
# echo $repoarm
echo "arm64"
basearm64=$(get_variant_sha "$base" "latest" "arm64")
echo $basearm64
# repoarm64=$(get_manifest_sha "$repo:latest" "arm64")
# echo $repoarm64
echo "change"
flag=true #$(compare_sha "$baseamd64" "$repoamd64" "$basearm" "$repoarm" "$basearm64" "$repoarm64")
echo $flag
if [[ $flag == true ]]; then
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
build_image "$base:latest" amd64 $repo
build_image "$base:latest" arm $repo
build_image "$base:latest" arm64 $repo
deploy_image $repo arm
deploy_image $repo amd64
deploy_image $repo arm64
sudo npm install -g @treehouses/cli
export gitter_channel="${{ secrets.CHANNEL }}"
echo "tags"
tag="$(date +%Y%m%d%H%M)"
echo $tag
docker manifest create $repo:$tag $repo-tags:amd64 $repo-tags:arm $repo-tags:arm64
docker manifest annotate $repo:$tag $repo-tags:amd64 --arch amd64
docker manifest annotate $repo:$tag $repo-tags:arm64 --arch arm64
docker manifest annotate $repo:$tag $repo-tags:arm --arch arm
docker manifest inspect $repo:$tag
docker manifest push $repo:$tag
tag2="latest"
echo $tag2
docker manifest create $repo:$tag2 $repo-tags:amd64 $repo-tags:arm $repo-tags:arm64
docker manifest annotate $repo:$tag2 $repo-tags:amd64 --arch amd64
docker manifest annotate $repo:$tag2 $repo-tags:arm64 --arch arm64
docker manifest annotate $repo:$tag2 $repo-tags:arm --arch arm
docker manifest inspect $repo:$tag2
docker manifest push $repo:$tag2
echo "https://hub.docker.com/r/treehouses/adminer/tags"
treehouses feedback "new treehouses/adminer check https://hub.docker.com/r/treehouses/adminer/tags"
else
echo "no changes"
fi
112 changes: 112 additions & 0 deletions .github/workflows/utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/bin/bash

get_variant_sha(){
local sha
docker_repo=$1 #alpine or vmnet/alpine
manifest_tag=$2
docker_image=$docker_repo:$manifest_tag
arch=$3
variant=$4
export DOCKER_CLI_EXPERIMENTAL=enabled

docker pull -q ${docker_image} &>/dev/null
docker manifest inspect ${docker_image} > "$2".txt

sha=""
i=0
while [ "$sha" == "" ] && read -r line
do
arch=$(jq .manifests[$i].platform.architecture "$2".txt |sed -e 's/^"//' -e 's/"$//')
if [ "$arch" = "$3" ] && [ "$arch" != "arm" ]; then
sha=$(jq .manifests[$i].digest "$2".txt |sed -e 's/^"//' -e 's/"$//')
echo ${sha}
elif [ "$arch" = "$3" ]; then
variant=$(jq .manifests[$i].platform.variant "$2".txt |sed -e 's/^"//' -e 's/"$//')
if [ "$variant" == "$4" ]; then
sha=$(jq .manifests[$i].digest "$2".txt |sed -e 's/^"//' -e 's/"$//')
echo ${sha}
fi
fi
i=$i+1
done < "$2".txt
}

get_manifest_sha (){
local repo=$1
local arch=$2
docker pull -q $1 &>/dev/null
docker manifest inspect $1 > "$2".txt
sha=""
i=0
while [ "$sha" == "" ] && read -r line
do
archecture=$(jq .manifests[$i].platform.architecture "$2".txt |sed -e 's/^"//' -e 's/"$//')
if [ "$archecture" = "$2" ];then
sha=$(jq .manifests[$i].digest "$2".txt |sed -e 's/^"//' -e 's/"$//')
echo ${sha}
fi
i=$i+1
done < "$2".txt
}

get_tag_sha(){
local repo=$1
local tag=$2
docker pull "$repo:$tag" &>/dev/null
sha=$(docker inspect --format='{{index .RepoDigests 0}}' "$repo:$tag" 2>/dev/null | cut -d @ -f 2)
echo $sha
}

build_image(){
local repo=$1 # this is the base repo, for example treehouses/alpine
local arch=$2 #arm arm64 amd64
local tag_repo=$3 # this is the tag repo, for example treehouses/node
if [ $# -le 1 ]; then
echo "missing parameters."
exit 1
fi
sha=$(get_manifest_sha $@)
echo $sha
base_image="$repo@$sha"
echo $base_image
if [ -n "$sha" ]; then
tag=$tag_repo-tags:$arch
sed "s|{{base_image}}|$base_image|g" Dockerfile.template > Dockerfile.$arch
docker buildx build --platform linux/$arch -t $tag -f Dockerfile.$arch .
fi
}

deploy_image(){
local repo=$1
local arch=$2 #arm arm64 amd64
tag_arch=$repo-tags:$arch
tag_time=$(date +%Y%m%d%H%M)
tag_arch_time=$repo-tags:$arch-$tag_time
echo $tag_arch_time
docker tag $tag_arch $tag_arch_time
docker push $tag_arch_time
docker tag $tag_arch_time $tag_arch
docker push $tag_arch
}

compare_sha () {
if [ "$1" != "$2" ] || [ "$3" != "$4" ] || [ "$5" != "$6" ]; then
echo "true"
else
echo "false"
fi
}

create_manifests(){
local repo=$1
local tag=$2
local x86=$3
local rpi=$4
local arm64=$5
docker manifest create $repo:$tag $x86 $rpi $arm64
docker manifest create $repo:latest $x86 $rpi $arm64
docker manifest annotate $repo:latest $rpi --arch arm
docker manifest annotate $repo:$tag $arm64 --arch arm64
docker manifest annotate $repo:latest $arm64 --arch arm64
docker manifest annotate $repo:$tag $rpi --arch arm
}
61 changes: 61 additions & 0 deletions Dockerfile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
FROM {{base_image}}

RUN echo "upload_max_filesize = 128M" >> /usr/local/etc/php/conf.d/0-upload_large_dumps.ini \
&& echo "post_max_size = 128M" >> /usr/local/etc/php/conf.d/0-upload_large_dumps.ini \
&& echo "memory_limit = 1G" >> /usr/local/etc/php/conf.d/0-upload_large_dumps.ini \
&& echo "max_execution_time = 600" >> /usr/local/etc/php/conf.d/0-upload_large_dumps.ini \
&& echo "max_input_vars = 5000" >> /usr/local/etc/php/conf.d/0-upload_large_dumps.ini

STOPSIGNAL SIGINT

RUN addgroup -S adminer \
&& adduser -S -G adminer adminer \
&& mkdir -p /var/www/html \
&& mkdir -p /var/www/html/plugins-enabled \
&& chown -R adminer:adminer /var/www/html

WORKDIR /var/www/html

RUN set -x \
&& apk add --no-cache --virtual .build-deps \
postgresql-dev \
sqlite-dev \
unixodbc-dev \
freetds-dev \
&& docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \
&& docker-php-ext-install \
pdo_mysql \
pdo_pgsql \
pdo_sqlite \
pdo_odbc \
pdo_dblib \
&& runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)" \
&& apk add --virtual .phpexts-rundeps $runDeps \
&& apk del .build-deps

COPY *.php /var/www/html/

ENV ADMINER_VERSION 4.8.1
ENV ADMINER_DOWNLOAD_SHA256 2fd7e6d8f987b243ab1839249551f62adce19704c47d3d0c8dd9e57ea5b9c6b3
ENV ADMINER_SRC_DOWNLOAD_SHA256 ef832414296d11eed33e9d85fff3fb316c63f13f05fceb4a961cbe4cb2ae8712

RUN set -x \
&& curl -fsSL https://github.com/vrana/adminer/releases/download/v$ADMINER_VERSION/adminer-$ADMINER_VERSION.php -o adminer.php \
&& echo "$ADMINER_DOWNLOAD_SHA256 adminer.php" |sha256sum -c - \
&& curl -fsSL https://github.com/vrana/adminer/archive/v$ADMINER_VERSION.tar.gz -o source.tar.gz \
&& echo "$ADMINER_SRC_DOWNLOAD_SHA256 source.tar.gz" |sha256sum -c - \
&& tar xzf source.tar.gz --strip-components=1 "adminer-$ADMINER_VERSION/designs/" "adminer-$ADMINER_VERSION/plugins/" \
&& rm source.tar.gz

COPY entrypoint.sh /usr/local/bin/
ENTRYPOINT [ "entrypoint.sh", "docker-php-entrypoint" ]

USER adminer
CMD [ "php", "-S", "[::]:8080", "-t", "/var/www/html" ]

EXPOSE 8080
20 changes: 20 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
set -e

if [ -n "$ADMINER_DESIGN" ]; then
# Only create link on initial start, to ensure that explicit changes to
# adminer.css after the container was started once are preserved.
if [ ! -e .adminer-init ]; then
ln -sf "designs/$ADMINER_DESIGN/adminer.css" .
fi
fi

number=1
for PLUGIN in $ADMINER_PLUGINS; do
php plugin-loader.php "$PLUGIN" > plugins-enabled/$(printf "%03d" $number)-$PLUGIN.php
number=$(($number+1))
done

touch .adminer-init || true

exec "$@"
43 changes: 43 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
namespace docker {
function adminer_object() {
require_once('plugins/plugin.php');

class Adminer extends \AdminerPlugin {
function _callParent($function, $args) {
if ($function === 'loginForm') {
ob_start();
$return = \Adminer::loginForm();
$form = ob_get_clean();

echo str_replace('name="auth[server]" value="" title="hostname[:port]"', 'name="auth[server]" value="'.($_ENV['ADMINER_DEFAULT_SERVER'] ?: 'db').'" title="hostname[:port]"', $form);

return $return;
}

return parent::_callParent($function, $args);
}
}

$plugins = [];
foreach (glob('plugins-enabled/*.php') as $plugin) {
$plugins[] = require($plugin);
}

return new Adminer($plugins);
}
}

namespace {
if (basename($_SERVER['DOCUMENT_URI']) === 'adminer.css' && is_readable('adminer.css')) {
header('Content-Type: text/css');
readfile('adminer.css');
exit;
}

function adminer_object() {
return \docker\adminer_object();
}

require('adminer.php');
}
Loading