This commit is contained in:
Julian Ospald 2018-06-05 16:38:05 +02:00
parent c76dc7f0f0
commit e15d23acd5
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
2 changed files with 45 additions and 10 deletions

View File

@ -7,18 +7,39 @@ ENV PATH $PATH:$GOROOT/bin:$GOPATH/bin
WORKDIR /gopath/src/github.com/gogs/gogs/ WORKDIR /gopath/src/github.com/gogs/gogs/
RUN apk --no-cache add go redis sqlite openssh sudo supervisor git \ RUN apk --no-cache add \
bash linux-pam build-base linux-pam-dev shadow && \ bash \
build-base \
build-deps \
ca-certificates \
curl \
git \
go \
linux-pam \
linux-pam-dev \
openssh \
redis \
shadow \
socat \
sqlite \
sudo \
supervisor \
tzdata \
&& \
apk --no-cache add --virtual build-deps \
build-base \
linux-pam-dev \
&& \
git clone --depth=1 https://github.com/gogs/gogs.git \ git clone --depth=1 https://github.com/gogs/gogs.git \
/gopath/src/github.com/gogs/gogs && \ /gopath/src/github.com/gogs/gogs && \
go get -v -tags "sqlite redis memcache cert pam" && \ make build TAGS="sqlite redis memcache cert pam" && \
go build -tags "sqlite redis memcache cert pam" && \ apk del build-deps && \
mkdir /app/ && \ mkdir /app/ && \
mv /gopath/src/github.com/gogs/gogs/ /app/gogs/ && \ mv /gopath/src/github.com/gogs/gogs/ /app/gogs/ && \
useradd --shell /bin/bash --system --comment gogs git && \
apk --no-cache del build-base linux-pam-dev shadow && \
rm -rf "$GOPATH" /var/cache/apk/* rm -rf "$GOPATH" /var/cache/apk/*
RUN adduser -G git -H -D -g 'Gogs Git User' git -h /data/git -s /bin/bash && \
usermod -p '*' git && passwd -u git
WORKDIR /app/gogs/ WORKDIR /app/gogs/
@ -26,10 +47,8 @@ WORKDIR /app/gogs/
RUN echo "export VISIBLE=now" >> /etc/profile && \ RUN echo "export VISIBLE=now" >> /etc/profile && \
echo "PermitUserEnvironment yes" >> /etc/ssh/sshd_config echo "PermitUserEnvironment yes" >> /etc/ssh/sshd_config
# Setup server keys on startup # Setup ssh
RUN echo "HostKey /data/ssh/ssh_host_rsa_key" >> /etc/ssh/sshd_config && \ COPY config/sshd_config /etc/ssh/sshd_config
echo "HostKey /data/ssh/ssh_host_dsa_key" >> /etc/ssh/sshd_config && \
echo "HostKey /data/ssh/ssh_host_ed25519_key" >> /etc/ssh/sshd_config
# Prepare data # Prepare data
ENV GOGS_CUSTOM /data/gogs ENV GOGS_CUSTOM /data/gogs

16
config/sshd_config Normal file
View File

@ -0,0 +1,16 @@
Port 22
AddressFamily any
ListenAddress 0.0.0.0
ListenAddress ::
Protocol 2
LogLevel INFO
HostKey /data/ssh/ssh_host_rsa_key
HostKey /data/ssh/ssh_host_dsa_key
HostKey /data/ssh/ssh_host_ecdsa_key
HostKey /data/ssh/ssh_host_ed25519_key
PermitRootLogin no
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
UsePrivilegeSeparation no
PermitUserEnvironment yes
AllowUsers git