diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e946f570c..1bef6d24c 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -49,3 +49,10 @@ updates: - "dependencies" - "ok-to-test" - "ready-for-review" + + - package-ecosystem: "docker" + directory: "/server/" + schedule: + interval: "weekly" + day: "sunday" + time: "10:00" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ea31a66ec..1c4e8e9a4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,3 +56,17 @@ jobs: DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} GIT_TAG: ${{ env.GIT_TAG }} run: devbox run -- just release-oci + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Release kommander applications server + env: + GIT_TAG: ${{ env.GIT_TAG }} + run: | + git config --global user.name "${GITHUB_ACTOR}" + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + devbox run -- just release-server diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d597ace99..ed802a044 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -33,7 +33,10 @@ jobs: git diff --exit-code - name: Check if kommander application server works - run: devbox run -- just test-server + run: | + git config --global user.name "${GITHUB_ACTOR}" + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + devbox run -- just test-server - name: Report Coveralls uses: coverallsapp/github-action@v2 diff --git a/.include-airgapped b/.include-airgapped index 3c0a89b98..d1cb856db 100644 --- a/.include-airgapped +++ b/.include-airgapped @@ -1,3 +1,4 @@ +./clusters ./common ./services ./charts diff --git a/just/test.just b/just/test.just index 57db5c766..39844992d 100644 --- a/just/test.just +++ b/just/test.just @@ -1,14 +1,16 @@ -test-server: - #!/usr/bin/env bash - set -euox pipefail - CONTAINER_ID=$(just --justfile {{ justfile() }} --working-directory {{ invocation_directory() }} _run_server 2>&1 | tail -n 1) - trap "docker kill ${CONTAINER_ID}" EXIT - curl --no-progress-meter --output /dev/null --retry-connrefused --retry 5 --retry-delay 3 http://localhost:5000/{{ archive_name }} +test_container_name := "kommander-applications-server" + +test-server: _run_server + sleep 3 # wait for container + git ls-remote git://localhost:12345/data _run_server: (release-server "false") docker run \ - --env DUFS_TLS_CERT \ - --env DUFS_TLS_KEY \ - --network=host \ + --name {{ test_container_name }} \ + --publish 12345:12345 \ --detach \ + --user 1000:1000 \ {{ server_docker_repository }}:{{ git_tag }} + +_kill_server: + docker kill {{ test_container_name }} diff --git a/justfile b/justfile index bf33e2a15..bd78e4921 100644 --- a/justfile +++ b/justfile @@ -18,18 +18,29 @@ archive_name := "kommander-applications-" + git_tag+ ".tar.gz" published_url := "https://downloads.d2iq.com" / s3_path / archive_name release publish="true" tmp_dir=`mktemp --directory`: (_prepare-archive tmp_dir) && _cleanup - if {{ publish }}; then aws s3 cp --acl {{ s3_acl }} {{ archive_name }} {{ s3_uri }}; fi - @echo "Published to {{ published_url }}" + #!/usr/bin/env bash + set -euox pipefail + if {{ publish }}; then + aws s3 cp --acl {{ s3_acl }} {{ archive_name }} {{ s3_uri }} + echo "Published to {{ published_url }}" + else + echo "Skipping publish" + fi release-oci publish="true" tmp_dir=`mktemp --directory`: (_prepare-files-for-a-bundle tmp_dir) - if {{ publish }}; then \ - cd {{ tmp_dir }} && echo "${DOCKER_PASSWORD}" | oras push --password-stdin --username "${DOCKER_USERNAME}" --verbose {{ registry }}/{{ repository }}:{{ git_tag }} .; + #!/usr/bin/env bash + set -euox pipefail + cd {{ tmp_dir }} + if {{ publish }}; then + oras push --username "${DOCKER_USERNAME}" --password "${DOCKER_PASSWORD}" --verbose {{ registry }}/{{ repository }}:{{ git_tag }} . + else + echo "Skipping publish" fi -release-server publish="true" tmp_dir=`mktemp --directory`: (_prepare-archive tmp_dir) && _cleanup - cp {{ archive_name }} ./server/ - cd ./server && docker buildx build . --tag {{ server_docker_repository }}:{{ git_tag }} --build-arg ARCHIVE_NAME={{ archive_name }} - rm ./server/{{ archive_name }} +release-server publish="true" tmp_dir=`mktemp --directory`: (_prepare-git-repository tmp_dir) + cp -r {{ tmp_dir }} ./server/data/ + cd ./server && docker buildx build . --tag {{ server_docker_repository }}:{{ git_tag }} + rm -rf ./server/data/ if {{ publish }}; then docker push {{ server_docker_repository }}:{{ git_tag }}; fi service_version:=`ls services/git-operator/ | grep -E "v?[[:digit:]]\.[[:digit:]]\.[[:digit:]]"` @@ -44,6 +55,12 @@ git-operator-fetch-manifests tmp_dir=`mktemp --directory`: _prepare-archive dir: (_prepare-files-for-a-bundle dir) tar -cvzf {{ justfile_directory() }}/{{ archive_name }} -C {{ dir }} . +_prepare-git-repository output_dir tmp_dir_for_cloning=`mktemp --directory`: + cd {{ output_dir }} && git init --bare --initial-branch=main + git clone {{ output_dir }} {{ tmp_dir_for_cloning }} + just --justfile {{ justfile() }} --working-directory {{ invocation_directory() }} _prepare-files-for-a-bundle {{ tmp_dir_for_cloning }} + cd {{ tmp_dir_for_cloning }} && git add . && git commit --no-gpg-sign --message "initial commit" && git push origin main + _cleanup: rm {{ archive_name }} @@ -51,4 +68,5 @@ _prepare-files-for-a-bundle output_dir: rsync --quiet --archive --recursive --files-from={{ include_file }} --exclude-from={{ exclude_file }} {{ justfile_directory() }} {{ output_dir }} yq 'del(.resources[] | select(. == "ai-navigator-repos.yaml"))' --inplace {{ output_dir }}/common/helm-repositories/kustomization.yaml + import 'just/test.just' diff --git a/server/Dockerfile b/server/Dockerfile index 3c58719c5..17b6a2b0c 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -1,13 +1,11 @@ -FROM sigoden/dufs +FROM alpine:3.20.3 -ARG ARCHIVE_NAME +LABEL org.opencontainers.image.source=https://github.com/alpinelinux/docker-alpine -# Dufs settings: -ENV DUFS_BIND=127.0.0.1 -ENV DUFS_PORT=5000 -ENV DUFS_TLS_CERT=cert.pem -ENV DUFS_TLS_KEY=key.pem +RUN apk add --update git && \ + apk add --update git-daemon \ + rm -rf /var/cache/apk/* -COPY ${ARCHIVE_NAME} /data/ +COPY --chown=1000:1000 data /data -CMD ["/data"] +CMD ["git", "daemon", "--verbose", "--port=12345","--export-all", "/data"]