diff --git a/.helpers/download-forgejo.sh b/.helpers/download-forgejo.sh new file mode 100644 index 0000000..52b3f33 --- /dev/null +++ b/.helpers/download-forgejo.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + +export $(cat ./config/flow-platform-services.cfg | grep FORGEJO_VERSION | tr -d "\"") + +declare -A CODEBERG_FORGEJO_BINARIES=( + [1.18.3-0]="https://codeberg.org/attachments/af34fbfc-d651-41b1-aaff-2b9cc7134051" +) + +declare -A CODEBERG_FORGEJO_BINARY_SIGNATURES=( + [1.18.3-0]="https://codeberg.org/attachments/f064c1a9-66f7-41a9-be03-4dc5e2298370" +) + +if ! [ -f ./build/forgejo/forgejo-${FORGEJO_VERSION}-linux-amd64 ]; then + echo "Downloading Forgejo ${FORGEJO_VERSION}..." + #curl -sSL https://github.com/go-gitea/gitea/releases/download/v${FORGEJO_VERSION}/gitea-${FORGEJO_VERSION}-linux-amd64 -o ./build/gitea/gitea-${FORGEJO_VERSION}-linux-amd64 + curl -sSL ${CODEBERG_FORGEJO_BINARIES[${FORGEJO_VERSION}]} -o ./build/forgejo/forgejo-${FORGEJO_VERSION}-linux-amd64 + curl -sSL ${CODEBERG_FORGEJO_BINARY_SIGNATURES[${FORGEJO_VERSION}]} -o ./build/forgejo/forgejo-${FORGEJO_VERSION}-linux-amd64.asc + ( cd ./build/forgejo && gpg --verify forgejo-${FORGEJO_VERSION}-linux-amd64.asc forgejo-${FORGEJO_VERSION}-linux-amd64 ) +else + echo "Forgejo ${FORGEJO_VERSION} is already present." +fi diff --git a/.helpers/download-gitea.sh b/.helpers/download-gitea.sh deleted file mode 100644 index bde1cc7..0000000 --- a/.helpers/download-gitea.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o nounset -set -o pipefail - -export $(cat ./config/flow-platform-services.cfg | grep GITEA_VERSION | tr -d "\"") - -if ! [ -f ./build/gitea/gitea-${GITEA_VERSION}-linux-amd64 ]; then - echo "Downloading Gitea ${GITEA_VERSION}..." - curl -sSL https://github.com/go-gitea/gitea/releases/download/v${GITEA_VERSION}/gitea-${GITEA_VERSION}-linux-amd64 -o ./build/gitea/gitea-${GITEA_VERSION}-linux-amd64 - curl -sSL https://github.com/go-gitea/gitea/releases/download/v${GITEA_VERSION}/gitea-${GITEA_VERSION}-linux-amd64.sha256 -o ./build/gitea/gitea-${GITEA_VERSION}-linux-amd64.sha256 - ( cd ./build/gitea && sha256sum --check gitea-${GITEA_VERSION}-linux-amd64.sha256 ) -else - echo "Gitea ${GITEA_VERSION} is already present." -fi diff --git a/Makefile b/Makefile index 4e3db45..83c2076 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,16 @@ -all: traefik gitea gotosocial +all: traefik-files forgejo-files gotosocial-files compose: bash ./.helpers/render.sh compose -traefik: compose +traefik-files: compose bash ./.helpers/render.sh traefik -gitea: gitea-binary compose - bash ./.helpers/render.sh gitea +forgejo-files: forgejo-binary compose + bash ./.helpers/render.sh forgejo -gitea-binary: - bash ./.helpers/download-gitea.sh +forgejo-binary: + bash ./.helpers/download-forgejo.sh -gotosocial: compose +gotosocial-files: compose bash ./.helpers/render.sh gotosocial diff --git a/config b/config index 0dda4e5..c5bea2c 160000 --- a/config +++ b/config @@ -1 +1 @@ -Subproject commit 0dda4e50e69cd0b4b01feedcf7ea3867214e5b1d +Subproject commit c5bea2ce0ed8dfdcc72e2e7f28039beaaa2b2976 diff --git a/templates/compose/docker-compose.yaml b/templates/compose/docker-compose.yaml index f7e7491..be60e62 100644 --- a/templates/compose/docker-compose.yaml +++ b/templates/compose/docker-compose.yaml @@ -54,17 +54,17 @@ services: source: "${TRAEFIK_TLS_HOST_DIR}" target: "${TRAEFIK_TLS_CONTAINER_DIR}" # -- Code flow -- - gitea: + forgejo: container_name: "code-flow" - image: localhost/flow/gitea:${GITEA_VERSION} + image: localhost/flow/forgejo:${FORGEJO_VERSION} build: - context: "../gitea" + context: "../forgejo" expose: - - "${GITEA_SSH_PORT}" - - "${GITEA_HTTP_PORT}" + - "${FORGEJO_SSH_PORT}" + - "${FORGEJO_HTTP_PORT}" networks: flow: - ipv4_address: "${GITEA_CONTAINER_IPV4_ADDRESS}" + ipv4_address: "${FORGEJO_CONTAINER_IPV4_ADDRESS}" restart: "always" volumes: - type: "volume" @@ -78,13 +78,13 @@ services: source: "/etc/localtime" target: "/etc/localtime" read_only: true - # Gitea data volume + # ForgeJo data volume - type: "bind" - source: "${GITEA_DATA_HOST_DIR}" - target: "${GITEA_DATA_CONTAINER_DIR}" + source: "${FORGEJO_DATA_HOST_DIR}" + target: "${FORGEJO_DATA_CONTAINER_DIR}" # -- Free Flow 2 -- gotosocial: - container_name: "free-flow-2" + container_name: "free-flow" image: localhost/flow/gotosocial:${GTS_VERSION} build: context: "../gotosocial" diff --git a/templates/forgejo/Dockerfile b/templates/forgejo/Dockerfile new file mode 100644 index 0000000..25592ce --- /dev/null +++ b/templates/forgejo/Dockerfile @@ -0,0 +1,44 @@ +# This is a custom made Dockerfile for Gitea which is inspired from +# the official Dockerfile.rootless from https://github.com/go-gitea/gitea/ +FROM alpine:3.17 + +ENV FORGEJO_WORK_DIR=${FORGEJO_WORK_DIR} \ + FORGEJO_CUSTOM=${FORGEJO_CUSTOM} \ + FORGEJO_APP_INI=${FORGEJO_APP_INI} \ + FORGEJO_BIN=${FORGEJO_BIN} \ + FORGEJO_VERSION=${FORGEJO_VERSION} \ + HOME=${FORGEJO_HOME} + +RUN apk update && apk upgrade && apk --no-cache add \ + bash \ + ca-certificates \ + gettext \ + git \ + curl \ + gnupg \ + openssh-keygen \ + && addgroup -S -g ${FLOW_GID} flow \ + && adduser -S -H -D -h ${FORGEJO_HOME} -s /bin/bash -u ${FORGEJO_FLOW_UID} -G flow git \ + && mkdir -p ${FORGEJO_DATA_CONTAINER_DIR} ${FORGEJO_TMP} \ + && chown git ${FORGEJO_DATA_CONTAINER_DIR} && chmod 0700 ${FORGEJO_DATA_CONTAINER_DIR} \ + && chown git ${FORGEJO_TMP} && chmod 0700 ${FORGEJO_TMP} + +ADD --chown=root:root forgejo-${FORGEJO_VERSION}-linux-amd64 ${FORGEJO_BIN} +ADD app.ini ${FORGEJO_APP_INI} +ADD entrypoint.sh /usr/local/bin/entrypoint.sh +ADD --chown=${FORGEJO_FLOW_UID}:${FLOW_GID} dynamic_git.yaml ${FORGEJO_TMP}/ + +RUN chown -R ${FORGEJO_FLOW_UID}:${FORGEJO_FLOW_UID} ${FORGEJO_APP_INI} \ + && chmod 0400 ${FORGEJO_APP_INI} \ + && chmod a+x ${FORGEJO_BIN} \ + && chmod a+rx /usr/local/bin/entrypoint.sh + +USER ${FORGEJO_FLOW_UID}:${FLOW_GID} + +WORKDIR /flow/gitea/data + +VOLUME ["/flow/gitea/data"] + +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] + +CMD [] diff --git a/templates/forgejo/app.ini b/templates/forgejo/app.ini new file mode 100644 index 0000000..c49e808 --- /dev/null +++ b/templates/forgejo/app.ini @@ -0,0 +1,105 @@ +APP_NAME = "${FORGEJO_APP_NAME_01} ${FORGEJO_APP_NAME_02}" +RUN_USER = git +RUN_MODE = ${FORGEJO_RUN_MODE} + +[repository] +ROOT = ${FORGEJO_DATA_CONTAINER_DIR}/git/repositories +DEFAULT_BRANCH = main + +[repository.local] +LOCAL_COPY_PATH = ${FORGEJO_TMP}/local-repo + +[repository.upload] +TEMP_PATH = ${FORGEJO_TMP}/uploads + +[repository.signing] +INITIAL_COMMIT = pubkey, twofa +MERGES = pubkey, twofa, basesigned, commitssigned + +[ui] +DEFAULT_THEME = forgejo-dark + +[server] +APP_DATA_PATH = ${FORGEJO_DATA_CONTAINER_DIR}/git +DOMAIN = ${FORGEJO_DOMAIN} +HTTP_ADDR = ${FORGEJO_CONTAINER_IPV4_ADDRESS} +HTTP_PORT = ${FORGEJO_HTTP_PORT} +ROOT_URL = https://${FORGEJO_DOMAIN} +DISABLE_SSH = false +START_SSH_SERVER = true +SSH_DOMAIN = ${FORGEJO_DOMAIN} +SSH_PORT = ${TRAEFIK_EXTERNAL_SSH_PORT} +SSH_LISTEN_HOST = ${FORGEJO_CONTAINER_IPV4_ADDRESS} +SSH_LISTEN_PORT = ${FORGEJO_SSH_PORT} +BUILTIN_SSH_SERVER_USER = git +LFS_START_SERVER = false +LFS_CONTENT_PATH = ${FORGEJO_DATA_CONTAINER_DIR}/git/lfs + +[ssh.minimum_key_sizes] +ED25519 = 256 +ECDSA = 256 +RSA = 4096 +DSA = -1 + +[database] +DB_TYPE = sqlite3 +PATH = ${FORGEJO_DATA_CONTAINER_DIR}/database/gitea.db +HOST = localhost:3306 +NAME = gitea +USER = gitea +PASSWD = + +[indexer] +ISSUE_INDEXER_PATH = ${FORGEJO_DATA_CONTAINER_DIR}/indexers/issues.bleve + +[session] +PROVIDER_CONFIG = ${FORGEJO_DATA_CONTAINER_DIR}/sessions + +[queue] +DATADIR = ${FORGEJO_DATA_CONTAINER_DIR}/queues + +[admin] +DISABLE_REGULAR_ORG_CREATION = true +DEFAULT_EMAIL_NOTIFICATION = disabled + +[security] +INSTALL_LOCK = true +SECRET_KEY = ${FORGEJO_SECRET_KEY} +INTERNAL_TOKEN = ${FORGEJO_INTERNAL_TOKEN} +LOGIN_REMEMBER_DAYS = 1 +MIN_PASSWORD_LENGTH = 16 +PASSWORD_COMPLEXITY = lower,upper,digit + +[service] +DISABLE_REGISTRATION = true + +[service.explore] +REQUIRE_SIGNIN_VIEW = false + +[picture] +AVATAR_UPLOAD_PATH = ${FORGEJO_DATA_CONTAINER_DIR}/avatars +REPOSITORY_AVATAR_UPLOAD_PATH = ${FORGEJO_DATA_CONTAINER_DIR}/repo-avatars + +[attachment] +ENABLED = true +PATH = ${FORGEJO_DATA_CONTAINER_DIR}/attachments + +[log] +ROOT_PATH = ${FORGEJO_DATA_CONTAINER_DIR}/log +MODE = console +LEVEL = ${FORGEJO_LOG_LEVEL} + +[log.console] +STDERR = false + +[i18n] +LANGS = en-US +NAMES = English + +[other] +SHOW_FOOTER_BRANDING = true +SHOW_FOOTER_VERSION = false +SHOW_FOOTER_TEMPLATE_LOAD_TIME = false + +[oauth2] +ENABLE = false diff --git a/templates/gitea/dynamic_git.yaml b/templates/forgejo/dynamic_git.yaml similarity index 65% rename from templates/gitea/dynamic_git.yaml rename to templates/forgejo/dynamic_git.yaml index be25e9f..e9774c0 100644 --- a/templates/gitea/dynamic_git.yaml +++ b/templates/forgejo/dynamic_git.yaml @@ -4,7 +4,7 @@ http: gitea: entryPoints: - "https" - rule: "Host(`${GITEA_DOMAIN}`)" + rule: "Host(`${FORGEJO_DOMAIN}`)" service: "git" tls: certResolver: resolver @@ -12,7 +12,7 @@ http: git: loadBalancer: servers: - - url: "http://${GITEA_CONTAINER_IPV4_ADDRESS}:${GITEA_HTTP_PORT}/" + - url: "http://${FORGEJO_CONTAINER_IPV4_ADDRESS}:${FORGEJO_HTTP_PORT}/" tcp: routers: @@ -25,4 +25,4 @@ tcp: gitSSH: loadBalancer: servers: - - address: "${GITEA_CONTAINER_IPV4_ADDRESS}:${GITEA_SSH_PORT}" + - address: "${FORGEJO_CONTAINER_IPV4_ADDRESS}:${FORGEJO_SSH_PORT}" diff --git a/templates/gitea/entrypoint.sh b/templates/forgejo/entrypoint.sh similarity index 59% rename from templates/gitea/entrypoint.sh rename to templates/forgejo/entrypoint.sh index 978049c..8284dac 100644 --- a/templates/gitea/entrypoint.sh +++ b/templates/forgejo/entrypoint.sh @@ -3,15 +3,15 @@ set -euo pipefail # Create the home directory. -if ! [ -d ${GITEA_HOME} ]; then - mkdir -p ${GITEA_HOME} - chmod 0700 ${GITEA_HOME} +if ! [ -d ${FORGEJO_HOME} ]; then + mkdir -p ${FORGEJO_HOME} + chmod 0700 ${FORGEJO_HOME} fi # Create the custom directory. -if ! [ -d ${GITEA_CUSTOM} ]; then - mkdir -p ${GITEA_CUSTOM} - chmod 0500 ${GITEA_CUSTOM} +if ! [ -d ${FORGEJO_CUSTOM} ]; then + mkdir -p ${FORGEJO_CUSTOM} + chmod 0500 ${FORGEJO_CUSTOM} fi # Move the dynamic Traefik config to the shared volume. @@ -22,5 +22,5 @@ fi if [ $# -gt 0 ]; then exec "$@" else - exec ${GITEA_BIN} -c ${GITEA_APP_INI} web + exec ${FORGEJO_BIN} -c ${FORGEJO_APP_INI} web fi diff --git a/templates/gitea/Dockerfile b/templates/gitea/Dockerfile deleted file mode 100644 index 59af196..0000000 --- a/templates/gitea/Dockerfile +++ /dev/null @@ -1,44 +0,0 @@ -# This is a custom made Dockerfile for Gitea which is inspired from -# the official Dockerfile.rootless from https://github.com/go-gitea/gitea/ -FROM alpine:3.17 - -ENV GITEA_WORK_DIR=${GITEA_WORK_DIR} \ - GITEA_CUSTOM=${GITEA_CUSTOM} \ - GITEA_APP_INI=${GITEA_APP_INI} \ - GITEA_BIN=${GITEA_BIN} \ - GITEA_VERSION=${GITEA_VERSION} \ - HOME=${GITEA_HOME} - -RUN apk update && apk upgrade && apk --no-cache add \ - bash \ - ca-certificates \ - gettext \ - git \ - curl \ - gnupg \ - openssh-keygen \ - && addgroup -S -g ${FLOW_GID} flow \ - && adduser -S -H -D -h ${GITEA_HOME} -s /bin/bash -u ${GITEA_FLOW_UID} -G flow git \ - && mkdir -p ${GITEA_DATA_CONTAINER_DIR} ${GITEA_TMP} \ - && chown git ${GITEA_DATA_CONTAINER_DIR} && chmod 0700 ${GITEA_DATA_CONTAINER_DIR} \ - && chown git ${GITEA_TMP} && chmod 0700 ${GITEA_TMP} - -ADD --chown=root:root gitea-${GITEA_VERSION}-linux-amd64 ${GITEA_BIN} -ADD app.ini ${GITEA_APP_INI} -ADD entrypoint.sh /usr/local/bin/entrypoint.sh -ADD --chown=${GITEA_FLOW_UID}:${FLOW_GID} dynamic_git.yaml ${GITEA_TMP}/ - -RUN chown -R ${GITEA_FLOW_UID}:${GITEA_FLOW_UID} ${GITEA_APP_INI} \ - && chmod 0400 ${GITEA_APP_INI} \ - && chmod a+x ${GITEA_BIN} \ - && chmod a+rx /usr/local/bin/entrypoint.sh - -USER ${GITEA_FLOW_UID}:${FLOW_GID} - -WORKDIR /flow/gitea/data - -VOLUME ["/flow/gitea/data"] - -ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] - -CMD [] diff --git a/templates/gitea/app.ini b/templates/gitea/app.ini deleted file mode 100644 index b564415..0000000 --- a/templates/gitea/app.ini +++ /dev/null @@ -1,105 +0,0 @@ -APP_NAME = "${GITEA_APP_NAME_01} ${GITEA_APP_NAME_02}" -RUN_USER = git -RUN_MODE = ${GITEA_RUN_MODE} - -[repository] -ROOT = ${GITEA_DATA_CONTAINER_DIR}/git/repositories -DEFAULT_BRANCH = main - -[repository.local] -LOCAL_COPY_PATH = ${GITEA_TMP}/local-repo - -[repository.upload] -TEMP_PATH = ${GITEA_TMP}/uploads - -[repository.signing] -INITIAL_COMMIT = pubkey, twofa -MERGES = pubkey, twofa, basesigned, commitssigned - -[ui] -DEFAULT_THEME = arc-green - -[server] -APP_DATA_PATH = ${GITEA_DATA_CONTAINER_DIR}/git -DOMAIN = ${GITEA_DOMAIN} -HTTP_ADDR = ${GITEA_CONTAINER_IPV4_ADDRESS} -HTTP_PORT = ${GITEA_HTTP_PORT} -ROOT_URL = https://${GITEA_DOMAIN} -DISABLE_SSH = false -START_SSH_SERVER = true -SSH_DOMAIN = ${GITEA_DOMAIN} -SSH_PORT = ${TRAEFIK_EXTERNAL_SSH_PORT} -SSH_LISTEN_HOST = ${GITEA_CONTAINER_IPV4_ADDRESS} -SSH_LISTEN_PORT = ${GITEA_SSH_PORT} -BUILTIN_SSH_SERVER_USER = git -LFS_START_SERVER = false -LFS_CONTENT_PATH = ${GITEA_DATA_CONTAINER_DIR}/git/lfs - -[ssh.minimum_key_sizes] -ED25519 = 256 -ECDSA = 256 -RSA = 4096 -DSA = -1 - -[database] -DB_TYPE = sqlite3 -PATH = ${GITEA_DATA_CONTAINER_DIR}/database/gitea.db -HOST = localhost:3306 -NAME = gitea -USER = gitea -PASSWD = - -[indexer] -ISSUE_INDEXER_PATH = ${GITEA_DATA_CONTAINER_DIR}/indexers/issues.bleve - -[session] -PROVIDER_CONFIG = ${GITEA_DATA_CONTAINER_DIR}/sessions - -[queue] -DATADIR = ${GITEA_DATA_CONTAINER_DIR}/queues - -[admin] -DISABLE_REGULAR_ORG_CREATION = true -DEFAULT_EMAIL_NOTIFICATION = disabled - -[security] -INSTALL_LOCK = true -SECRET_KEY = ${GITEA_SECRET_KEY} -INTERNAL_TOKEN = ${GITEA_INTERNAL_TOKEN} -LOGIN_REMEMBER_DAYS = 1 -MIN_PASSWORD_LENGTH = 16 -PASSWORD_COMPLEXITY = lower,upper,digit - -[service] -DISABLE_REGISTRATION = true - -[service.explore] -REQUIRE_SIGNIN_VIEW = false - -[picture] -AVATAR_UPLOAD_PATH = ${GITEA_DATA_CONTAINER_DIR}/avatars -REPOSITORY_AVATAR_UPLOAD_PATH = ${GITEA_DATA_CONTAINER_DIR}/repo-avatars - -[attachment] -ENABLED = true -PATH = ${GITEA_DATA_CONTAINER_DIR}/attachments - -[log] -ROOT_PATH = ${GITEA_DATA_CONTAINER_DIR}/log -MODE = console -LEVEL = ${GITEA_LOG_LEVEL} - -[log.console] -STDERR = false - -[i18n] -LANGS = en-US -NAMES = English - -[other] -SHOW_FOOTER_BRANDING = true -SHOW_FOOTER_VERSION = false -SHOW_FOOTER_TEMPLATE_LOAD_TIME = false - -[oauth2] -ENABLE = false