Browse Source

Add debian image

pull/4839/head
syndbg 7 years ago
parent
commit
fcad2e5aea
  1. 66
      Dockerfile.debian
  2. 29
      docker/build-debian.sh
  3. 31
      docker/build-go-debian.sh
  4. 22
      docker/s6/openssh/run
  5. 5
      docker/s6/syslogd/run

66
Dockerfile.debian

@ -0,0 +1,66 @@
FROM debian:9.2
# Install system utils & Gogs runtime dependencies
ADD https://github.com/tianon/gosu/releases/download/1.10/gosu-amd64 /usr/sbin/gosu
RUN chmod +x /usr/sbin/gosu && \
apt update -q && \
apt install -y \
inetutils-syslogd \
build-essential \
ca-certificates \
curl \
wget \
git \
openssh-server \
openssh-client \
socat \
uidmap \
login \
passwd \
tzdata
# NOTE: Symlink `syslogd` and fake `/dev/xconsole` since we don't have that.
RUN ln -s /usr/sbin/syslogd /sbin/syslogd && \
mknod -m 640 /dev/xconsole p
# NOTE: Install `skalibs`
ADD https://skarnet.org/software/skalibs/skalibs-2.6.0.2.tar.gz /tmp/skalibs
RUN cd /tmp/skalibs/skalibs-2.6.0.2 && \
./configure && make && make install && \
cd -
# NOTE: Install `execline`
ADD https://skarnet.org/software/execline/execline-2.3.0.3.tar.gz /tmp/execline
RUN cd /tmp/execline/execline-2.3.0.3 && \
./configure && make && make install && \
cd -
# NOTE: Install `s6`
ADD https://skarnet.org/software/s6/s6-2.6.1.1.tar.gz /tmp/s6
RUN cd /tmp/s6/s6-2.6.1.1 && \
./configure && make && make install && \
cd -
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 . .
RUN chmod +x ./docker/build-go-debian.sh \
./docker/build-debian.sh \
./docker/finalize.sh && \
./docker/build-go-debian.sh \
&& ./docker/build-debian.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/"]

29
docker/build-debian.sh

@ -0,0 +1,29 @@
#!/bin/sh
set -x
set -e
# Set temp environment vars
export GOPATH=/tmp/go
export PATH=/usr/local/go/bin:${PATH}:${GOPATH}/bin
export GO15VENDOREXPERIMENT=1
# Install build deps
apt install -y libpam0g-dev
# Build Gogs
mkdir -p ${GOPATH}/src/github.com/gogits/
ln -s /app/gogs/build ${GOPATH}/src/github.com/gogits/gogs
cd ${GOPATH}/src/github.com/gogits/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
# Create git user for Gogs
addgroup --system git
useradd -o -u 0 -g git -M git -d /data/git -s /bin/bash && \
usermod -p '*' git && \
passwd -u git
echo "export GOGS_CUSTOM=${GOGS_CUSTOM}" >> /etc/profile

31
docker/build-go-debian.sh

@ -0,0 +1,31 @@
#!/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
apt install -y gcc musl-dev openssl golang-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

22
docker/s6/openssh/run

@ -1,7 +1,25 @@
#!/bin/sh #!/bin/sh
if test -f ./setup; then # Check if host keys are present, else create them
source ./setup if ! test -f /data/ssh/ssh_host_rsa_key; then
ssh-keygen -q -f /data/ssh/ssh_host_rsa_key -N '' -t rsa
fi fi
if ! test -f /data/ssh/ssh_host_dsa_key; then
ssh-keygen -q -f /data/ssh/ssh_host_dsa_key -N '' -t dsa
fi
if ! test -f /data/ssh/ssh_host_ecdsa_key; then
ssh-keygen -q -f /data/ssh/ssh_host_ecdsa_key -N '' -t ecdsa
fi
if ! test -f /data/ssh/ssh_host_ed25519_key; then
ssh-keygen -q -f /data/ssh/ssh_host_ed25519_key -N '' -t ed25519
fi
# Set correct right to ssh keys
chown -R root:root /data/ssh/*
chmod 0700 /data/ssh
chmod 0600 /data/ssh/*
exec gosu root /usr/sbin/sshd -D -f /app/gogs/docker/sshd_config exec gosu root /usr/sbin/sshd -D -f /app/gogs/docker/sshd_config

5
docker/s6/syslogd/run

@ -4,4 +4,9 @@ if test -f ./setup; then
source ./setup source ./setup
fi fi
if [ "$(grep -Ei 'debian' /etc/*release)" ]; then
exec gosu root /sbin/syslogd -nS
else
exec gosu root /sbin/syslogd -nS -O- exec gosu root /sbin/syslogd -nS -O-
fi

Loading…
Cancel
Save