Browse Source

docker: add new Dockerfile.docker-ce for docker-ce(>=v17.06) to build docker image (#5322)

* add new Dockerfile.docker-ce for docker-ce(>=v17.06) to  build docker image

* change default Dockerfile to support docker-ce(>=v17.06) multi-stage build
pull/5380/head
Michael Li 6 years ago committed by 无闻
parent
commit
cc95d251d6
  1. 2
      .dockerignore
  2. 24
      Dockerfile
  3. 10
      docker/build.sh
  4. 9
      docker/finalize.sh

2
.dockerignore

@ -1,5 +1,3 @@
.git
.git/**
packager
packager/**
scripts

24
Dockerfile

@ -1,7 +1,13 @@
FROM alpine:3.5
FROM golang:alpine AS binarybuilder
# Install build deps
RUN apk --no-cache --no-progress add --virtual build-deps build-base git linux-pam-dev
WORKDIR /go/src/github.com/gogs/gogs
COPY . .
RUN make build TAGS="sqlite cert pam"
FROM alpine:latest
# Install system utils & Gogs runtime dependencies
ADD https://github.com/tianon/gosu/releases/download/1.9/gosu-amd64 /usr/sbin/gosu
ADD https://github.com/tianon/gosu/releases/download/1.10/gosu-amd64 /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 \
@ -20,16 +26,14 @@ ENV GOGS_CUSTOM /data/gogs
# Configure LibC Name Service
COPY docker/nsswitch.conf /etc/nsswitch.conf
COPY docker /app/gogs/docker
COPY templates /app/gogs/templates
COPY public /app/gogs/public
WORKDIR /app/gogs/build
COPY . .
WORKDIR /app/gogs
COPY docker ./docker
COPY templates ./templates
COPY public ./public
COPY --from=binarybuilder /go/src/github.com/gogs/gogs/gogs .
RUN ./docker/build-go.sh \
&& ./docker/build.sh \
&& ./docker/finalize.sh
RUN ./docker/finalize.sh
# Configure Docker Container
VOLUME ["/data"]

10
docker/build.sh

@ -23,7 +23,9 @@ rm -r $GOPATH
# Remove build deps
apk --no-progress del build-deps
# Create git user for Gogs
addgroup -S git
adduser -G git -H -D -g 'Gogs Git User' git -h /data/git -s /bin/bash && usermod -p '*' git && passwd -u git
echo "export GOGS_CUSTOM=${GOGS_CUSTOM}" >> /etc/profile
# Move to final place
mv /app/gogs/build/gogs /app/gogs/
# Cleanup go
rm -rf /tmp/go
rm -rf /usr/local/go

9
docker/finalize.sh

@ -4,8 +4,10 @@
set -x
set -e
# Move to final place
mv /app/gogs/build/gogs /app/gogs/
# Create git user for Gogs
addgroup -S git
adduser -G git -H -D -g 'Gogs Git User' git -h /data/git -s /bin/bash && usermod -p '*' git && passwd -u git
echo "export GOGS_CUSTOM=${GOGS_CUSTOM}" >> /etc/profile
# Final cleaning
rm -rf /app/gogs/build
@ -14,6 +16,3 @@ 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
rm -rf /tmp/go
rm -rf /usr/local/go

Loading…
Cancel
Save