summaryrefslogtreecommitdiffstats
path: root/Dockerfile
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-08-25 12:41:01 +0800
committerUnknwon <u@gogs.io>2015-08-25 12:41:01 +0800
commitbe90ea583a3d65566be8bfbf3440cf0c20557972 (patch)
treeea2d6e06951bdfd63b36cf6f2a5635c9d9f0f47e /Dockerfile
parentc256fc4438488558c2976858bc0f7cf451aa641d (diff)
downloadgitea-be90ea583a3d65566be8bfbf3440cf0c20557972.tar.gz
gitea-be90ea583a3d65566be8bfbf3440cf0c20557972.zip
#1521 reduce Docker image size
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile73
1 files changed, 44 insertions, 29 deletions
diff --git a/Dockerfile b/Dockerfile
index baba8f19d3..9186a47116 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,39 +1,54 @@
-FROM google/golang:latest
-MAINTAINER codeskyblue@gmail.com
-
-RUN echo "deb http://ftp.debian.org/debian/ wheezy-backports main" >> /etc/apt/sources.list
-RUN apt-get update
-RUN apt-get install -y openssh-server rsync libpam-dev
-
-# set the working directory and add current stuff
-COPY . /gopath/src/github.com/gogits/gogs/
+FROM google/debian:wheezy
+MAINTAINER u@gogs.io
+
+RUN echo "deb http://ftp.debian.org/debian/ wheezy-backports main" >> /etc/apt/sources.list && \
+ apt-get update -qqy && \
+ apt-get install --no-install-recommends -qqy \
+ curl build-essential ca-certificates git \
+ openssh-server rsync libpam-dev && \
+ apt-get autoclean && \
+ apt-get autoremove && \
+ rm -rf /var/lib/apt/lists/*
+
+ENV GOROOT /goroot
+ENV GOPATH /gopath
+ENV PATH $PATH:$GOROOT/bin:$GOPATH/bin
+
+COPY . /gopath/src/github.com/gogits/gogs/
WORKDIR /gopath/src/github.com/gogits/gogs/
-RUN go get -v -tags "sqlite redis memcache cert pam"
-RUN go build -tags "sqlite redis memcache cert pam"
+# Build binary and clean up useless files
+RUN mkdir /goroot && \
+ curl https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz | tar xzf - -C /goroot --strip-components=1 && \
+ go get -v -tags "sqlite redis memcache cert pam" && \
+ go build -tags "sqlite redis memcache cert pam" && \
+ mkdir /app/ && \
+ mv /gopath/src/github.com/gogits/gogs/ /app/gogs/ && \
+ rm -r $GOROOT $GOPATH
+
+WORKDIR /app/gogs/
RUN useradd --shell /bin/bash --system --comment gogits git
-RUN mkdir /var/run/sshd
-# SSH login fix. Otherwise user is kicked off after login
-RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
-RUN sed 's@UsePrivilegeSeparation yes@UsePrivilegeSeparation no@' -i /etc/ssh/sshd_config
-RUN echo "export VISIBLE=now" >> /etc/profile
-RUN echo "PermitUserEnvironment yes" >> /etc/ssh/sshd_config
-
-# setup server keys on startup
-RUN sed 's@^HostKey@\#HostKey@' -i /etc/ssh/sshd_config
-RUN echo "HostKey /data/ssh/ssh_host_key" >> /etc/ssh/sshd_config
-RUN echo "HostKey /data/ssh/ssh_host_rsa_key" >> /etc/ssh/sshd_config
-RUN echo "HostKey /data/ssh/ssh_host_dsa_key" >> /etc/ssh/sshd_config
-RUN echo "HostKey /data/ssh/ssh_host_ecdsa_key" >> /etc/ssh/sshd_config
-RUN echo "HostKey /data/ssh/ssh_host_ed25519_key" >> /etc/ssh/sshd_config
-
-# prepare data
-#ENV USER="git" HOME="/home/git"
+# SSH login fix, otherwise user is kicked off after login
+RUN mkdir /var/run/sshd && \
+ sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd && \
+ sed 's@UsePrivilegeSeparation yes@UsePrivilegeSeparation no@' -i /etc/ssh/sshd_config && \
+ echo "export VISIBLE=now" >> /etc/profile && \
+ echo "PermitUserEnvironment yes" >> /etc/ssh/sshd_config
+
+# Setup server keys on startup
+RUN sed 's@^HostKey@\#HostKey@' -i /etc/ssh/sshd_config && \
+ echo "HostKey /data/ssh/ssh_host_key" >> /etc/ssh/sshd_config && \
+ echo "HostKey /data/ssh/ssh_host_rsa_key" >> /etc/ssh/sshd_config && \
+ echo "HostKey /data/ssh/ssh_host_dsa_key" >> /etc/ssh/sshd_config && \
+ echo "HostKey /data/ssh/ssh_host_ecdsa_key" >> /etc/ssh/sshd_config && \
+ echo "HostKey /data/ssh/ssh_host_ed25519_key" >> /etc/ssh/sshd_config
+
+# Prepare data
ENV GOGS_CUSTOM /data/gogs
RUN echo "export GOGS_CUSTOM=/data/gogs" >> /etc/profile
EXPOSE 22 3000
ENTRYPOINT []
-CMD ["./docker/start.sh"]
+CMD ["./docker/start.sh"] \ No newline at end of file