Merge branch 'optional-forgejo-fed' of gitlab.com:domaindrivenarchitecture/c4k-forgejo into optional-forgejo-fed

This commit is contained in:
erik 2023-06-07 13:40:26 +02:00
commit 8768c68c22
8 changed files with 44 additions and 26 deletions

View file

@ -114,3 +114,11 @@ release:
--assets-link "{\"name\":\"c4k-forgejo.js\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-forgejo/-/jobs/${CI_JOB_ID}/artifacts/file/target/frontend-build/c4k-forgejo.js\"}" \ --assets-link "{\"name\":\"c4k-forgejo.js\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-forgejo/-/jobs/${CI_JOB_ID}/artifacts/file/target/frontend-build/c4k-forgejo.js\"}" \
--assets-link "{\"name\":\"c4k-forgejo.js.sha256\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-forgejo/-/jobs/${CI_JOB_ID}/artifacts/file/target/frontend-build/c4k-forgejo.js.sha256\"}" \ --assets-link "{\"name\":\"c4k-forgejo.js.sha256\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-forgejo/-/jobs/${CI_JOB_ID}/artifacts/file/target/frontend-build/c4k-forgejo.js.sha256\"}" \
--assets-link "{\"name\":\"c4k-forgejo.js.sha512\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-forgejo/-/jobs/${CI_JOB_ID}/artifacts/file/target/frontend-build/c4k-forgejo.js.sha512\"}" \ --assets-link "{\"name\":\"c4k-forgejo.js.sha512\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-forgejo/-/jobs/${CI_JOB_ID}/artifacts/file/target/frontend-build/c4k-forgejo.js.sha512\"}" \
forgejo-image-test-publish:
image: domaindrivenarchitecture/devops-build:latest
stage: image
rules:
- if: '$CI_COMMIT_TAG != null'
script:
- cd infrastructure/docker-federated && pyb image test publish

View file

@ -12,7 +12,7 @@ class MyBuild(DevopsDockerBuild):
@init @init
def initialize(project): def initialize(project):
project.build_depends_on('ddadevops>=0.12.4') project.build_depends_on('ddadevops>=0.15.5')
stage = 'prod' stage = 'prod'
dockerhub_user = environ.get('DOCKERHUB_USER') dockerhub_user = environ.get('DOCKERHUB_USER')
if not dockerhub_user: if not dockerhub_user:
@ -49,4 +49,3 @@ def publish(project):
def test(project): def test(project):
build = get_devops_build(project) build = get_devops_build(project)
build.test() build.test()

View file

