Skip to content

Commit

Permalink
docker: add new Dockerfile.docker-ce for docker-ce(>=v17.06) to build…
Browse files Browse the repository at this point in the history
… docker image (gogs#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
  • Loading branch information
alimy authored and unknwon committed Aug 13, 2018
1 parent 1f247cf commit cc95d25
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
2 changes: 0 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
.git
.git/**
packager
packager/**
scripts
Expand Down
24 changes: 14 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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"]
Expand Down
10 changes: 6 additions & 4 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 4 additions & 5 deletions docker/finalize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit cc95d25

Please sign in to comment.