diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f746f2..747366c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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.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\"}" \ + +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 \ No newline at end of file diff --git a/infrastructure/docker-federated/build.py b/infrastructure/docker-federated/build.py index 9919c53..6b3cf58 100644 --- a/infrastructure/docker-federated/build.py +++ b/infrastructure/docker-federated/build.py @@ -12,7 +12,7 @@ class MyBuild(DevopsDockerBuild): @init def initialize(project): - project.build_depends_on('ddadevops>=0.12.4') + project.build_depends_on('ddadevops>=0.15.5') stage = 'prod' dockerhub_user = environ.get('DOCKERHUB_USER') if not dockerhub_user: @@ -49,4 +49,3 @@ def publish(project): def test(project): build = get_devops_build(project) build.test() - diff --git a/infrastructure/docker-federated/image/Dockerfile b/infrastructure/docker-federated/image/Dockerfile index ace4fb6..bf2e710 100644 --- a/infrastructure/docker-federated/image/Dockerfile +++ b/infrastructure/docker-federated/image/Dockerfile @@ -1,35 +1,33 @@ #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 ENV GOPROXY ${GOPROXY:-direct} -ARG GITEA_VERSION +#ARG GITEA_VERSION ARG TAGS="sqlite sqlite_unlock_notify" ENV TAGS "bindata timetzdata $TAGS" ARG CGO_EXTRA_CFLAGS -ARG FORGEJO_GIT_URL="https://codeberg.org/forgejo/forgejo.git" -ARG FORGEJO_BRANCH="forgejo-federation" -ARG FORGEJO_FOLDER="forgejo-fed" +ENV FORGEJO_GIT_URL "https://codeberg.org/forgejo/forgejo.git" +ENV FORGEJO_BRANCH "forgejo-federation" #Build deps RUN apk --no-cache add build-base git nodejs npm #Setup repo -RUN git clone --single-branch --branch FORGEJO_BRANCH FORGEJO_GIT_URL FORGEJO_FOLDER -COPY FORGEJO_FOLDER/* ${GOPATH}/src/code.gitea.io/gitea +RUN git clone --single-branch --branch ${FORGEJO_BRANCH} ${FORGEJO_GIT_URL} ${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 +RUN make clean-all build # Begin env-to-ini build RUN go build contrib/environment-to-ini/environment-to-ini.go # Run stage -FROM docker.io/library/alpine:3.17 +FROM docker.io/library/alpine:3.18 LABEL maintainer="contact@forgejo.org" EXPOSE 22 3000 @@ -67,7 +65,7 @@ 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/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 diff --git a/infrastructure/docker-federated/image/resources/install.sh b/infrastructure/docker-federated/image/resources/install.sh deleted file mode 100755 index 1937557..0000000 --- a/infrastructure/docker-federated/image/resources/install.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -install -m 0700 /tmp/entrypoint.sh / -install -m 0700 /tmp/functions.sh /usr/local/bin/ - diff --git a/infrastructure/docker-federated/test/Dockerfile b/infrastructure/docker-federated/test/Dockerfile new file mode 100644 index 0000000..10de78a --- /dev/null +++ b/infrastructure/docker-federated/test/Dockerfile @@ -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 diff --git a/infrastructure/docker-federated/test/serverspec.edn b/infrastructure/docker-federated/test/serverspec.edn new file mode 100644 index 0000000..7c95886 --- /dev/null +++ b/infrastructure/docker-federated/test/serverspec.edn @@ -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"}]} diff --git a/src/main/cljc/dda/c4k_forgejo/forgejo.cljc b/src/main/cljc/dda/c4k_forgejo/forgejo.cljc index 531e5eb..f92d75f 100644 --- a/src/main/cljc/dda/c4k_forgejo/forgejo.cljc +++ b/src/main/cljc/dda/c4k_forgejo/forgejo.cljc @@ -47,14 +47,14 @@ (def config-defaults {:issuer "staging"}) -(def config? (s/keys :req-un [::fqdn +(def config? (s/keys :req-un [::fqdn + ::deploy-federated ::mailer-from ::mailer-host ::mailer-port - ::service-noreply-address - ::deploy-federated] - :opt-un [::issuer - ::default-app-name + ::service-noreply-address] + :opt-un [::issuer + ::default-app-name ::service-domain-whitelist])) (def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password ::mailer-user ::mailer-pw])) diff --git a/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc b/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc index a068e00..d816e62 100644 --- a/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc +++ b/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc @@ -44,13 +44,12 @@ }) (cut/generate-appini-env {:default-app-name "test forgejo" :deploy-federated "true" - :fqdn "test.com" + :fqdn "test.com" :mailer-from "test@test.com" :mailer-host "mail.test.com" :mailer-port "456" :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 (is (= {:apiVersion "apps/v1", @@ -131,4 +130,4 @@ (is (= {:storage-c1 "1Gi", :storage-c2 "15Gi"} (th/map-diff (cut/generate-data-volume {:volume-total-storage-size 1}) - (cut/generate-data-volume {:volume-total-storage-size 15}))))) \ No newline at end of file + (cut/generate-data-volume {:volume-total-storage-size 15})))))