update travis for docker push

This commit is contained in:
codeskyblue
2018-09-26 13:52:24 +08:00
parent 22555ed424
commit d7b886751b
5 changed files with 44 additions and 4 deletions

View File

@@ -1,3 +1,6 @@
sudo: required
services:
- docker
language: go
go:
- "1.10"
@@ -10,3 +13,7 @@ deploy:
on:
tags: true
condition: $TRAVIS_OS_NAME = linux
- provider: script
script: bash docker/docker_push
on:
branch: master

View File

@@ -84,7 +84,7 @@ Share current directory with http basic auth
```bash
docker run -it --rm -p 8000:8000 -v $PWD:/app/public --name gohttpserver \
codeskyblue/gohttpserver --root /app/public \
codeskyblue/gohttpserver \
--auth-type http --auth-http username:password
```
@@ -92,7 +92,7 @@ Share current directory with openid auth. (Works only in netease company.)
```bash
docker run -it --rm -p 8000:8000 -v $PWD:/app/public --name gohttpserver \
codeskyblue/gohttpserver --root /app/public \
codeskyblue/gohttpserver \
--auth-type openid
```

View File

@@ -12,5 +12,5 @@ VOLUME /app/public
ADD assets ./assets
COPY --from=0 /go/src/github.com/codeskyblue/gohttpserver/gohttpserver .
EXPOSE 8000
ENTRYPOINT [ "/app/gohttpserver" ]
CMD ["--root=/app/public"]
ENTRYPOINT [ "/app/gohttpserver", "--root=/app/public" ]
CMD []

16
docker/Dockerfile.armhf Normal file
View File

@@ -0,0 +1,16 @@
FROM golang:1.10
WORKDIR /go/src/github.com/codeskyblue/gohttpserver
ADD . /go/src/github.com/codeskyblue/gohttpserver/
RUN go get -v
RUN GOOS=linux GOARCH=arm go build -o gohttpserver .
FROM multiarch/debian-debootstrap:armhf-stretch
WORKDIR /app
RUN mkdir -p /app/public
RUN apt-get update && apt-get install -y ca-certificates
VOLUME /app/public
ADD assets ./assets
COPY --from=0 /go/src/github.com/codeskyblue/gohttpserver/gohttpserver .
EXPOSE 8000
ENTRYPOINT [ "/app/gohttpserver", "--root=/app/public" ]
CMD []

17
docker/docker_push Normal file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
#
# article: https://lantian.pub/article/modify-computer/build-arm-docker-image-on-x86-docker-hub-travis-automatic-build.lantian
set -ex
docker run --rm --privileged multiarch/qemu-user-static:register --reset
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
IMAGE_NAME="gohttpserver"
# arm linux for respberry
docker build -t $DOCKER_USERNAME/$IMAGE_NAME:armhf -f Dockerfile.armhf docker
# x86 linux
docker build -t $DOCKER_USERNAME/$IMAGE_NAME -f Dockerfile docker
docker push $DOCKER_USERNAME/$IMAGE_NAME