Skip to content

Docker image fixes #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ config.codekit
.editorconfig
.gitignore
Dockerfile*
vendor
vendor/**
gogs
gitea
bin
34 changes: 17 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
FROM alpine:3.3
MAINTAINER [email protected]
FROM willemvd/ubuntu-unprivileged-git-ssh:latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This opens up a huge security hole and should not, in any way, be accepted by the maintainers of Gitea.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, what's wrong with alpine?


# Install system utils & Gogs runtime dependencies
ADD https://github.com/tianon/gosu/releases/download/1.9/gosu-amd64 /usr/sbin/gosu
RUN chmod +x /usr/sbin/gosu \
&& apk --no-cache --no-progress add ca-certificates bash git linux-pam s6 curl openssh socat tzdata
USER root

ENV GITEA_CUSTOM /data/gogs
COPY . /app/gitea/
WORKDIR /app/gitea/

COPY . /app/gogs/
WORKDIR /app/gogs/
RUN ./docker/build.sh
# remove when using pre-build gitea
RUN docker/prepare.sh && docker/build.sh && docker/cleanup.sh
# end remove

# Configure LibC Name Service
COPY docker/nsswitch.conf /etc/nsswitch.conf
RUN docker/init/10-setup-gitea.sh

# Configure Docker Container
VOLUME ["/data"]
EXPOSE 22 3000
ENTRYPOINT ["docker/start.sh"]
CMD ["/bin/s6-svscan", "/app/gogs/docker/s6/"]
USER git

# persistent volume for the host ssh key and gitea data
VOLUME ["/etc/ssh/keys", "/data"]

EXPOSE 2222 3000

# Use baseimage-docker's init system.
ENTRYPOINT ["/sbin/my_init", "--"]
111 changes: 0 additions & 111 deletions docker/README.md

This file was deleted.

29 changes: 7 additions & 22 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,15 @@ export GOPATH=/tmp/go
export PATH=${PATH}:${GOPATH}/bin
export GO15VENDOREXPERIMENT=1

# Install build deps
apk --no-cache --no-progress add --virtual build-deps build-base linux-pam-dev go

# Install glide
git clone -b 0.10.2 https://github.com/Masterminds/glide ${GOPATH}/src/github.com/Masterminds/glide
cd ${GOPATH}/src/github.com/Masterminds/glide
make build
go install



# Build Gogs
mkdir -p ${GOPATH}/src/github.com/gogits/
ln -s /app/gogs/ ${GOPATH}/src/github.com/go-gitea/gitea
# Build Gitea
mkdir -p ${GOPATH}/src/github.com/go-gitea/
ln -s /app/gitea/ ${GOPATH}/src/github.com/go-gitea/gitea
cd ${GOPATH}/src/github.com/go-gitea/gitea
glide install

make build TAGS="sqlite cert pam"
go install

# Cleanup GOPATH & vendoring dir
rm -r $GOPATH /app/gogs/vendor

# Remove build deps
apk --no-progress del build-deps
rm -r $GOPATH /app/gitea/vendor

# Create git user for Gogs
adduser -H -D -g 'Gogs Git User' git -h /data/git -s /bin/bash && passwd -u git
echo "export GITEA_CUSTOM=${GITEA_CUSTOM}" >> /etc/profile
mv /app/gitea/bin/gitea /app/gitea/gitea
6 changes: 6 additions & 0 deletions docker/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
apt-get remove -y build-essential libpam0g-dev golang software-properties-common
apt autoremove -y
apt-get clean
apt-get autoclean
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
2 changes: 2 additions & 0 deletions docker/gitea.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec /app/gitea/gitea web 2>&1
26 changes: 26 additions & 0 deletions docker/init/00-init-git-user-and-folders.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

source /etc/profile

# Create VOLUME subfolder
for f in ${GITEA_CUSTOM}/data ${GITEA_CUSTOM}/conf ${GITEA_CUSTOM}/custom ${GITEA_CUSTOM}/log /data/git /data/ssh; do
if ! test -d $f; then
mkdir -p $f
fi
done


if ! test -f ~git/.ssh/environment; then
echo "GITEA_CUSTOM=${GITEA_CUSTOM}" > ~git/.ssh/environment
chmod 660 ~git/.ssh/environment
fi

# Link volumed data with app data
ln -sf ${GITEA_CUSTOM}/log /app/gitea/log
ln -sf ${GITEA_CUSTOM}/data /app/gitea/data
ln -sf ${GITEA_CUSTOM}/custom /app/gitea/custom

# Backward Compatibility with Gogs Container v0.6.15
ln -sf /data/git /home/git

chmod 0775 ${GITEA_CUSTOM} ${GITEA_CUSTOM}/custom ${GITEA_CUSTOM}/log ${GITEA_CUSTOM}/data
15 changes: 15 additions & 0 deletions docker/init/10-setup-gitea.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

mkdir -p /etc/service/99-gitea

cp /app/gitea/docker/gitea.sh /etc/service/99-gitea/run

chmod -R 775 /etc/service/99-gitea
chown -R git:root /etc/service/99-gitea

export GITEA_CUSTOM=/data/gitea
echo "export GITEA_CUSTOM=${GITEA_CUSTOM}" >> /etc/profile

chown -R git:root /data /app/gitea
chmod 0775 /data /app/gitea
cp /app/gitea/docker/init/00-init-git-user-and-folders.sh /etc/my_init.d/99-gitea
16 changes: 0 additions & 16 deletions docker/nsswitch.conf

This file was deleted.

Loading