diff options
-rw-r--r-- | Dockerfile.aarch64 | 37 | ||||
-rw-r--r-- | Dockerfile.aarch64hub | 46 | ||||
-rw-r--r-- | Dockerfile.rpi | 37 | ||||
-rw-r--r-- | Dockerfile.rpihub | 57 | ||||
-rw-r--r-- | docker/Dockerfile.aarch64 | 44 | ||||
-rw-r--r-- | docker/Dockerfile.rpi | 44 | ||||
-rw-r--r-- | docker/README.md | 2 | ||||
-rw-r--r-- | docker/aarch64/build.sh | 3 | ||||
-rwxr-xr-x | docker/aarch64/qemu-aarch64-static | bin | 3451880 -> 0 bytes | |||
-rwxr-xr-x | docker/aarch64/resin-xbuild | bin | 1422176 -> 0 bytes | |||
-rw-r--r-- | docker/aarch64/resin-xbuild.go | 67 | ||||
-rw-r--r-- | docker/armhf/build.sh | 3 | ||||
-rwxr-xr-x | docker/armhf/qemu-arm-static | bin | 3370216 -> 0 bytes | |||
-rwxr-xr-x | docker/armhf/resin-xbuild | bin | 1299072 -> 0 bytes | |||
-rw-r--r-- | docker/armhf/resin-xbuild.go | 67 | ||||
-rwxr-xr-x | docker/build-go.sh | 32 | ||||
-rwxr-xr-x | docker/build.sh | 31 | ||||
-rwxr-xr-x | docker/finalize.sh | 2 | ||||
-rw-r--r-- | docker/no-pic.patch | 16 |
19 files changed, 89 insertions, 399 deletions
diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 deleted file mode 100644 index 9ba104be..00000000 --- a/Dockerfile.aarch64 +++ /dev/null @@ -1,37 +0,0 @@ -FROM arm64v8/alpine:latest - -# Install system utils & Gogs runtime dependencies -ADD https://github.com/tianon/gosu/releases/download/1.9/gosu-arm64 /usr/sbin/gosu -RUN chmod +x /usr/sbin/gosu \ - && echo http://dl-2.alpinelinux.org/alpine/edge/community/ >> /etc/apk/repositories \ - && apk --no-cache --no-progress add \ - bash \ - ca-certificates \ - curl \ - git \ - linux-pam \ - openssh \ - s6 \ - shadow \ - socat \ - tzdata \ - rsync - -ENV GOGS_CUSTOM /data/gogs - -# Configure LibC Name Service -COPY docker/nsswitch.conf /etc/nsswitch.conf -COPY docker /app/gogs/docker - -WORKDIR /app/gogs/build -COPY . . - -RUN ./docker/build-go.sh \ - && ./docker/build.sh \ - && ./docker/finalize.sh - -# Configure Docker Container -VOLUME ["/data"] -EXPOSE 22 3000 -ENTRYPOINT ["/app/gogs/docker/start.sh"] -CMD ["/bin/s6-svscan", "/app/gogs/docker/s6/"] diff --git a/Dockerfile.aarch64hub b/Dockerfile.aarch64hub deleted file mode 100644 index 5bc16410..00000000 --- a/Dockerfile.aarch64hub +++ /dev/null @@ -1,46 +0,0 @@ -FROM arm64v8/alpine:latest - -ENV GOGS_CUSTOM /data/gogs -ENV QEMU_EXECVE 1 - -# For cross compile on dockerhub -################################ - -COPY ./docker/aarch64/qemu-aarch64-static /usr/bin/ -COPY ./docker/aarch64/resin-xbuild /usr/bin/ - -RUN [ "/usr/bin/qemu-aarch64-static", "/bin/sh", "-c", "ln -s resin-xbuild /usr/bin/cross-build-start; ln -s resin-xbuild /usr/bin/cross-build-end; ln /bin/sh /bin/sh.real" ] - -RUN [ "cross-build-start" ] - -# Prepare the container -####################### - -# Install system utils & Gogs runtime dependencies -ADD https://github.com/tianon/gosu/releases/download/1.10/gosu-arm64 /usr/sbin/gosu -RUN chmod +x /usr/sbin/gosu \ - && apk --no-cache --no-progress add ca-certificates bash git linux-pam s6 curl openssh shadow socat tzdata go=1.10.1-r0 - - - -COPY docker /app/gogs/docker -WORKDIR /app/gogs/build -COPY . . - -RUN ./docker/build.sh \ - && ./docker/finalize.sh - -# Configure LibC Name Service -COPY docker/nsswitch.conf /etc/nsswitch.conf - -# For cross compile on dockerhub -################################ - -RUN [ "cross-build-end" ] - -# Configure Docker Container -############################ -VOLUME ["/data"] -EXPOSE 22 3000 -ENTRYPOINT ["/app/gogs/docker/start.sh"] -CMD ["/bin/s6-svscan", "/app/gogs/docker/s6/"] diff --git a/Dockerfile.rpi b/Dockerfile.rpi deleted file mode 100644 index d6fe9616..00000000 --- a/Dockerfile.rpi +++ /dev/null @@ -1,37 +0,0 @@ -FROM arm32v7/alpine:latest - -# Install system utils & Gogs runtime dependencies -ADD https://github.com/tianon/gosu/releases/download/1.9/gosu-armhf /usr/sbin/gosu -RUN chmod +x /usr/sbin/gosu \ - && echo http://dl-2.alpinelinux.org/alpine/edge/community/ >> /etc/apk/repositories \ - && apk --no-cache --no-progress add \ - bash \ - ca-certificates \ - curl \ - git \ - linux-pam \ - openssh \ - s6 \ - shadow \ - socat \ - tzdata \ - rsync - -ENV GOGS_CUSTOM /data/gogs - -# Configure LibC Name Service -COPY docker/nsswitch.conf /etc/nsswitch.conf -COPY docker /app/gogs/docker - -WORKDIR /app/gogs/build -COPY . . - -RUN ./docker/build-go.sh \ - && ./docker/build.sh \ - && ./docker/finalize.sh - -# Configure Docker Container -VOLUME ["/data"] -EXPOSE 22 3000 -ENTRYPOINT ["/app/gogs/docker/start.sh"] -CMD ["/bin/s6-svscan", "/app/gogs/docker/s6/"] diff --git a/Dockerfile.rpihub b/Dockerfile.rpihub deleted file mode 100644 index d83a9f5a..00000000 --- a/Dockerfile.rpihub +++ /dev/null @@ -1,57 +0,0 @@ -FROM arm32v7/alpine:latest - -ENV GOGS_CUSTOM /data/gogs -ENV QEMU_EXECVE 1 - -# For cross compile on dockerhub -################################ - -COPY ./docker/armhf/qemu-arm-static /usr/bin/ -COPY ./docker/armhf/resin-xbuild /usr/bin/ - -RUN [ "/usr/bin/qemu-arm-static", "/bin/sh", "-c", "ln -s resin-xbuild /usr/bin/cross-build-start; ln -s resin-xbuild /usr/bin/cross-build-end; ln /bin/sh /bin/sh.real" ] - -RUN [ "cross-build-start" ] - -# Prepare the container -####################### - -# Install system utils & Gogs runtime dependencies -ADD https://github.com/tianon/gosu/releases/download/1.9/gosu-armhf /usr/sbin/gosu -RUN chmod +x /usr/sbin/gosu \ - && echo http://dl-2.alpinelinux.org/alpine/edge/community/ >> /etc/apk/repositories \ - && apk --no-cache --no-progress add \ - bash \ - ca-certificates \ - curl \ - git \ - linux-pam \ - openssh \ - s6 \ - shadow \ - socat \ - tzdata \ - rsync - -# Configure LibC Name Service -COPY docker/nsswitch.conf /etc/nsswitch.conf -COPY docker /app/gogs/docker - -WORKDIR /app/gogs/build -COPY . . - -RUN ./docker/build-go.sh \ - && ./docker/build.sh \ - && ./docker/finalize.sh - -# For cross compile on dockerhub -################################ - -RUN [ "cross-build-end" ] - -# Configure Docker Container -############################ -VOLUME ["/data"] -EXPOSE 22 3000 -ENTRYPOINT ["/app/gogs/docker/start.sh"] -CMD ["/bin/s6-svscan", "/app/gogs/docker/s6/"] diff --git a/docker/Dockerfile.aarch64 b/docker/Dockerfile.aarch64 new file mode 100644 index 00000000..730b7f87 --- /dev/null +++ b/docker/Dockerfile.aarch64 @@ -0,0 +1,44 @@ +FROM arm64v8/golang:1.14 AS binarybuilder +RUN apk --no-cache --no-progress add --virtual \ + build-deps \ + build-base \ + git \ + linux-pam-dev + +WORKDIR /gogs.io/gogs +COPY . . +RUN make build-no-gen TAGS="cert pam" + +FROM arm64v8/alpine:3.11 +ADD https://github.com/tianon/gosu/releases/download/1.11/gosu-arm64 /usr/sbin/gosu +RUN chmod +x /usr/sbin/gosu \ + && echo http://dl-2.alpinelinux.org/alpine/edge/community/ >> /etc/apk/repositories \ + && apk --no-cache --no-progress add \ + bash \ + ca-certificates \ + curl \ + git \ + linux-pam \ + openssh \ + s6 \ + shadow \ + socat \ + tzdata \ + rsync + +ENV GOGS_CUSTOM /data/gogs + +# Configure LibC Name Service +COPY docker/nsswitch.conf /etc/nsswitch.conf + +WORKDIR /app/gogs +COPY docker ./docker +COPY --from=binarybuilder /gogs.io/gogs/gogs . + +RUN ./docker/finalize.sh + +# Configure Docker Container +VOLUME ["/data"] +EXPOSE 22 3000 +ENTRYPOINT ["/app/gogs/docker/start.sh"] +CMD ["/bin/s6-svscan", "/app/gogs/docker/s6/"] diff --git a/docker/Dockerfile.rpi b/docker/Dockerfile.rpi new file mode 100644 index 00000000..b1c61b0e --- /dev/null +++ b/docker/Dockerfile.rpi @@ -0,0 +1,44 @@ +FROM arm32v7/golang:1.14 AS binarybuilder +RUN apk --no-cache --no-progress add --virtual \ + build-deps \ + build-base \ + git \ + linux-pam-dev + +WORKDIR /gogs.io/gogs +COPY . . +RUN make build-no-gen TAGS="cert pam" + +FROM arm32v7/alpine:3.11 +ADD https://github.com/tianon/gosu/releases/download/1.11/gosu-arm64 /usr/sbin/gosu +RUN chmod +x /usr/sbin/gosu \ + && echo http://dl-2.alpinelinux.org/alpine/edge/community/ >> /etc/apk/repositories \ + && apk --no-cache --no-progress add \ + bash \ + ca-certificates \ + curl \ + git \ + linux-pam \ + openssh \ + s6 \ + shadow \ + socat \ + tzdata \ + rsync + +ENV GOGS_CUSTOM /data/gogs + +# Configure LibC Name Service +COPY docker/nsswitch.conf /etc/nsswitch.conf + +WORKDIR /app/gogs +COPY docker ./docker +COPY --from=binarybuilder /gogs.io/gogs/gogs . + +RUN ./docker/finalize.sh + +# Configure Docker Container +VOLUME ["/data"] +EXPOSE 22 3000 +ENTRYPOINT ["/app/gogs/docker/start.sh"] +CMD ["/bin/s6-svscan", "/app/gogs/docker/s6/"] diff --git a/docker/README.md b/docker/README.md index df240459..30542316 100644 --- a/docker/README.md +++ b/docker/README.md @@ -73,7 +73,7 @@ $ docker run --name=gogs -p 10022:22 -p 10080:3000 -v gogs-data:/data gogs/gogs Most of settings are obvious and easy to understand, but there are some settings can be confusing by running Gogs inside Docker: - **Repository Root Path**: keep it as default value `/home/git/gogs-repositories` because `start.sh` already made a symbolic link for you. -- **Run User**: keep it as default value `git` because `build.sh` already setup a user with name `git`. +- **Run User**: keep it as default value `git` because `finalize.sh` already setup a user with name `git`. - **Domain**: fill in with Docker container IP (e.g. `192.168.99.100`). But if you want to access your Gogs instance from a different physical machine, please fill in with the hostname or IP address of the Docker host machine. - **SSH Port**: Use the exposed port from Docker container. For example, your SSH server listens on `22` inside Docker, **but** you expose it by `10022:22`, then use `10022` for this value. **Builtin SSH server is not recommended inside Docker Container** - **HTTP Port**: Use port you want Gogs to listen on inside Docker container. For example, your Gogs listens on `3000` inside Docker, **and** you expose it by `10080:3000`, but you still use `3000` for this value. diff --git a/docker/aarch64/build.sh b/docker/aarch64/build.sh deleted file mode 100644 index d864f4b3..00000000 --- a/docker/aarch64/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -go build -ldflags "-w -s" resin-xbuild.go diff --git a/docker/aarch64/qemu-aarch64-static b/docker/aarch64/qemu-aarch64-static Binary files differdeleted file mode 100755 index f44233bc..00000000 --- a/docker/aarch64/qemu-aarch64-static +++ /dev/null diff --git a/docker/aarch64/resin-xbuild b/docker/aarch64/resin-xbuild Binary files differdeleted file mode 100755 index 3996ea53..00000000 --- a/docker/aarch64/resin-xbuild +++ /dev/null diff --git a/docker/aarch64/resin-xbuild.go b/docker/aarch64/resin-xbuild.go deleted file mode 100644 index 7e4ead56..00000000 --- a/docker/aarch64/resin-xbuild.go +++ /dev/null @@ -1,67 +0,0 @@ -//nolint -package main - -import ( - "log" - "os" - "os/exec" - "syscall" -) - -func crossBuildStart() { - err := os.Remove("/bin/sh") - if err != nil { - log.Fatal(err) - } - err = os.Link("/usr/bin/resin-xbuild", "/bin/sh") - if err != nil { - log.Fatal(err) - } -} - -func crossBuildEnd() { - err := os.Remove("/bin/sh") - if err != nil { - log.Fatal(err) - } - err = os.Link("/bin/sh.real", "/bin/sh") - if err != nil { - log.Fatal(err) - } -} - -func runShell() error { - cmd := exec.Command("/usr/bin/qemu-aarch64-static", append([]string{"-0", "/bin/sh", "/bin/sh"}, os.Args[1:]...)...) - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - return cmd.Run() -} - -func main() { - switch os.Args[0] { - case "cross-build-start": - crossBuildStart() - case "cross-build-end": - crossBuildEnd() - case "/bin/sh": - code := 0 - crossBuildEnd() - - if err := runShell(); err != nil { - code = 1 - if exiterr, ok := err.(*exec.ExitError); ok { - if status, ok := exiterr.Sys().(syscall.WaitStatus); ok { - code = status.ExitStatus() - } - } - } - - crossBuildStart() - - // Hack to bypass apk issues with triggering - code = 0 - - os.Exit(code) - } -} diff --git a/docker/armhf/build.sh b/docker/armhf/build.sh deleted file mode 100644 index d864f4b3..00000000 --- a/docker/armhf/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -go build -ldflags "-w -s" resin-xbuild.go diff --git a/docker/armhf/qemu-arm-static b/docker/armhf/qemu-arm-static Binary files differdeleted file mode 100755 index bf5897b1..00000000 --- a/docker/armhf/qemu-arm-static +++ /dev/null diff --git a/docker/armhf/resin-xbuild b/docker/armhf/resin-xbuild Binary files differdeleted file mode 100755 index 5471f249..00000000 --- a/docker/armhf/resin-xbuild +++ /dev/null diff --git a/docker/armhf/resin-xbuild.go b/docker/armhf/resin-xbuild.go deleted file mode 100644 index fb749449..00000000 --- a/docker/armhf/resin-xbuild.go +++ /dev/null @@ -1,67 +0,0 @@ -//nolint -package main - -import ( - "log" - "os" - "os/exec" - "syscall" -) - -func crossBuildStart() { - err := os.Remove("/bin/sh") - if err != nil { - log.Fatal(err) - } - err = os.Link("/usr/bin/resin-xbuild", "/bin/sh") - if err != nil { - log.Fatal(err) - } -} - -func crossBuildEnd() { - err := os.Remove("/bin/sh") - if err != nil { - log.Fatal(err) - } - err = os.Link("/bin/sh.real", "/bin/sh") - if err != nil { - log.Fatal(err) - } -} - -func runShell() error { - cmd := exec.Command("/usr/bin/qemu-arm-static", append([]string{"-0", "/bin/sh", "/bin/sh"}, os.Args[1:]...)...) - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - return cmd.Run() -} - -func main() { - switch os.Args[0] { - case "cross-build-start": - crossBuildStart() - case "cross-build-end": - crossBuildEnd() - case "/bin/sh": - code := 0 - crossBuildEnd() - - if err := runShell(); err != nil { - code = 1 - if exiterr, ok := err.(*exec.ExitError); ok { - if status, ok := exiterr.Sys().(syscall.WaitStatus); ok { - code = status.ExitStatus() - } - } - } - - crossBuildStart() - - // Hack to bypass apk issues with triggering - code = 0 - - os.Exit(code) - } -} diff --git a/docker/build-go.sh b/docker/build-go.sh deleted file mode 100755 index 22e3724d..00000000 --- a/docker/build-go.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Build GO version as specified in Dockerfile - -set -x -set -e - -# Components versions -export GOLANG_VERSION="1.8" -export GOLANG_SRC_URL="https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz" -export GOLANG_SRC_SHA256="406865f587b44be7092f206d73fc1de252600b79b3cacc587b74b5ef5c623596" - - -# Install build tools -apk add --no-cache --no-progress --virtual build-deps-go gcc musl-dev openssl go - -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/build/docker/no-pic.patch -./make.bash - -# Clean -rm /app/gogs/build/docker/*.patch -apk del build-deps-go diff --git a/docker/build.sh b/docker/build.sh deleted file mode 100755 index ebcdb89c..00000000 --- a/docker/build.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -set -x -set -e - -# Set temp environment vars -export GOPATH=/tmp/go -export PATH=/usr/local/go/bin:${PATH}:${GOPATH}/bin - -# Install build deps -apk --no-cache --no-progress add --virtual build-deps build-base linux-pam-dev - -# Build Gogs -mkdir -p ${GOPATH}/src/github.com/gogs/ -ln -s /app/gogs/build ${GOPATH}/src/github.com/gogs/gogs -cd ${GOPATH}/src/github.com/gogs/gogs -# Needed since git 2.9.3 or 2.9.4 -git config --global http.https://gopkg.in.followRedirects true -make build TAGS="sqlite cert pam" - -# Cleanup GOPATH -rm -r $GOPATH - -# Remove build deps -apk --no-progress del build-deps - -# Move to final place -mv /app/gogs/build/gogs /app/gogs/ - -# Cleanup go -rm -rf /tmp/go -rm -rf /usr/local/go diff --git a/docker/finalize.sh b/docker/finalize.sh index 5880aae3..4038b16d 100755 --- a/docker/finalize.sh +++ b/docker/finalize.sh @@ -11,8 +11,6 @@ echo "export GOGS_CUSTOM=${GOGS_CUSTOM}" >> /etc/profile # Final cleaning rm -rf /app/gogs/build -rm /app/gogs/docker/build.sh -rm /app/gogs/docker/build-go.sh rm /app/gogs/docker/finalize.sh rm /app/gogs/docker/nsswitch.conf rm /app/gogs/docker/README.md diff --git a/docker/no-pic.patch b/docker/no-pic.patch deleted file mode 100644 index 9da79921..00000000 --- a/docker/no-pic.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go -index 14f4fa9..5599307 100644 ---- a/src/cmd/link/internal/ld/lib.go -+++ b/src/cmd/link/internal/ld/lib.go -@@ -1272,6 +1272,11 @@ func hostlink() { - argv = append(argv, peimporteddlls()...) - } - -+ // The Go linker does not currently support building PIE -+ // executables when using the external linker. See: -+ // https://github.com/golang/go/issues/6940 -+ argv = append(argv, "-fno-PIC") -+ - if l.Debugvlog != 0 { - l.Logf("%5.2f host link:", obj.Cputime()) - for _, v := range argv { |