@ -1,35 +1,33 @@
#Build stage #Build stage
FROM docker.io/library/golang:1.20-alpine3.17 AS build-env FROM docker.io/library/golang:1.20.4-alpine3.18 AS build-env
ARG GOPROXY ARG GOPROXY
ENV GOPROXY ${GOPROXY:-direct} ENV GOPROXY ${GOPROXY:-direct}
ARG GITEA_VERSION #ARG GITEA_VERSION
ARG TAGS="sqlite sqlite_unlock_notify" ARG TAGS="sqlite sqlite_unlock_notify"
ENV TAGS "bindata timetzdata $TAGS" ENV TAGS "bindata timetzdata $TAGS"
ARG CGO_EXTRA_CFLAGS ARG CGO_EXTRA_CFLAGS
ARG FORGEJO_GIT_URL="https://codeberg.org/forgejo/forgejo.git" ENV FORGEJO_GIT_URL "https://codeberg.org/forgejo/forgejo.git"
ARG FORGEJO_BRANCH="forgejo-federation" ENV FORGEJO_BRANCH "forgejo-federation"
ARG FORGEJO_FOLDER="forgejo-fed"
#Build deps #Build deps
RUN apk --no-cache add build-base git nodejs npm RUN apk --no-cache add build-base git nodejs npm
#Setup repo #Setup repo
RUN git clone --single-branch --branch FORGEJO_BRANCH FORGEJO_GIT_URL FORGEJO_FOLDER RUN git clone --single-branch --branch ${FORGEJO_BRANCH} ${FORGEJO_GIT_URL} ${GOPATH}/src/code.gitea.io/gitea
COPY FORGEJO_FOLDER/* ${GOPATH}/src/code.gitea.io/gitea
WORKDIR ${GOPATH}/src/code.gitea.io/gitea WORKDIR ${GOPATH}/src/code.gitea.io/gitea
#Checkout version if set #Checkout version if set
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \ RUN make clean-all build
&& make clean-all build
# Begin env-to-ini build # Begin env-to-ini build
RUN go build contrib/environment-to-ini/environment-to-ini.go RUN go build contrib/environment-to-ini/environment-to-ini.go
# Run stage # Run stage
FROM docker.io/library/alpine:3.17 FROM docker.io/library/alpine:3.18
LABEL maintainer="contact@forgejo.org" LABEL maintainer="contact@forgejo.org"
EXPOSE 22 3000 EXPOSE 22 3000
@ -67,7 +65,7 @@ VOLUME ["/data"]
ENTRYPOINT ["/usr/bin/entrypoint"] ENTRYPOINT ["/usr/bin/entrypoint"]
CMD ["/bin/s6-svscan", "/etc/s6"] CMD ["/bin/s6-svscan", "/etc/s6"]
COPY docker/root / COPY --from=build-env /go/src/code.gitea.io/gitea/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/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/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 COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh

View file

@ -1,4 +0,0 @@
#!/bin/bash
install -m 0700 /tmp/entrypoint.sh /
install -m 0700 /tmp/functions.sh /usr/local/bin/

View file

@ -0,0 +1,10 @@
FROM c4k-forgejo-fed
RUN apk --no-cache add openjdk11-jre-headless
RUN curl -L -o /tmp/serverspec.jar \
https://github.com/DomainDrivenArchitecture/dda-serverspec-crate/releases/download/2.0.0/dda-serverspec-standalone.jar
COPY serverspec.edn /tmp/serverspec.edn
RUN java -jar /tmp/serverspec.jar /tmp/serverspec.edn -v

View file

@ -0,0 +1,8 @@
{:file [{:path "/usr/bin/entrypoint" :mod "755"}
{:path "/app/gitea/gitea" :mod "755"}
{:path "/usr/local/bin/gitea" :mod "755"}
{:path "/usr/local/bin/environment-to-ini" :mod "755"}
{:path "/etc/s6/gitea/" :mod "755"}
{:path "/etc/s6/openssh/" :mod "755"}
{:path "/etc/s6/.s6-svscan/" :mod "755"}
{:path "/etc/profile.d/gitea_bash_autocomplete.sh" :mod "644"}]}

View file

@ -47,14 +47,14 @@
(def config-defaults {:issuer "staging"}) (def config-defaults {:issuer "staging"})
(def config? (s/keys :req-un [::fqdn (def config? (s/keys :req-un [::fqdn
::deploy-federated
::mailer-from ::mailer-from
::mailer-host ::mailer-host
::mailer-port ::mailer-port
::service-noreply-address ::service-noreply-address]
::deploy-federated] :opt-un [::issuer
:opt-un [::issuer ::default-app-name
::default-app-name
::service-domain-whitelist])) ::service-domain-whitelist]))
(def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password ::mailer-user ::mailer-pw])) (def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password ::mailer-user ::mailer-pw]))

View file

@ -44,13 +44,12 @@
}) })
(cut/generate-appini-env {:default-app-name "test forgejo" (cut/generate-appini-env {:default-app-name "test forgejo"
:deploy-federated "true" :deploy-federated "true"
:fqdn "test.com" :fqdn "test.com"
:mailer-from "test@test.com" :mailer-from "test@test.com"
:mailer-host "mail.test.com" :mailer-host "mail.test.com"
:mailer-port "456" :mailer-port "456"
:service-domain-whitelist "test.com,test.net" :service-domain-whitelist "test.com,test.net"
:service-noreply-address "noreply@test.com" :service-noreply-address "noreply@test.com"})))))
})))))
(deftest should-generate-non-federated-deployment (deftest should-generate-non-federated-deployment
(is (= {:apiVersion "apps/v1", (is (= {:apiVersion "apps/v1",
@ -131,4 +130,4 @@
(is (= {:storage-c1 "1Gi", (is (= {:storage-c1 "1Gi",
:storage-c2 "15Gi"} :storage-c2 "15Gi"}
(th/map-diff (cut/generate-data-volume {:volume-total-storage-size 1}) (th/map-diff (cut/generate-data-volume {:volume-total-storage-size 1})
(cut/generate-data-volume {:volume-total-storage-size 15}))))) (cut/generate-data-volume {:volume-total-storage-size 15})))))