Browse Source

Simplify Dockerfile with a dedicated build-go.sh script

In order to have a + simple Dockerfile, Go building commands are now
isolated in a dedicated script

Refs: [ #4145 ]
pull/4150/head
Yaourt 8 years ago
parent
commit
8e97b25a85
  1. 41
      Dockerfile
  2. 22
      docker/build-go.sh
  3. 18
      docker/build.sh

41
Dockerfile

@ -29,45 +29,8 @@ CMD ["/bin/s6-svscan", "/app/gogs/docker/s6/"]
## Build Golang & Gogs
# https://golang.org/issue/14851
#COPY no-pic.patch /
COPY docker /app/gogs/docker
RUN set -ex \
&& apk add --no-cache --virtual .build-deps \
bash \
gcc \
musl-dev \
openssl \
go \
build-base \
linux-pam-dev \
\
&& export GOROOT_BOOTSTRAP="$(go env GOROOT)" \
\
&& wget -q "$GOLANG_SRC_URL" -O golang.tar.gz \
&& echo "$GOLANG_SRC_SHA256 golang.tar.gz" | sha256sum -c - \
&& tar -C /usr/local -xzf golang.tar.gz \
&& rm golang.tar.gz \
&& cd /usr/local/go/src \
&& patch -p2 -i /app/gogs/docker/no-pic.patch \
&& ./make.bash \
\
&& rm /app/gogs/docker/*.patch \
&& git config --global http.https://gopkg.in.followRedirects true \
&& cd /app/gogs/docker/ \
&& sh /app/gogs/docker/build.sh \
&& rm /app/gogs/docker/build.sh \
&& rm /app/gogs/docker/nsswitch.conf \
&& rm /app/gogs/docker/README.md \
&& apk del .build-deps \
&& mv /go/src/github.com/gogits/gogs/gogs /app/gogs/ \
&& mv /go/src/github.com/gogits/gogs/templates /app/gogs/ \
&& mv /go/src/github.com/gogits/gogs/scripts /app/gogs/ \
&& mv /go/src/github.com/gogits/gogs/public /app/gogs/ \
&& rm -rf /go \
&& rm -rf /usr/local/go
&& sh /app/gogs/docker/build-go.sh \
&& sh /app/gogs/docker/build.sh

22
docker/build-go.sh

@ -0,0 +1,22 @@
#!/bin/sh
# Build GO version as specified in Dockerfile
# Install build tools
apk add --no-cache --virtual .build-deps bash gcc musl-dev openssl go build-base linux-pam-dev
export GOROOT_BOOTSTRAP="$(go env GOROOT)"
# Download Go
wget -q "$GOLANG_SRC_URL" -O golang.tar.gz
echo "$GOLANG_SRC_SHA256 golang.tar.gz" | sha256sum -c -
tar -C /usr/local -xzf golang.tar.gz
rm golang.tar.gz
# Build
cd /usr/local/go/src
# see https://golang.org/issue/14851
patch -p2 -i /app/gogs/docker/no-pic.patch
./make.bash
# Clean
rm /app/gogs/docker/*.patch

18
docker/build.sh

@ -15,4 +15,20 @@ make build TAGS="sqlite cert pam"
# Create git user for Gogs
adduser -H -D -g 'Gogs Git User' git -h /data/git -s /bin/bash && passwd -u git
echo "export GOGS_CUSTOM=${GOGS_CUSTOM}" >> /etc/profile
echo "export GOGS_CUSTOM=${GOGS_CUSTOM}" >> /etc/profile
# Move to final place
mv /go/src/github.com/gogits/gogs/gogs /app/gogs/
mv /go/src/github.com/gogits/gogs/templates /app/gogs/
mv /go/src/github.com/gogits/gogs/scripts /app/gogs/
mv /go/src/github.com/gogits/gogs/public /app/gogs/
# Final cleaning
rm /app/gogs/docker/build.sh
rm /app/gogs/docker/build-go.sh
rm /app/gogs/docker/nsswitch.conf
rm /app/gogs/docker/README.md
rm -rf /go
rm -rf /usr/local/go
apk del .build-deps
Loading…
Cancel
Save