diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4dfd452..f81841c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,6 +31,22 @@ arm32v7 postgres build: - echo "$QUAY_PASSWORD" | docker login -u "$QUAY_USERNAME" quay.io --password-stdin && docker push $DOCKER_REGISTRY_QUAY/$DOCKER_REGISTRY_QUAY_REPO:arm32v7 - echo "$QUAY_PASSWORD" | docker login -u "$QUAY_USERNAME" quay.io --password-stdin && docker push $DOCKER_REGISTRY_QUAY/$DOCKER_REGISTRY_QUAY_REPO:armhf +arm64v8 postgres build: + stage: yobasystems/alpine-docker:aarch64-dind + stage: build + tags: + - aarch64 + script: + - apk add --update git + - echo "$CI_JOB_TOKEN" | docker login -u gitlab-ci-token "$DOCKER_REGISTRY" --password-stdin + - cd alpine-postgres-aarch64/ && docker build -t $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:arm64v8 -t $DOCKER_REGISTRY_DOCKERHUB_REPO:arm64v8 -t $DOCKER_REGISTRY_QUAY/$DOCKER_REGISTRY_QUAY_REPO:arm64v8 -t $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:aarch64 -t $DOCKER_REGISTRY_DOCKERHUB_REPO:aarch64 -t $DOCKER_REGISTRY_QUAY/$DOCKER_REGISTRY_QUAY_REPO:aarch64 . + - docker push $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:arm64v8 + - docker push $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:aarch64 + - echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin && docker push $DOCKER_REGISTRY_DOCKERHUB_REPO:arm64v8 + - echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin && docker push $DOCKER_REGISTRY_DOCKERHUB_REPO:aarch64 + - echo "$QUAY_PASSWORD" | docker login -u "$QUAY_USERNAME" quay.io --password-stdin && docker push $DOCKER_REGISTRY_QUAY/$DOCKER_REGISTRY_QUAY_REPO:arm64v8 + - echo "$QUAY_PASSWORD" | docker login -u "$QUAY_USERNAME" quay.io --password-stdin && docker push $DOCKER_REGISTRY_QUAY/$DOCKER_REGISTRY_QUAY_REPO:aarch64 + Github Mirror: stage: deploy tags: diff --git a/alpine-postgres-aarch64/Dockerfile b/alpine-postgres-aarch64/Dockerfile new file mode 100644 index 0000000..3435591 --- /dev/null +++ b/alpine-postgres-aarch64/Dockerfile @@ -0,0 +1,21 @@ +FROM yobasystems/alpine:3.9.0-aarch64 +LABEL maintainer "Dominic Taylor " architecture="ARM64v8/aarch64" +LABEL postgres-version="11.1" alpine-version="3.9.0" date="11-Feb-2018" + +ENV LANG en_GB.utf8 +ENV PGDATA /var/lib/postgresql/data + +RUN apk update && \ + apk add su-exec tzdata libpq postgresql-client postgresql postgresql-contrib && \ + mkdir /docker-entrypoint-initdb.d && \ + rm -rf /var/cache/apk/* + + +VOLUME /var/lib/postgresql/data + +COPY files/docker-entrypoint.sh / + +ENTRYPOINT ["/docker-entrypoint.sh"] + +EXPOSE 5432 +CMD ["postgres"] diff --git a/alpine-postgres-aarch64/files/docker-entrypoint.sh b/alpine-postgres-aarch64/files/docker-entrypoint.sh new file mode 100644 index 0000000..acbead5 --- /dev/null +++ b/alpine-postgres-aarch64/files/docker-entrypoint.sh @@ -0,0 +1,59 @@ +#!/bin/sh +chown -R postgres "$PGDATA" + +if [ -z "$(ls -A "$PGDATA")" ]; then + gosu postgres initdb + sed -ri "s/^#(listen_addresses\s*=\s*)\S+/\1'*'/" "$PGDATA"/postgresql.conf + + : ${POSTGRES_USER:="postgres"} + : ${POSTGRES_DB:=$POSTGRES_USER} + + if [ "$POSTGRES_PASSWORD" ]; then + pass="PASSWORD '$POSTGRES_PASSWORD'" + authMethod=md5 + else + echo "===============================" + echo "!!! NO PASSWORD SET !!! (Use \$POSTGRES_PASSWORD env var)" + echo "===============================" + pass= + authMethod=trust + fi + echo + + + if [ "$POSTGRES_DB" != 'postgres' ]; then + createSql="CREATE DATABASE $POSTGRES_DB;" + echo $createSql | gosu postgres postgres --single -jE + echo + fi + + if [ "$POSTGRES_USER" != 'postgres' ]; then + op=CREATE + else + op=ALTER + fi + + userSql="$op USER $POSTGRES_USER WITH SUPERUSER $pass;" + echo $userSql | gosu postgres postgres --single -jE + echo + + gosu postgres pg_ctl -D "$PGDATA" \ + -o "-c listen_addresses=''" \ + -w start + + echo + for f in /docker-entrypoint-initdb.d/*; do + case "$f" in + *.sh) echo "$0: running $f"; . "$f" ;; + *.sql) echo "$0: running $f"; psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < "$f" && echo ;; + *) echo "$0: ignoring $f" ;; + esac + echo + done + + gosu postgres pg_ctl -D "$PGDATA" -m fast -w stop + + { echo; echo "host all all 0.0.0.0/0 $authMethod"; } >> "$PGDATA"/pg_hba.conf +fi + +exec gosu postgres "$@"