From a2e22c25b143fb1b3e9d45ebf7c81538d1f1ef5b Mon Sep 17 00:00:00 2001 From: Gapodo Date: Mon, 5 Dec 2022 22:06:06 +0100 Subject: [PATCH] debug docker --- .woodpecker/compliance-and-tests.yml | 182 +++++++++++++-------------- .woodpecker/release-version.yml | 24 ++-- Dockerfile.ci | 33 +---- docker/map-binaries.sh | 20 ++- 4 files changed, 126 insertions(+), 133 deletions(-) diff --git a/.woodpecker/compliance-and-tests.yml b/.woodpecker/compliance-and-tests.yml index 72afdbfad0..8fb8e903ea 100644 --- a/.woodpecker/compliance-and-tests.yml +++ b/.woodpecker/compliance-and-tests.yml @@ -9,105 +9,105 @@ variables: - &gitea_test_env_image 'gitea/test_env:linux-amd64' pipeline: - # dummy: + dummy: + image: *golang_image + commands: + - exit 0 + # deps-backend: # image: *golang_image + # pull: true + # secrets: + # - goproxy_override # commands: - # - exit 0 - deps-backend: - image: *golang_image - pull: true - secrets: - - goproxy_override - commands: - - test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}" - - make deps-backend + # - test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}" + # - make deps-backend - security-check: - image: *golang_image - pull: true - secrets: - - goproxy_override - commands: - - test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}" - - make security-check + # security-check: + # image: *golang_image + # pull: true + # secrets: + # - goproxy_override + # commands: + # - test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}" + # - make security-check - lint-backend: - image: *gitea_test_env_image - pull: true - secrets: - - goproxy_override - environment: - - TAGS=bindata sqlite sqlite_unlock_notify - - GOSUMDB=sum.golang.org - commands: - - test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}" - - make lint-backend + # lint-backend: + # image: *gitea_test_env_image + # pull: true + # secrets: + # - goproxy_override + # environment: + # - TAGS=bindata sqlite sqlite_unlock_notify + # - GOSUMDB=sum.golang.org + # commands: + # - test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}" + # - make lint-backend - checks-backend: - image: *golang_image - pull: true - secrets: - - goproxy_override - commands: - - test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}" - - make --always-make checks-backend + # checks-backend: + # image: *golang_image + # pull: true + # secrets: + # - goproxy_override + # commands: + # - test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}" + # - make --always-make checks-backend - fetch-tags: - image: docker:git - pull: true - commands: - - git config --add safe.directory '*' - - git fetch --tags --force + # fetch-tags: + # image: docker:git + # pull: true + # commands: + # - git config --add safe.directory '*' + # - git fetch --tags --force - tag-pre-condition: - image: drone/git - pull: true - commands: - - git update-ref refs/heads/tag_test ${CI_COMMIT_SHA} + # tag-pre-condition: + # image: drone/git + # pull: true + # commands: + # - git update-ref refs/heads/tag_test ${CI_COMMIT_SHA} - prepare-test-env: - image: *gitea_test_env_image - pull: true - secrets: - - goproxy_override - commands: - - test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}" - - ./build/test-env-prepare.sh + # prepare-test-env: + # image: *gitea_test_env_image + # pull: true + # secrets: + # - goproxy_override + # commands: + # - test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}" + # - ./build/test-env-prepare.sh - build-test: - image: *gitea_test_env_image - pull: true - secrets: - - goproxy_override - environment: - - GOSUMDB=sum.golang.org - - TAGS=bindata sqlite sqlite_unlock_notify - commands: - - test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}" - - su gitea -c './build/test-env-check.sh' - - su gitea -c 'make backend' + # build-test: + # image: *gitea_test_env_image + # pull: true + # secrets: + # - goproxy_override + # environment: + # - GOSUMDB=sum.golang.org + # - TAGS=bindata sqlite sqlite_unlock_notify + # commands: + # - test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}" + # - su gitea -c './build/test-env-check.sh' + # - su gitea -c 'make backend' - unit-test: - image: *gitea_test_env_image - pull: true - secrets: - - github_read_token - - goproxy_override - environment: - - TAGS=bindata sqlite sqlite_unlock_notify - - RACE_ENABLED=true - commands: - - test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}" - - su gitea -c 'make unit-test-coverage test-check' + # unit-test: + # image: *gitea_test_env_image + # pull: true + # secrets: + # - github_read_token + # - goproxy_override + # environment: + # - TAGS=bindata sqlite sqlite_unlock_notify + # - RACE_ENABLED=true + # commands: + # - test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}" + # - su gitea -c 'make unit-test-coverage test-check' - test-sqlite: - image: *gitea_test_env_image - environment: - - USE_REPO_TEST_DIR=1 - - GOPROXY=off - - TAGS=bindata gogit sqlite sqlite_unlock_notify - - TEST_TAGS=bindata gogit sqlite sqlite_unlock_notify - commands: - - su gitea -c 'timeout -s ABRT 120m make test-sqlite-migration test-sqlite' - when: - - evaluate: 'not (CI_COMMIT_MESSAGE contains "[SKIP SQLITE TEST]")' + # test-sqlite: + # image: *gitea_test_env_image + # environment: + # - USE_REPO_TEST_DIR=1 + # - GOPROXY=off + # - TAGS=bindata gogit sqlite sqlite_unlock_notify + # - TEST_TAGS=bindata gogit sqlite sqlite_unlock_notify + # commands: + # - su gitea -c 'timeout -s ABRT 120m make test-sqlite-migration test-sqlite' + # when: + # - evaluate: 'not (CI_COMMIT_MESSAGE contains "[SKIP SQLITE TEST]")' diff --git a/.woodpecker/release-version.yml b/.woodpecker/release-version.yml index f073445ce0..6e6078c8be 100644 --- a/.woodpecker/release-version.yml +++ b/.woodpecker/release-version.yml @@ -16,10 +16,10 @@ variables: # Docker and XGO platforms may vary in name (arm/v6/v7,...), please make sure, # that all platforms listed in docker_platforms are also in make_platforms # for the mapping look at docker/map-binaries.sh - #- &make_platforms 'linux/amd64,linux/arm64' - #- &docker_platforms 'linux/amd64,linux/arm64' - - &make_platforms 'linux/amd64' - - &docker_platforms 'linux/amd64' + - &make_platforms 'linux/amd64,linux/arm64' + - &docker_platforms 'linux/amd64,linux/arm64' + #- &make_platforms 'linux/amd64' + #- &docker_platforms 'linux/amd64' pipeline: fetch-tags: @@ -99,11 +99,22 @@ pipeline: - releaseteamtoken - releaseteamuser + prep-multiarch-binaries: + image: *golang_image # image reuse to reduce pull times, go not required + pull: true + # the fallback version-name used by make, defaults to main in the script use this if we change the default name + # environment: + # defaulttagname: main + commands: + - mkdir docker/bin + - ./docker/map-binaries.sh ./dist/binaries forgejo gitea ${CI_COMMIT_TAG##v} + - ./docker/map-binaries.sh ./dist/contrib environment-to-ini false ${CI_COMMIT_TAG##v} + when: + event: tag + build-docker: image: *buildx_plugin_image pull: true - environment: - defaulttagname: main settings: dockerfile: Dockerfile.ci no_cache: true @@ -116,7 +127,6 @@ pipeline: - CACHEBUST=${CI_PIPELINE_NUMBER} build_args_from_env: - CI_COMMIT_TAG - - DEFAULTTAGNAME password: from_secret: releaseteamtoken username: diff --git a/Dockerfile.ci b/Dockerfile.ci index bed016171d..f21a2d9aa4 100644 --- a/Dockerfile.ci +++ b/Dockerfile.ci @@ -1,36 +1,9 @@ FROM --platform=$BUILDPLATFORM alpine:3.17.0 as prep ARG BUILDPLATFORM -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 - -RUN apk --no-cache add bash && \ - mkdir -p /docker/bin && \ - mkdir /dist - -ENV USER git - -ARG DEFAULTTAGNAME -ARG CI_COMMIT_TAG -ENV DEFAULTTAGNAME=${DEFAULTTAGNAME:-main} COPY docker /docker/ -COPY dist /dist/ -RUN /docker/map-binaries.sh /dist/binaries forgejo ${CI_COMMIT_TAG##v} && \ - /docker/map-binaries.sh /dist/contrib environment-to-ini ${CI_COMMIT_TAG##v} - -RUN chmod 755 /docker/root/usr/bin/entrypoint /docker/root/etc/s6/gitea/* /docker/root/etc/s6/openssh/* /docker/root/etc/s6/.s6-svscan/* && \ - find /docker/bin -name 'forgejo' -type f | xargs -I{} /bin/chmod 0755 {} && \ - find /docker/bin -name 'environment-to-ini' -type f | xargs -I{} /bin/chmod 0755 {} +RUN chmod 755 /docker/root/usr/bin/entrypoint /docker/usr/local/bin/gitea /docker/root/etc/s6/gitea/* /docker/root/etc/s6/openssh/* /docker/root/etc/s6/.s6-svscan/* FROM alpine:3.17.0 LABEL maintainer="contact@forgejo.org" @@ -76,5 +49,5 @@ ENTRYPOINT ["/usr/bin/entrypoint"] CMD ["/bin/s6-svscan", "/etc/s6"] COPY --from=prep /docker/root / -COPY --from=prep /docker/bin/$TARGETPLATFORM/forgejo /app/gitea/gitea -COPY --from=prep /docker/bin/$TARGETPLATFORM/environment-to-ini /usr/local/bin/environment-to-ini +COPY --chmod=755 ./docker/bin/$TARGETPLATFORM/* /app/gitea/ +RUN ln -s /app/gitea/environment-to-ini /usr/local/bin/environment-to-ini diff --git a/docker/map-binaries.sh b/docker/map-binaries.sh index a77853198e..89b1e83c20 100755 --- a/docker/map-binaries.sh +++ b/docker/map-binaries.sh @@ -7,11 +7,21 @@ fi BINARYLOOKUPPATH="${1}" FILEBASENAME="${2}" +RENAME="${3}" -if [[ ${#@} -gt 2 ]] && ! [[ "${3}" == "" ]]; then - FILEVERSION="${3}" +if [[ ${#@} -gt 3 ]] && ! [[ "${4}" == "" ]]; then + FILEVERSION="${4}" else - FILEVERSION="$DEFAULTTAGNAME" + FILEVERSION="${DEFAULTTAGNAME:-main}" +fi + +OUTFILENAME="" +if [[ "$RENAME" == "false" ]]; then + OUTFILENAME="${FILEBASENAME}" +elif [["$RENAME" == "true" ]]; then + OUTFILENAME=gitea +else + OUTFILENAME="${RENAME}" fi FILE_WIHTOUT_PLATFORM="${FILEBASENAME}-${FILEVERSION}" @@ -34,8 +44,8 @@ function map(){ local platform="$(grep $bin_platform "${DOCKERDIR}/archmap.txt" | cut -d':' -f2)" mkdir -p "${DOCKERDIR}/bin/$platform" - echo "Mapped ${file} to $platform, copying" - cp "${file}" "${DOCKERDIR}/bin/$platform/${FILEBASENAME}" + echo "Mapped ${file} to $platform, copying to ${DOCKERDIR}/bin/$platform/${OUTFILENAME}" + cp "${file}" "${DOCKERDIR}/bin/$platform/${OUTFILENAME}" } cd "$WS_BASE/${BINARYLOOKUPPATH}"