From 502abe750b698fdc64e2c4a89500a9535355d13c Mon Sep 17 00:00:00 2001 From: Mirco Date: Wed, 24 May 2023 09:50:39 +0200 Subject: [PATCH] [Skip-ci] WIP dockerimage --- infrastructure/docker-federated/build.py | 52 ++++++++++++++ .../docker-federated/image/Dockerfile | 70 +++++++++++++++++++ src/main/resources/forgejo/deployment.yaml | 2 +- 3 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 infrastructure/docker-federated/build.py create mode 100644 infrastructure/docker-federated/image/Dockerfile diff --git a/infrastructure/docker-federated/build.py b/infrastructure/docker-federated/build.py new file mode 100644 index 0000000..9919c53 --- /dev/null +++ b/infrastructure/docker-federated/build.py @@ -0,0 +1,52 @@ +from os import environ +from pybuilder.core import task, init +from ddadevops import * +import logging + +name = 'c4k-forgejo-fed' +MODULE = 'docker' +PROJECT_ROOT_PATH = '../..' + +class MyBuild(DevopsDockerBuild): + pass + +@init +def initialize(project): + project.build_depends_on('ddadevops>=0.12.4') + stage = 'prod' + dockerhub_user = environ.get('DOCKERHUB_USER') + if not dockerhub_user: + dockerhub_user = gopass_field_from_path('meissa/web/docker.com', 'login') + dockerhub_password = environ.get('DOCKERHUB_PASSWORD') + if not dockerhub_password: + dockerhub_password = gopass_password_from_path('meissa/web/docker.com') + tag = environ.get('CI_COMMIT_TAG') + if not tag: + tag = get_tag_from_latest_commit() + config = create_devops_docker_build_config( + stage, PROJECT_ROOT_PATH, MODULE, dockerhub_user, dockerhub_password, docker_publish_tag=tag) + build = MyBuild(project, config) + build.initialize_build_dir() + + +@task +def image(project): + build = get_devops_build(project) + build.image() + +@task +def drun(project): + build = get_devops_build(project) + build.drun() + +@task +def publish(project): + build = get_devops_build(project) + build.dockerhub_login() + build.dockerhub_publish() + +@task +def test(project): + build = get_devops_build(project) + build.test() + diff --git a/infrastructure/docker-federated/image/Dockerfile b/infrastructure/docker-federated/image/Dockerfile new file mode 100644 index 0000000..99ab1f9 --- /dev/null +++ b/infrastructure/docker-federated/image/Dockerfile @@ -0,0 +1,70 @@ +#Build stage +FROM docker.io/library/golang:1.20-alpine3.17 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 + +# Begin env-to-ini build +RUN go build contrib/environment-to-ini/environment-to-ini.go + +FROM docker.io/library/alpine:3.17 +LABEL maintainer="contact@forgejo.org" + +EXPOSE 22 3000 + +RUN apk --no-cache add \ + bash \ + ca-certificates \ + curl \ + gettext \ + git \ + linux-pam \ + openssh \ + s6 \ + sqlite \ + su-exec \ + gnupg + +RUN addgroup \ + -S -g 1000 \ + git && \ + adduser \ + -S -H -D \ + -h /data/git \ + -s /bin/bash \ + -u 1000 \ + -G git \ + git && \ + echo "git:*" | chpasswd -e + +ENV USER git +ENV GITEA_CUSTOM /data/gitea + +VOLUME ["/data"] + +ENTRYPOINT ["/usr/bin/entrypoint"] +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 +COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh +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 chmod 644 /etc/profile.d/gitea_bash_autocomplete.sh diff --git a/src/main/resources/forgejo/deployment.yaml b/src/main/resources/forgejo/deployment.yaml index 4b1a5f1..93fa1ef 100644 --- a/src/main/resources/forgejo/deployment.yaml +++ b/src/main/resources/forgejo/deployment.yaml @@ -18,7 +18,7 @@ spec: spec: containers: - name: forgejo - image: IMAGE_NAME #codeberg.org/forgejo/forgejo:1.19 + image: codeberg.org/meissa/forgejo:federated-latest #codeberg.org/forgejo/forgejo:1.19 imagePullPolicy: IfNotPresent # config settings envFrom: