diff --git a/Dockerfile b/Dockerfile index 69a8cdbec1f..5bf06064a49 100644 --- a/Dockerfile +++ b/Dockerfile @@ -66,6 +66,5 @@ CMD ["/bin/s6-svscan", "/etc/s6"] COPY docker/root / COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea COPY --from=build-env /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini -RUN chmod 755 /usr/bin/entrypoint /app/gitea/gitea /usr/local/bin/environment-to-ini +RUN chmod 755 /usr/bin/entrypoint /app/gitea/gitea /usr/local/bin/gitea /usr/local/bin/environment-to-ini RUN chmod 755 /etc/s6/gitea/* /etc/s6/openssh/* /etc/s6/.s6-svscan/* -RUN ln -s /app/gitea/gitea /usr/local/bin/gitea diff --git a/Dockerfile.rootless b/Dockerfile.rootless index f6430e5f69d..8bfaf9cb86f 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -53,9 +53,9 @@ RUN mkdir -p /var/lib/gitea /etc/gitea RUN chown git:git /var/lib/gitea /etc/gitea COPY docker/rootless / -COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/gitea /usr/local/bin/gitea +COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini -RUN chmod 755 /usr/local/bin/docker-entrypoint.sh /usr/local/bin/docker-setup.sh /usr/local/bin/gitea /usr/local/bin/environment-to-ini +RUN chmod 755 /usr/local/bin/docker-entrypoint.sh /usr/local/bin/docker-setup.sh /app/gitea/gitea /usr/local/bin/gitea /usr/local/bin/environment-to-ini #git:git USER 1000:1000 diff --git a/contrib/fhs-compliant-script/gitea b/contrib/fhs-compliant-script/gitea index 019f838f922..ae1ae3cf14a 100755 --- a/contrib/fhs-compliant-script/gitea +++ b/contrib/fhs-compliant-script/gitea @@ -1,8 +1,8 @@ #!/bin/bash -######################################################################## -# This script some defaults for gitea to run in a FHS compliant manner # -######################################################################## +############################################################################# +# This script sets some defaults for gitea to run in a FHS compliant manner # +############################################################################# # It assumes that you place this script as gitea in /usr/bin # @@ -36,7 +36,7 @@ if [ -z "$APP_INI_SET" ]; then CONF_ARG="-c \"$APP_INI\"" fi -# Provide FHS compliant defaults to -exec -a "$0" GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" "$GITEA" $CONF_ARG "$@" +# Provide FHS compliant defaults +GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" exec -a "$0" "$GITEA" $CONF_ARG "$@" diff --git a/docker/root/etc/s6/gitea/run b/docker/root/etc/s6/gitea/run index b6150c10d5f..7b858350f29 100755 --- a/docker/root/etc/s6/gitea/run +++ b/docker/root/etc/s6/gitea/run @@ -2,5 +2,5 @@ [[ -f ./setup ]] && source ./setup pushd /app/gitea >/dev/null -exec su-exec $USER /app/gitea/gitea web +exec su-exec $USER /usr/local/bin/gitea web popd diff --git a/docker/root/usr/local/bin/gitea b/docker/root/usr/local/bin/gitea new file mode 100644 index 00000000000..8a8f17bc4ec --- /dev/null +++ b/docker/root/usr/local/bin/gitea @@ -0,0 +1,17 @@ +#!/bin/bash + +############################################################### +# This script sets defaults for gitea to run in the container # +############################################################### + +# It assumes that you place this script as gitea in /usr/local/bin +# +# And place the original in /usr/lib/gitea with working files in /data/gitea +GITEA="/app/gitea/gitea" +WORK_DIR="/app/gitea" +CUSTOM_PATH="/data/gitea" + +# Provide docker defaults +GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" GITEA_CUSTOM="${GITEA_CUSTOM:-$CUSTOM_PATH}" exec -a "$0" "$GITEA" $CONF_ARG "$@" + + diff --git a/docker/rootless/usr/local/bin/gitea b/docker/rootless/usr/local/bin/gitea new file mode 100644 index 00000000000..5fdadfb3fe8 --- /dev/null +++ b/docker/rootless/usr/local/bin/gitea @@ -0,0 +1,42 @@ +#!/bin/bash + +############################################################### +# This script sets defaults for gitea to run in the container # +############################################################### + +# It assumes that you place this script as gitea in /usr/local/bin +# +# And place the original in /usr/lib/gitea with working files in /data/gitea +GITEA="/app/gitea/gitea" +WORK_DIR="/var/lib/gitea" +APP_INI="/etc/gitea/app.ini" + +APP_INI_SET="" +for i in "$@"; do + case "$i" in + "-c") + APP_INI_SET=1 + ;; + "-c="*) + APP_INI_SET=1 + ;; + "--config") + APP_INI_SET=1 + ;; + "--config="*) + APP_INI_SET=1 + ;; + *) + ;; + esac +done + +if [ -z "$APP_INI_SET" ]; then + CONF_ARG="-c \"$APP_INI\"" +fi + + +# Provide docker defaults +GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" exec -a "$0" "$GITEA" $CONF_ARG "$@" + +