Dockerfile 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. FROM google/debian:wheezy
  2. MAINTAINER u@gogs.io
  3. RUN echo "deb http://ftp.debian.org/debian/ wheezy-backports main" >> /etc/apt/sources.list && \
  4. apt-get update -qqy && \
  5. apt-get install --no-install-recommends -qqy \
  6. curl build-essential ca-certificates git \
  7. openssh-server rsync libpam-dev && \
  8. apt-get autoclean && \
  9. apt-get autoremove && \
  10. rm -rf /var/lib/apt/lists/*
  11. ENV GOROOT /goroot
  12. ENV GOPATH /gopath
  13. ENV PATH $PATH:$GOROOT/bin:$GOPATH/bin
  14. COPY . /gopath/src/github.com/gogits/gogs/
  15. WORKDIR /gopath/src/github.com/gogits/gogs/
  16. # Build binary and clean up useless files
  17. RUN mkdir /goroot && \
  18. curl https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz | tar xzf - -C /goroot --strip-components=1 && \
  19. go get -v -tags "sqlite redis memcache cert pam" && \
  20. go build -tags "sqlite redis memcache cert pam" && \
  21. mkdir /app/ && \
  22. mv /gopath/src/github.com/gogits/gogs/ /app/gogs/ && \
  23. rm -r $GOROOT $GOPATH
  24. WORKDIR /app/gogs/
  25. RUN useradd --shell /bin/bash --system --comment gogits git
  26. # SSH login fix, otherwise user is kicked off after login
  27. RUN mkdir /var/run/sshd && \
  28. sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd && \
  29. sed 's@UsePrivilegeSeparation yes@UsePrivilegeSeparation no@' -i /etc/ssh/sshd_config && \
  30. echo "export VISIBLE=now" >> /etc/profile && \
  31. echo "PermitUserEnvironment yes" >> /etc/ssh/sshd_config
  32. # Setup server keys on startup
  33. RUN sed 's@^HostKey@\#HostKey@' -i /etc/ssh/sshd_config && \
  34. echo "HostKey /data/ssh/ssh_host_key" >> /etc/ssh/sshd_config && \
  35. echo "HostKey /data/ssh/ssh_host_rsa_key" >> /etc/ssh/sshd_config && \
  36. echo "HostKey /data/ssh/ssh_host_dsa_key" >> /etc/ssh/sshd_config && \
  37. echo "HostKey /data/ssh/ssh_host_ecdsa_key" >> /etc/ssh/sshd_config && \
  38. echo "HostKey /data/ssh/ssh_host_ed25519_key" >> /etc/ssh/sshd_config
  39. # Prepare data
  40. ENV GOGS_CUSTOM /data/gogs
  41. RUN echo "export GOGS_CUSTOM=/data/gogs" >> /etc/profile
  42. EXPOSE 22 3000
  43. ENTRYPOINT []
  44. CMD ["./docker/start.sh"]