Просмотр исходного кода

Update docker/build.sh script to use glide & make (#3079)

* docker: update build script to use glide + make

- docker/build.sh will now use glide to fetch dependencies
- glide is built from source to keep compatibility with arm
  (no pre-prebuilt binary for arm)
- docker/build.sh will also now use the provided Makefile
  It will generate an error when trying to get git build has as we do
  not ship the 88mo .git directory during the build (should not cause
  any problem as the variable it sets was not set previously)

* docker: fix docker arm build

- drop gosu version back to 1.7 as gosu binary for armhf is broken
- see tianon/gosu#19

* docker: update gosu to 1.9

Signed-off-by: Jean-Philippe Roemer <jp@roemer.im>
Jean-Philippe Roemer лет назад: 7
Родитель
Сommit
bcd4adb3a0
4 измененных файлов с 20 добавлено и 13 удалено
  1. 3 5
      .dockerignore
  2. 1 1
      Dockerfile
  3. 1 1
      Dockerfile.rpi
  4. 15 6
      docker/build.sh

+ 3 - 5
.dockerignore

@@ -1,7 +1,5 @@
 .git
 .git/**
-conf
-conf/**
 packager
 packager/**
 scripts
@@ -9,13 +7,13 @@ scripts/**
 .github/
 .github/**
 config.codekit
-LICENSE
-Makefile
 .dockerignore
 *.yml
 *.md
 .bra.toml
 .editorconfig
 .gitignore
-.gopmfile
 Dockerfile*
+vendor
+vendor/**
+gogs

+ 1 - 1
Dockerfile

@@ -2,7 +2,7 @@ FROM alpine:3.3
 MAINTAINER jp@roemer.im
 
 # Install system utils & Gogs runtime dependencies
-ADD https://github.com/tianon/gosu/releases/download/1.7/gosu-amd64 /usr/sbin/gosu
+ADD https://github.com/tianon/gosu/releases/download/1.9/gosu-amd64 /usr/sbin/gosu
 RUN chmod +x /usr/sbin/gosu \
  && apk --no-cache --no-progress add ca-certificates bash git linux-pam s6 curl openssh socat
 

+ 1 - 1
Dockerfile.rpi

@@ -2,7 +2,7 @@ FROM hypriot/rpi-alpine-scratch:v3.2
 MAINTAINER jp@roemer.im, raxetul@gmail.com
 
 # Install system utils & Gogs runtime dependencies
-ADD https://github.com/tianon/gosu/releases/download/1.7/gosu-armhf /usr/sbin/gosu
+ADD https://github.com/tianon/gosu/releases/download/1.9/gosu-armhf /usr/sbin/gosu
 RUN chmod +x /usr/sbin/gosu \
  && echo "http://dl-4.alpinelinux.org/alpine/v3.3/main/"      | tee /etc/apk/repositories    \
  && echo "http://dl-4.alpinelinux.org/alpine/v3.3/community/" | tee -a /etc/apk/repositories \

+ 15 - 6
docker/build.sh

@@ -5,19 +5,28 @@ set -e
 # Set temp environment vars
 export GOPATH=/tmp/go
 export PATH=${PATH}:${GOPATH}/bin
+export GO15VENDOREXPERIMENT=1
 
 # Install build deps
-apk --no-cache --no-progress add --virtual build-deps linux-pam-dev go gcc musl-dev
+apk --no-cache --no-progress add --virtual build-deps build-base linux-pam-dev go
 
-# Init go environment to build Gogs
+# Install glide
+git clone -b 0.10.2 https://github.com/Masterminds/glide ${GOPATH}/src/github.com/Masterminds/glide
+cd ${GOPATH}/src/github.com/Masterminds/glide
+make build
+go install
+
+
+
+# Build Gogs
 mkdir -p ${GOPATH}/src/github.com/gogits/
 ln -s /app/gogs/ ${GOPATH}/src/github.com/gogits/gogs
 cd ${GOPATH}/src/github.com/gogits/gogs
-go get -v -tags "sqlite cert pam"
-go build -tags "sqlite cert pam"
+glide install
+make build TAGS="sqlite cert pam"
 
-# Cleanup GOPATH
-rm -r $GOPATH
+# Cleanup GOPATH & vendoring dir
+rm -r $GOPATH /app/gogs/vendor
 
 # Remove build deps
 apk --no-progress del build-deps