-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
docker: rootless image #10154
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
Merged
techknowlogick
merged 5 commits into
go-gitea:master
from
sapk-fork:rootless-docker-image
Nov 1, 2020
Merged
docker: rootless image #10154
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7fd8e42
docker: rootless image
sapk 039e3fb
improve docs + remove check for write perm on custom
sapk f35a3ef
Merge branch 'master' into rootless-docker-image
sapk 8007ae6
add more info on ssh passtrough
sapk bfa48ff
Add comment for internal ssh server in container config
sapk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
|
||
################################### | ||
#Build stage | ||
FROM golang:1.15-alpine3.12 AS build-env | ||
|
||
ARG GOPROXY | ||
ENV GOPROXY ${GOPROXY:-direct} | ||
|
||
ARG GITEA_VERSION | ||
ARG TAGS="sqlite sqlite_unlock_notify" | ||
ENV TAGS "bindata timetzdata $TAGS" | ||
ARG CGO_EXTRA_CFLAGS | ||
|
||
#Build deps | ||
RUN apk --no-cache add build-base git nodejs npm | ||
|
||
#Setup repo | ||
COPY . ${GOPATH}/src/code.gitea.io/gitea | ||
WORKDIR ${GOPATH}/src/code.gitea.io/gitea | ||
|
||
#Checkout version if set | ||
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \ | ||
&& make clean-all build | ||
|
||
FROM alpine:3.12 | ||
LABEL maintainer="[email protected]" | ||
|
||
EXPOSE 2222 3000 | ||
|
||
RUN apk --no-cache add \ | ||
bash \ | ||
ca-certificates \ | ||
gettext \ | ||
git \ | ||
gnupg | ||
|
||
RUN addgroup \ | ||
-S -g 1000 \ | ||
git && \ | ||
adduser \ | ||
-S -H -D \ | ||
-h /var/lib/gitea/git \ | ||
-s /bin/bash \ | ||
-u 1000 \ | ||
-G git \ | ||
git && \ | ||
echo "git:$(dd if=/dev/urandom bs=24 count=1 status=none | base64)" | chpasswd | ||
|
||
RUN mkdir -p /var/lib/gitea /etc/gitea | ||
RUN chown git:git /var/lib/gitea /etc/gitea | ||
|
||
COPY docker/rootless / | ||
COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /usr/local/bin/gitea | ||
RUN chown root:root /usr/local/bin/* && chmod 755 /usr/local/bin/* | ||
|
||
USER git:git | ||
ENV GITEA_WORK_DIR /var/lib/gitea | ||
ENV GITEA_CUSTOM /var/lib/gitea/custom | ||
ENV GITEA_TEMP /tmp/gitea | ||
#TODO add to docs the ability to define the ini to load (usefull to test and revert a config) | ||
ENV GITEA_APP_INI /etc/gitea/app.ini | ||
ENV HOME "/var/lib/gitea/git" | ||
VOLUME ["/var/lib/gitea", "/etc/gitea"] | ||
WORKDIR /var/lib/gitea | ||
|
||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] | ||
CMD [] | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}-rootless | ||
{{#if build.tags}} | ||
tags: | ||
{{#each build.tags}} | ||
- {{this}} | ||
{{/each}} | ||
{{/if}} | ||
manifests: | ||
- | ||
image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64-rootless | ||
platform: | ||
architecture: amd64 | ||
os: linux | ||
- | ||
image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64-rootless | ||
platform: | ||
architecture: arm64 | ||
os: linux | ||
variant: v8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
APP_NAME = $APP_NAME | ||
RUN_USER = $RUN_USER | ||
RUN_MODE = $RUN_MODE | ||
|
||
[repository] | ||
ROOT = $GITEA_WORK_DIR/git/repositories | ||
|
||
[repository.local] | ||
LOCAL_COPY_PATH = $GITEA_TEMP/local-repo | ||
|
||
[repository.upload] | ||
TEMP_PATH = $GITEA_TEMP/uploads | ||
|
||
[server] | ||
APP_DATA_PATH = $GITEA_WORK_DIR | ||
SSH_DOMAIN = $SSH_DOMAIN | ||
HTTP_PORT = $HTTP_PORT | ||
ROOT_URL = $ROOT_URL | ||
DISABLE_SSH = $DISABLE_SSH | ||
; In rootless gitea container only internal ssh server is supported | ||
START_SSH_SERVER = true | ||
SSH_PORT = $SSH_PORT | ||
SSH_LISTEN_PORT = $SSH_LISTEN_PORT | ||
BUILTIN_SSH_SERVER_USER = $RUN_USER | ||
LFS_START_SERVER = $LFS_START_SERVER | ||
LFS_CONTENT_PATH = $GITEA_WORK_DIR/git/lfs | ||
|
||
[database] | ||
PATH = $GITEA_WORK_DIR/data/gitea.db | ||
DB_TYPE = $DB_TYPE | ||
HOST = $DB_HOST | ||
NAME = $DB_NAME | ||
USER = $DB_USER | ||
PASSWD = $DB_PASSWD | ||
|
||
[indexer] | ||
ISSUE_INDEXER_PATH = $GITEA_WORK_DIR/data/indexers/issues.bleve | ||
|
||
[session] | ||
PROVIDER_CONFIG = $GITEA_WORK_DIR/data/sessions | ||
|
||
[picture] | ||
AVATAR_UPLOAD_PATH = $GITEA_WORK_DIR/data/avatars | ||
REPOSITORY_AVATAR_UPLOAD_PATH = $GITEA_WORK_DIR/data/gitea/repo-avatars | ||
|
||
[attachment] | ||
PATH = $GITEA_WORK_DIR/data/attachments | ||
|
||
[log] | ||
ROOT_PATH = $GITEA_WORK_DIR/data/log | ||
|
||
[security] | ||
INSTALL_LOCK = $INSTALL_LOCK | ||
SECRET_KEY = $SECRET_KEY | ||
|
||
[service] | ||
DISABLE_REGISTRATION = $DISABLE_REGISTRATION | ||
REQUIRE_SIGNIN_VIEW = $REQUIRE_SIGNIN_VIEW |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
if [ -x /usr/local/bin/docker-setup.sh ]; then | ||
/usr/local/bin/docker-setup.sh || { echo 'docker setup failed' ; exit 1; } | ||
fi | ||
|
||
if [ $# -gt 0 ]; then | ||
exec "$@" | ||
else | ||
exec /usr/local/bin/gitea -c ${GITEA_APP_INI} web | ||
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
# Prepare git folder | ||
mkdir -p ${HOME} && chmod 0700 ${HOME} | ||
if [ ! -w ${HOME} ]; then echo "${HOME} is not writable"; exit 1; fi | ||
|
||
# Prepare custom folder | ||
mkdir -p ${GITEA_CUSTOM} && chmod 0500 ${GITEA_CUSTOM} | ||
|
||
# Prepare temp folder | ||
mkdir -p ${GITEA_TEMP} && chmod 0700 ${GITEA_TEMP} | ||
if [ ! -w ${GITEA_TEMP} ]; then echo "${GITEA_TEMP} is not writable"; exit 1; fi | ||
|
||
#Prepare config file | ||
if [ ! -f ${GITEA_APP_INI} ]; then | ||
|
||
#Prepare config file folder | ||
GITEA_APP_INI_DIR=$(dirname ${GITEA_APP_INI}) | ||
mkdir -p ${GITEA_APP_INI_DIR} && chmod 0700 ${GITEA_APP_INI_DIR} | ||
if [ ! -w ${GITEA_APP_INI_DIR} ]; then echo "${GITEA_APP_INI_DIR} is not writable"; exit 1; fi | ||
|
||
# Set INSTALL_LOCK to true only if SECRET_KEY is not empty and | ||
# INSTALL_LOCK is empty | ||
if [ -n "$SECRET_KEY" ] && [ -z "$INSTALL_LOCK" ]; then | ||
INSTALL_LOCK=true | ||
fi | ||
|
||
# Substitude the environment variables in the template | ||
APP_NAME=${APP_NAME:-"Gitea: Git with a cup of tea"} \ | ||
RUN_MODE=${RUN_MODE:-"dev"} \ | ||
RUN_USER=${USER:-"git"} \ | ||
SSH_DOMAIN=${SSH_DOMAIN:-"localhost"} \ | ||
HTTP_PORT=${HTTP_PORT:-"3000"} \ | ||
ROOT_URL=${ROOT_URL:-""} \ | ||
DISABLE_SSH=${DISABLE_SSH:-"false"} \ | ||
SSH_PORT=${SSH_PORT:-"2222"} \ | ||
SSH_LISTEN_PORT=${SSH_LISTEN_PORT:-$SSH_PORT} \ | ||
DB_TYPE=${DB_TYPE:-"sqlite3"} \ | ||
DB_HOST=${DB_HOST:-"localhost:3306"} \ | ||
DB_NAME=${DB_NAME:-"gitea"} \ | ||
DB_USER=${DB_USER:-"root"} \ | ||
DB_PASSWD=${DB_PASSWD:-""} \ | ||
INSTALL_LOCK=${INSTALL_LOCK:-"false"} \ | ||
DISABLE_REGISTRATION=${DISABLE_REGISTRATION:-"false"} \ | ||
REQUIRE_SIGNIN_VIEW=${REQUIRE_SIGNIN_VIEW:-"false"} \ | ||
SECRET_KEY=${SECRET_KEY:-""} \ | ||
envsubst < /etc/templates/app.ini > ${GITEA_APP_INI} | ||
fi |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.