add docker-credential-pass to dev img and use it in travis

This commit is contained in:
1138-4EB 2018-08-06 00:37:16 +01:00
parent 2592c5eb43
commit 5ab5c7c243
3 changed files with 42 additions and 7 deletions

View File

@ -6,6 +6,7 @@ addons:
apt:
packages:
- docker-ce
- pass
env:
global:
- USE_DOCKER="true"
@ -30,7 +31,7 @@ jobs:
script:
- cp dockerfiles/filebrowser Dockerfile
- docker build -t filebrowser/filebrowser .
- echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
- ./build/docker_login.sh
- docker push filebrowser/filebrowser
- docker logout
on:
@ -40,7 +41,7 @@ jobs:
- stage: release
script:
- cp dockerfiles/filebrowser Dockerfile
- echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
- ./build/docker_login.sh
- docker run --rm -itv $(pwd):$WDIR -v /var/run/docker.sock:/var/run/docker.sock filebrowser/dev goreleaser
- docker logout
if: tag IS present

27
build/docker_login.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/sh
set -e
# init key for pass
gpg --batch --gen-key <<-EOF
%echo Generating a standard key
Key-Type: DSA
Key-Length: 1024
Subkey-Type: ELG-E
Subkey-Length: 1024
Name-Real: Meshuggah Rocks
Name-Email: meshuggah@example.com
Expire-Date: 0
# Do a commit here, so that we can later print "done" :-)
%commit
%echo done
EOF
key=$(gpg --no-auto-check-trustdb --list-secret-keys | grep ^sec | cut -d/ -f2 | cut -d" " -f1)
pass init $key
if [ "$(command -v docker-credential-pass)" = "" ]; then
docker run --rm -itv /usr/local/bin:/src filebrowser/dev sh -c "cp /go/bin/docker-credential-pass /src"
fi
echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin

View File

@ -23,5 +23,12 @@ RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/reposit
chmod +x /go/bin/dep && \
curl -sL https://git.io/goreleaser -o /go/bin/goreleaser && \
chmod +x /go/bin/goreleaser && \
curl -fsSL https://download.docker.com/linux/static/edge/x86_64/docker-18.05.0-ce.tgz | tar xvz --strip-components=1 docker/docker -C /usr/local/bin && \
chmod +x /usr/local/bin/docker
curl -fsSL https://download.docker.com/linux/static/edge/x86_64/docker-18.05.0-ce.tgz | tar xvz --strip-components=1 docker/docker -C /go/bin && \
chmod +x /go/bin/docker && \
curl -fsSL $( \
curl -s https://api.github.com/repos/docker/docker-credential-helpers/releases/latest \
| grep "browser_download_url.*pass-.*-amd64" \
| cut -d : -f 2,3 \
| tr -d \" \
) | tar xv -C /go/bin && \
chmod + /go/bin/docker-credential-pass