diff --git a/.cz.yaml b/.cz.yaml new file mode 100644 index 0000000..62b2ada --- /dev/null +++ b/.cz.yaml @@ -0,0 +1,7 @@ +commitizen: + bump_message: "build(version): bump version $current_version \u2192 $new_version" + changelog_incremental: false + name: cz_conventional_commits + tag_format: $major.$minor.$patch$prerelease + update_changelog_on_bump: true + version: 0.0.1 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 745488d..2e30af7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,124 +1,23 @@ -# available variables, do not uncomment all at once. -# variables: -# CI_BUILDX_ARCHS: "linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7" -# CI_BUILD_ARM: true -# CI_BUILD_ARM64: true -# CI_AMD64_DISABLED: true -.build: - image: docker:dind - stage: build - services: - - name: docker:dind - entrypoint: ["env", "-u", "DOCKER_HOST"] - command: ["dockerd-entrypoint.sh"] - variables: - DOCKER_HOST: tcp://docker:2375/ - DOCKER_DRIVER: overlay2 - # See https://github.com/docker-library/docker/pull/166 - DOCKER_TLS_CERTDIR: "" - retry: 2 - before_script: - - | - if [[ -z "$CI_COMMIT_TAG" ]]; then - export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG} - export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_SHA} - else - export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE} - export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_TAG} - fi - - echo "$CI_REGISTRY_PASSWORD" | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY +include: + - project: nofusscomputing/projects/gitlab-ci + ref: development + file: + - .gitlab-ci_common.yaml + - type/docker-image.gitlab-ci.yaml -# these images depend on this repos image -# it must exist for for the arch that the gitlab-runner has. -build:buildx-master: - extends: .build - # set the image because we are using buildx here. - image: $CI_REGISTRY_IMAGE:latest - only: - refs: - - master - variables: - - $CI_BUILDX_ARCHS - script: - # Use docker-container driver to allow useful features (push/multi-platform) - - update-binfmts --enable # Important: Ensures execution of other binary formats is enabled in the kernel - - docker buildx create --driver docker-container --use - - docker buildx inspect --bootstrap - - docker buildx ls - - docker buildx build --platform $CI_BUILDX_ARCHS --progress plain --pull -t "$CI_REGISTRY_IMAGE" --push . -build:buildx: - extends: .build - # set the image because we are using buildx here. - image: $CI_REGISTRY_IMAGE:latest - only: - variables: - - $CI_BUILDX_ARCHS - except: - refs: - - master - script: - - update-binfmts --enable # Important: Ensures execution of other binary formats is enabled in the kernel - - docker buildx create --driver docker-container --use - - docker buildx inspect --bootstrap - - docker buildx ls - - docker buildx build --platform $CI_BUILDX_ARCHS --progress plain --pull -t "$CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG" --push . +variables: + MY_PROJECT_ID: "45926238" -# disable build:armv7 for now since it seems to have an issue with dind -.build:arm: - extends: .build - only: - variables: - - $CI_BUILD_ARM - except: - variables: - - $CI_BUILDX_ARCHS - tags: - - arm - script: - - docker build -t "$CI_APPLICATION_REPOSITORY/arm:$CI_APPLICATION_TAG" . - - docker push "$CI_APPLICATION_REPOSITORY/arm:$CI_APPLICATION_TAG" + GIT_SYNC_URL: "https://$GITHUB_USERNAME_ROBOT:$GITHUB_TOKEN_ROBOT@github.com/NoFussComputing/docker-buildx-qemu.git" -build:arm64: - extends: .build - only: - variables: - - $CI_BUILD_ARM64 - except: - variables: - - $CI_BUILDX_ARCHS - tags: - - arm64 + #JOB_STOP_CONVENTIONAL_COMMITS: 'disable for testing' + #JOB_STOP_GIT_PUSH_MIRROR: 'disable for testing' + #JOB_STOP_GITLAB_RELEASE: 'disable for testing' - script: - - docker build -t "$CI_APPLICATION_REPOSITORY/arm64:$CI_APPLICATION_TAG" . - - docker push "$CI_APPLICATION_REPOSITORY/arm64:$CI_APPLICATION_TAG" - -# builds this by default -build:amd64: - extends: .build - except: - variables: - - $CI_AMD64_DISABLED - - $CI_BUILDX_ARCHS - script: - - docker build -t "$CI_APPLICATION_REPOSITORY/amd64:$CI_APPLICATION_TAG" . - - docker push "$CI_APPLICATION_REPOSITORY/amd64:$CI_APPLICATION_TAG" - -build:manifest: - extends: .build - stage: deploy - except: - variables: - - $CI_BUILDX_ARCHS - script: - - echo "Checking amd86 build..." && [[ -z $CI_AMD64_DISABLED ]] && echo "found" && export CI_MANIFEST_LIST="$CI_APPLICATION_REPOSITORY/amd64:$CI_APPLICATION_TAG" - - echo "Checking arm build..." && [[ $CI_BUILD_ARM ]] && echo "found" && export CI_MANIFEST_LIST="$CI_MANIFEST_LIST $CI_APPLICATION_REPOSITORY/arm:$CI_APPLICATION_TAG" - - echo "Checking arm64 build..." && [[ $CI_BUILD_ARM64 ]] && echo "found" && export CI_MANIFEST_LIST="$CI_MANIFEST_LIST $CI_APPLICATION_REPOSITORY/arm64:$CI_APPLICATION_TAG" - - export DOCKER_CLI_EXPERIMENTAL=enabled - - echo $CI_MANIFEST_LIST - - docker manifest create $CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG $CI_MANIFEST_LIST && docker manifest push $CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG - - docker manifest create $CI_APPLICATION_REPOSITORY:latest $CI_MANIFEST_LIST && docker manifest push $CI_APPLICATION_REPOSITORY:latest - - echo "Checking master" && [[ $CI_COMMIT_REF_NAME == "master" ]] && docker manifest create $CI_REGISTRY_IMAGE:latest $CI_MANIFEST_LIST && docker manifest push $CI_REGISTRY_IMAGE:latest + DOCKER_IMAGE_BUILD_TARGET_PLATFORMS: "linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/arm64,linux/386,linux/arm/v7,linux/arm/v6" + DOCKER_IMAGE_PUBLISH_NAME: $CI_PROJECT_NAME + DOCKER_IMAGE_PUBLISH_REGISTRY: docker.io/nofusscomputing + DOCKER_IMAGE_PUBLISH_URL: https://hub.docker.com/r/nofusscomputing/$DOCKER_IMAGE_PUBLISH_NAME diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..cc4d8a5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "gitlab-ci"] + path = gitlab-ci + url = https://gitlab.com/nofusscomputing/projects/gitlab-ci.git + branch = development diff --git a/Dockerfile b/Dockerfile index e3f39a9..4be7b83 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,37 @@ FROM debian -# Install Docker and qemu -# TODO Use docker stable once it properly supports buildx -RUN apt-get update && apt-get install -y \ + + + +RUN export DEBIAN_FRONTEND=noninteractive \ + && apt-get update && apt --fix-broken install \ + && apt install -y libc-bin locales-all + + + +RUN export DEBIAN_FRONTEND=noninteractive \ + && apt-get update && apt-get install -y \ apt-transport-https \ ca-certificates \ curl \ + git \ gnupg2 \ - software-properties-common && \ - curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - && \ + software-properties-common \ + python3 \ + python3-pip || true + + +# Install Docker and qemu +RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - && \ add-apt-repository "deb https://download.docker.com/linux/debian $(lsb_release -cs) stable" && \ apt-get update && apt-get install -y \ + docker-buildx-plugin \ docker-ce-cli \ binfmt-support \ - qemu-user-static + qemu-user-static || true -# Install buildx plugin -RUN mkdir -p ~/.docker/cli-plugins && \ - ARCH=`dpkg --print-architecture` && echo Running on $ARCH && curl -s https://api.github.com/repos/docker/buildx/releases/latest | \ - grep "browser_download_url.*linux-$ARCH" | cut -d : -f 2,3 | tr -d \" | \ - xargs curl -L -o ~/.docker/cli-plugins/docker-buildx && \ - chmod a+x ~/.docker/cli-plugins/docker-buildx # Write version file RUN printf "$(docker --version | perl -pe 's/^.*\s(\d+\.\d+\.\d+.*),.*$/$1/')_$(docker buildx version | perl -pe 's/^.*v?(\d+\.\d+\.\d+).*$/$1/')" > /version && \ cat /version + +RUN echo "[DEBUG] why arm64 reports no docker 'which docker'=[$(which docker)]" \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8dc76e0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,10 @@ +MIT License + +Copyright + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..9bc153a --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +